Property color

Hi,

when I draw a line I want to change the color but it's impossible, I couldn't see the palette.

I send you a video with the problem.

Attachment: Video_1534508724_7f05fd78.zip

4 Replies

SG Shyam G Syncfusion Team August 20, 2018 12:44 PM UTC

Hi Blanca, 
In order to achieve your requirement, we suggest you to customize Diagram’s “LineTool” and override “CreateNode()” method to as per your requirement. please refer to the below code example.  
  
Code example:  
  
[C#]  
  
public class CustomLineTool 
        : LineTool 
    { 
        #region Class initialize/finalize methods 
        /// <summary> 
        /// Initializes a new instance of the <see cref="LineTool"/> class. 
        /// </summary> 
        /// <param name="controller">The controller.</param> 
        public CustomLineTool(DiagramController controller) 
            : base(controller) 
        { 
            this.Name = "CustomLineTool"; 
        } 
        #endregion 
 
        #region Class override 
        /// <summary> 
        /// Creates the line shape node. 
        /// </summary> 
        /// <param name="ptStart">The start point.</param> 
        /// <param name="ptEnd">The end point.</param> 
        /// <returns>The node.</returns> 
        protected override Node CreateNode(PointF ptStart, PointF ptEnd) 
        { 
            LineBase toReturn = new Line(new PointF[] { ptStart, ptEnd }); 
            //set the line color based on your requirement 
            toReturn.LineStyle.LineColor = Color.Yellow; 
            toReturn.EditStyle.DefaultHandleEditMode = HandleEditMode.Vertex; 
 
            SetDecorator(toReturn); 
 
            return toReturn; 
        } 
        #endregion 
    }  
  
Regards,  
  
Shyam G 



BC Blanca Calderon August 21, 2018 06:10 AM UTC

I think that you don't understand me. The only thing that I want is see the palette of color and I could choose the color that I want every moment. Sometimes I couldn't see the palette!!


NG Naganathan Ganesh Babu Syncfusion Team August 21, 2018 10:08 AM UTC

Hi Blanca, 
 
Please confirm us whether the PropertyEditor is not visible while adding node/changing the color of the node? If so, we are unable to reproduce the reported issue at our end and we have created a sample which is attached in below. 
 
Sample: 
 
 
Also, please check in your project, did you handling any code to change the PropertyEditor’s visibility option in Diagram’s SelectionChanged/PropertyChanged events. 
 
If we misunderstood your requirement, please share us more information about your requirement such as code example or modify sample to reproduce the reported issue at our end and also share us current version of Syncfusion control your using at your end, which will help us to analyze further and provide a better solution. 
 
Regards, 
 
Naganathan K G 



NG Naganathan Ganesh Babu Syncfusion Team August 21, 2018 10:45 AM UTC

Hi Blanca, 
 
Sorry for the inconvenience caused and please ignore our previous update. 
 
Please confirm whether you are using custom properties in PropertyGrid and change the Node’s color by using color palette in propertyGrid? If so, we suggest you to set the property type as “Color” instead of “string” in property convertor class. please refer to the below code example and sample. 
 
Code example: 
 
[C#] 
 
  public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) 
        { 
            Attribute[] attrs = new Attribute[] 
                                    { 
                                                new BrowsableAttribute(true) 
                                    }; 
 
            // This code returns only the specified properties. It can be used to filter out 
            // properties that you do not wish to expose to in property grid. 
            PropertyDescriptor[] props = new PropertyDescriptor[4]; 
            props[0] = TypeDescriptor.CreateProperty(typeof(CustomConnector), "Color", typeof(Color), attrs); 
            props[1] = TypeDescriptor.CreateProperty(typeof(CustomConnector), "LineWidth", typeof(float), attrs); 
            props[2] = TypeDescriptor.CreateProperty(typeof(CustomConnector), "Width", typeof(float), attrs); 
            props[3] = TypeDescriptor.CreateProperty(typeof(CustomConnector), "Height", typeof(float), attrs); 
 
            return new PropertyDescriptorCollection(props); 
        } 
 
Sample: 
 
Sample  
 
Please confirm whether  
 
Regards, 
 
Naganathan K G 


Loader.
Up arrow icon