Create custom images group

4 posts, 1 answers
  1. Carolina
    Carolina avatar
    3 posts
    Member since:
    Oct 2012

    Posted 06 May Link to this post

    Hi I want to know if it is possible to create custom shapes and add them to the toolbox radDiagram, I need to create the figures shown in the attached image.

    I hope you can help me.
  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    1414 posts

    Posted 09 May Link to this post

    Hello Carolina,

    Thank you for writing.

    The following article shows how you can create custom shapes: Custom shapes.

    The following snippet shows how you can add the new shape to the toolbox:
    DiagramListViewDataItem item = new DiagramListViewDataItem();
    item.Key = "MyShape";
    item.Shape = new AShape();
    item.Group = radDiagramToolbox1.Groups[0];
    radDiagramToolbox1.Items.Add(item);

    Let me know if I can assist you further.

    Regards,
    Dimitar
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Carolina
    Carolina avatar
    3 posts
    Member since:
    Oct 2012

    Posted 10 May Link to this post

    Hello,

    Thanks for the prompt response, I followed the instructions you provided me, but even I achievement not understand how I can create a shape that contains another figure inside as I show in the attached image.

    As you can see in the diagram of the image I need to create a rectangular shape with a square black with a letter V inside, really have not much idea of how to do it.

    I hope you can help me, receives a warm greeting.

  5. Dimitar
    Admin
    Dimitar avatar
    1414 posts

    Posted 11 May Link to this post

    Hello Carolina,

    Thank you for writing back.

    You need to create a proper path. For example, you can add several rectangles to paint the border and the upper left part (the attached image shows the result on my side):
    public class AShape : Telerik.WinControls.ElementShape
    {
        public override GraphicsPath CreatePath(Rectangle bounds)
        {
            GraphicsPath path = new GraphicsPath();
     
            path.AddRectangle(new RectangleF(bounds.X, bounds.Y, 20, 20));
            //left
            path.AddRectangle(new RectangleF(bounds.X, bounds.Y + 20, 2, bounds.Height - 20));
            //bottom
            path.AddRectangle(new RectangleF(bounds.X + 2, bounds.Y + bounds.Height - 2, bounds.Width - 2, 2));
            //top
            path.AddRectangle(new RectangleF(bounds.X + 20, bounds.Y, bounds.Width - 20, 2));
            //right
            path.AddRectangle(new RectangleF(bounds.X + bounds.Width - 2, bounds.Y + 2, 2, bounds.Height - 4));
     
            path.AddString("V", new FontFamily("Arial"), 0, 10, new Point(5, 5), StringFormat.GenericTypographic);
     
            return path;
        }
    }

    Please let me know if there is something else I can help you with. 
     
    Regards,
    Dimitar
    Telerik
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Back to Top