We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Custom Symbols in the palette

Dear support,
I'm using SL5 Diagram control of Essential Studio Version 10.3.0.43.

I need to add geometric symbol to the palette.
I tried to use the code provided as example (4.8.5.1 Adding a path as SymbolPaletteItem).
The code produce a new symbol in the palette, but when I drop it in the diagram it remain invisible.
(pls see the region "Adding a SymbolPaletteItem as in the example" code below)

Then I tired to add a rectangle as Item as shown in the region "Adding a rectangle", but in this case when I drop the symbol in the diagram It's visible, but the node resize operation do not camge its dimension.

can you help me?
Best regards
Domenico

below the code I used to customize the palette:
private void CustomizePalette()
        {
            // Adding Group in SymbolPalette
            SymbolPaletteGroup group = new SymbolPaletteGroup();
            group.HeaderName = "TestShapes";
            group.HeaderVisibility = Visibility.Visible;
            group.PanelVisibility = Visibility.Visible;

            diagramControl.SymbolPalette.SymbolGroups.Add(group);

            #region Adding a SymbolPaletteItem as in the example
            SymbolPaletteItem item = new SymbolPaletteItem();
            item.Width = 50;
            item.Height = 50;
            item.Name = "item";
            //Initialising a Path
            Path path = new Path();
            //Initialising a PathGeometry
            PathGeometry geo = new PathGeometry();
            PathFigure pathfig = new PathFigure();
            pathfig.StartPoint = new Point(0, 0);
            //Adding line segments to path figure
            LineSegment line = new LineSegment();
            line.Point = new Point(-3, -7);
            pathfig.Segments.Add(line);
            line = new LineSegment();
            line.Point = new Point(-3, -15);
            pathfig.Segments.Add(line);
            line = new LineSegment();
            line.Point = new Point(3, -15);
            pathfig.Segments.Add(line);
            line = new LineSegment();
            line.Point = new Point(3, -7);
            pathfig.Segments.Add(line);
            pathfig.IsClosed = true;
            geo.Figures.Add(pathfig);
            path.Data = geo;
            path.Height = 40;
            path.Width = 40;
            path.Fill = new SolidColorBrush(Colors.Red);
            path.Stretch = Stretch.Fill;
            path.Stroke = new SolidColorBrush(Colors.Blue);
            path.StrokeThickness = 1;
            path.Margin = new Thickness(3);
            //setting path as the content of SymbolPaletteItem
            item.Content = path;
            group.Items.Add(item);
            #endregion

            #region Adding a rectangle
            var symbolPaletteItem = new SymbolPaletteItem { Width = 50, Height = 50, Name = "FlowChartItemRectangle" };
                var rect = new System.Windows.Shapes.Rectangle
                {
                    Height = 40,
                    Width = 40,
                    Fill = new SolidColorBrush(Colors.LightGray),
                    Stroke = new SolidColorBrush(Colors.Blue),
                    StrokeThickness = 1,
                    Margin = new Thickness(2),
                    Stretch = Stretch.Fill
                };
                
                symbolPaletteItem.Content = rect;
                group.Items.Add(symbolPaletteItem);
            #endregion

        }

3 Replies

PA Parthiban A Syncfusion Team October 17, 2012 01:32 PM UTC

Hi Domenico,

We have analyzed your query with the provided coding. In that you have initialized the width and height of the Rectangle shape, while creating. So that you cannot resize the content of the node (Rectangle). We have created sample to meet your requirements, in which we have set HorizontalContentAlignmemnt nad VerticalContentAlignment as Stretch, while drag and drop the custom symbol palette item from the symbol palette. Now you can resize the content, while resize the node.

For more information, please refer the attached sample.

Please let us know if you require further assist on this.

Regards,

Parthiban A.

 



GeometricSymbol_7164af2d.zip


DM Domenico Mozzone October 18, 2012 07:02 AM UTC

Hi Parthiban,
thank you for your help. 
It solved the problem.

Best Regards
Domenico


SC Sudhakar C Syncfusion Team October 26, 2012 03:14 PM UTC

Hi Domenico,

 

We have analyzed your query with the provided coding, the responses are in below.

 

                                    Query

                                     Response

I tried to use the code provided as example (4.8.5.1 Adding a path as SymbolPaletteItem).

The code produce a new symbol in the palette, but when I drop it in the diagram it remain invisible.

We have created a simple sample based on your requirement. In that sample, we have added the new SymbolPalette Group and added the symbol palette item with the content of Path to that SymbolPalette Group. Now, you can drag & drop that symbolpalette Item to the diagram page. For more information please refer the following sample. 

Then I tried to add a rectangle as Item as shown in the region "Adding a rectangle", but in this case when I drop the symbol in the diagram It's visible, but the node resize operation do not camge its dimension.

In the provided coding, you have set the Width & Height to the Rectangle. So, if you drag & drop that rectangle, the width & height of that rectangle will be maintain.

 

For example, you have set the Width & Height of the rectangle such as 40 , 40. Then, if you drag & drop the rectangle to diagram, the Height & Width of that rectangle is maintained as 40, 40.

 

So please set the width & height to SymbolPalette only. Now, we hope it will be work fine.

 

Please let us know if you require further assistance on this.

 

Regards,

Sudhakar.C



PaletteItemWithPath_347a47e3.zip

Loader.
Live Chat Icon For mobile
Up arrow icon