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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Custom Symbols in the palette

Thread ID:

Created:

Updated:

Platform:

Replies:

105438 Oct 12,2012 01:51 PM UTC Oct 26,2012 03:14 PM UTC Silverlight 3
loading
Tags: Diagram
Domenico Mozzone
Asked On October 12, 2012 01:51 PM UTC

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

        }

Parthiban A [Syncfusion]
Replied On 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

Domenico Mozzone
Replied On October 18, 2012 07:02 AM UTC

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

Best Regards
Domenico

Sudhakar C [Syncfusion]
Replied On 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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;