Custom shape with model

4 posts, 0 answers
  1. Tino
    Tino avatar
    86 posts
    Member since:
    Jul 2017

    Posted 25 May 2018 Link to this post

    What's the easiest way to get a custom shape based on a rectangle, to draw a model object?

    For example, if this is a dummy model object

    class model
    {
        public string text { get; set; }
        public int x { get; set; }
        public int y { get; set; }
        public int width { get; set; }
        public int height { get; set; }
    }

     

    I want to display these objects using a custom shape that is just a white rectangle with a black border, programmatically. Please give a short sample.

     

     

     

  2. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3462 posts

    Posted 25 May 2018 Link to this post

    Hello, Tino,    

    By default, when you bind RadDiagram, RadDiagramShape items are created by the DiagramDataLayer. It would be nice to have the possibility to replace the DiagramDataLayer for example and override its CreateDiagramShapeItem method to use custom RadDiagramShapes. I have logged it in our feedback portal. You can track its progress, subscribe for status changes and add your comments on the following link - feedback item.

    I have also updated your Telerik points.

    Currently, the possible solution that I can suggest is to use unbound mode and add your custom shapes considering the data stored in the model's records.

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Tino
    Tino avatar
    86 posts
    Member since:
    Jul 2017

    Posted 27 May 2018 in reply to Dess | Tech Support Engineer, Sr. Link to this post

    Hi, this question is already about unbound mode (programmatic). Thanks.
  4. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    3462 posts

    Posted 28 May 2018 Link to this post

    Hello, Tino,    

    If you need to add custom shapes in RadDiagram, it is necessary to create a derivative of the RadDiagramShape class. Create the desired properties and implement the desired custom logic you need in the custom shape. Then, in order to add the custom shapes programmatically in unbound mode, it is just necessary to create an instance of the custom shape, extract the necessary information from the Model object you have and add the shape by using the RadDiagram.AddShape method passing the shape instance as a parameter. The following help article demonstrates how to create a custom shape and add it to the diagram: https://docs.telerik.com/devtools/winforms/diagram/custom-shapes

    I hope this information helps. If you have any additional questions, please let me know. 

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top