This is a migrated thread and some comments may be shown as answers.

add container to custom toolbox in codebehind

6 Answers 176 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Kidder
Top achievements
Rank 1
Kidder asked on 15 Nov 2012, 02:31 PM
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,

6 Answers, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 20 Nov 2012, 12:23 PM
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.

0
Kidder
Top achievements
Rank 1
answered on 20 Nov 2012, 08:17 PM
Hi Hristo,

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

Thanks
0
Zarko
Telerik team
answered on 23 Nov 2012, 03:40 PM
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.

0
Kidder
Top achievements
Rank 1
answered on 23 Nov 2012, 09:22 PM
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);
    }
}


0
Tina Stancheva
Telerik team
answered on 28 Nov 2012, 12:16 PM
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.

0
Kidder
Top achievements
Rank 1
answered on 29 Nov 2012, 11:31 AM
Thank you very much
Tags
Diagram
Asked by
Kidder
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Kidder
Top achievements
Rank 1
Zarko
Telerik team
Tina Stancheva
Telerik team
Share this question
or