add container to custom toolbox in codebehind

7 posts, 0 answers
  1. Kidder
    Kidder avatar
    13 posts
    Member since:
    Nov 2012

    Posted 15 Nov 2012 Link to this post

    Hi,

    I want to add auto container and fixed container to my custom toolbox in codebehind. But how can i add this shapes like this;

     firstGallery.Shapes.Add(new MyShape
                {
                    Header = "Elips",
                    Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.EllipseShape)
                });
               var geo = GeometryParser.GetGeometry("M16.35,6.39 C16.28,7.36 12.26,20.45 12.26,20.45 L20.56,20.45 C20.56,20.45 16.64,7.54 16.53,6.39 z M12.30,0.50 L20.97,0.50 L32.50,33.50 L24.54,33.50 L22.23,26.16 L10.70,26.16 L8.42,33.50 L0.50,33.50 z");
                
               thirdgallery.Shapes.Add(new MyShape
                {
                    Header = "custom", 
                    Geometry = geo
                });

    Best regards,
  2. Hristo
    Admin
    Hristo avatar
    352 posts

    Posted 20 Nov 2012 Link to this post

    Hi Kidder,

    You should be able to add the container shape the same way you and other types of shapes. I can see in your code snippet that you are creating custom shape "MyShape" and adding it to the gallery. You could try creating a custom or regular container shape (RadDiagramContainerShape) and add it to the gallery using the approach from your code.

    Greetings,
    Hristo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. DevCraft banner
  4. Kidder
    Kidder avatar
    13 posts
    Member since:
    Nov 2012

    Posted 20 Nov 2012 Link to this post

    Hi Hristo,

    please give me example for  regular container shape (RadDiagramContainerShape) adding to first gallery to my custom toolbox in code behind

    Thanks
  5. Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 23 Nov 2012 Link to this post

    Hello Kidder,
    I'm sure if I'll be able to help you because I don't know your exact structure (I don't know what firstGallery is, and I don't know how you set the itemsSource of your custom toolbox) but you could try something like this:
     
    firstGallery.Shapes.Add(new RadDiagramContainerShape());
    firstGallery.Shapes.Add(new RadDiagramContainerShape() { ContainerLayout = Primitives.ContainerLayout.Fixed });
    If this doesn't work I'd like to ask you for a sample project or some more code snippets.
    We're looking forward to hearing from you. 

    Regards,
    Zarko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Kidder
    Kidder avatar
    13 posts
    Member since:
    Nov 2012

    Posted 23 Nov 2012 Link to this post

    Hi,
    i've used http://www.telerik.com/help/silverlight/raddiagram-extensions-toolbox.html example for Customize the RadDiagramToolbox ItemsSource Collection but i couldnt add container in this toolbox;

    Please give me example for add RadDiagramContainerShape to this toolbox?

    Best regards..

    public class MyShape
    {
        public Geometry Geometry { get; set; }
        public string Header { get; set; }
    }
    public class MyGallery
    {
        public string Header { get; set; }
        public ObservableCollection<MyShape> Shapes { get; set; }
        public MyGallery()
        {
            this.Shapes = new ObservableCollection<MyShape>();
        }
    }
    public class MainViewModel
    {
        public ObservableCollection<MyGallery> Items { get; set; }
        public MainViewModel()
        {
            this.Items = new ObservableCollection<MyGallery>();
            //create and populate the first custom gallery
            MyGallery firstGallery = new MyGallery { Header = "First Gallery" };
            firstGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 1.1",
                Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.CloudShape)
            });
            firstGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 1.2",
                Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.EllipseShape)
            });
            firstGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 1.3",
                Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.HexagonShape)
            });
            firstGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 1.4",
                Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.PentagonShape)
            });
            firstGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 1.5",
                Geometry = ShapeFactory.GetShapeGeometry(CommonShapeType.RightTriangleShape)
            });
            this.Items.Add(firstGallery);


            //create and populate the second custom gallery
            MyGallery secondGallery = new MyGallery { Header = "Second Gallery" };
            secondGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 2.1",
                Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.CardShape)
            });
            secondGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 2.2",
                Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.Database1Shape)
            });
            secondGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 2.3",
                Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.CollateShape)
            });
            secondGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 2.4",
                Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.DataShape)
            });
            secondGallery.Shapes.Add(new MyShape
            {
                Header = "Shape 2.5",
                Geometry = ShapeFactory.GetShapeGeometry(FlowChartShapeType.DisplayShape)
            });
            this.Items.Add(secondGallery);
        }
    }


  7. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 28 Nov 2012 Link to this post

    Hi Kidder,

    Please find attached a sample solution demonstrating how to add containers in your view model and display them in the RadDiagramToolbox.

    Basically, the approach demonstrated in the solution takes two different data objects - MyShape and MyContainer and uses different DataTemplates to visualize them in the different galleries in the DiagramToolbox.

    Let me know if this is what you had in mind or if you need more info.

    All the best,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  8. Kidder
    Kidder avatar
    13 posts
    Member since:
    Nov 2012

    Posted 29 Nov 2012 Link to this post

    Thank you very much
Back to Top
DevCraft banner