S.no |
Query |
Response |
1 |
I'm interested by the SFDiagram control for drawing basic "empty" shapes on an image.
Is there a simpler sample allowing ton drag and drop basic shapes?
|
Requirement: “Need to drag and Drop a symbol from stencil”,
We have analyzed and created a sample to achieve your requirement. We have provided a sample to represent this. Please refer to the sample link as below.
Sample link:127065__Stencil
Sample details:
In sample, we have adding NodeViewModel to SymbolCollection and this Collection will be the SymbolSource to the Stencil. Based on the SymbolSource, the Stencil will populate the Symbols. For more details about stencil, please refer the below online documentation link.
Note:
In sample, we have set “Fill” property of the Node ShapeStyle to transparent. if we won’t set Fill property, we were unable to select the Dropped Nodes from the Diagram. |
2 |
I don't know if I can use it: on the sample "Diagram Builder", we can add shapes and define their properties, but the "Fill" property can't be define on empty or transparent...
Is these feasable?
|
There is no way to set “Fill" property can be defining on empty. But we have to check for the transparent if it is needed. |
<syncfusion:NodeViewModel OffsetX="100" OffsetY="100" UnitHeight="100" UnitWidth="100" Shape="{StaticResource RightArrow}" ShapeStyle="{StaticResource shapeStyle}" Key="Arrow Shapes"> </syncfusion:NodeViewModel> |
S.no |
Query |
Response | |
1 |
But I meet a first problem with 3 basic shapes: Rectangle, Triangle and RightTriangle. I can't select them and drag&drop, whereas there is no problem with the other ones... |
Reported issue: “unable to select and Drag and Drop a Node from Stencil”.
We have tested these scenarios (selection and dragging) with the provided sample. But, we were unable to reproduce the reported issue. We have provided Video to represent this. Please refer to the Video from the following link.
Video Link:Stencil_Video
However, please ensure whether the Fill is set as Transparent in your application.
| |
2 |
In add, why is there a "global container" around the shapes that has been dropped on the diagram? I tried to play with "MainWindow_ItemAdded()" to remove it, but it didn't change anything. |
We assumed your requirement ("global container") is a selector or pagesettings.
1. if it is Selector, we have a support to customize the Selector. We have provided a sample to represent this. Please refer to the sample link as below.
2. if it is PageSettings, we have PageBorderBrush support for PageSettings to set is as Transparent.
Code Example:
| |
3 |
I also need to redefine 2 properties of the nodes thas has been dropped: the foreground color and the thickness. The other properties shouldn't be used. But is it possible to show these properties under the Symbol Collection, so that the user doesn't have to navigate to another page? |
We assumed your requirement is to set foreground color and thickness to the text (Symbol Text) or Diagraming Node.
Please give us more information like screenshot/Video to achieve your requirement at the earliest. | |
4 |
And finally is there a way to deactivate 2 items of the context menu? I don't need to use them and this can disrupt the enduser. |
We have a support to achieve your requirement.
We have provided an option to remove Quick Command (3 items(Rotator,Connector,Remove)) via Graphs Constraints. If you want to remove the 2 items from Quick Command, we need to customize. We have provided a sample to represent this. Please refer the below sample. | |
5 |
Finally I can use Rectangle, Triangle and RightTriangle: these shapes are just harder to select. |
Before run the sample, please ensure whether you have set the Fill as Transparent. | |
6 |
But I encounter problems for moving shapes on the diagram in tablet mode. With the mouse it is easier as we can select the edges of the shapes. But this is harder with the fingers or the pen in tablet mode. Does this occurs because the background is transparent? In the official samples, I don't meet this case...
|
In the official sample, we have used Fill as “#FFFFFF” and SymbolCollection as SymbolItems instead of using NodeViewModel. There is no problem for setting background as Transparent. Make sure before run the sample we need to set Fill as Transparent for the Node interaction. | |
7 |
I also tried to replace the rounded arrows of your sample with the arrows that we can found in the official sample:
|
We have added the arrows shapes in Below sample. Please refer to the above sample link. |
<DataTemplate x:Key="nodeImageTemplate"> <Border Background="White" MaxHeight="800" MaxWidth="1200"> <Image Source="ms-appx:///Assets/Image.jpeg" Stretch="UniformToFill" /> </Border> </DataTemplate> |
<!--Initializes Node--> <syncfusion:SfDiagram.Nodes> <syncfusion:NodeCollection> <syncfusion:NodeViewModel ContentTemplate="{StaticResource nodeImageTemplate}" Pivot="0,0" /> </syncfusion:NodeCollection> </syncfusion:SfDiagram.Nodes> |
DiagramCollection<NodeViewModel> nodes = (diagram as SfDiagram).Nodes as DiagramCollection<NodeViewModel>; if (nodes != null && nodes.Count > 0) { int cptNodes = 0; foreach (var node in nodes) { cptNodes++; if (cptNodes == 1) { node.Constraints = ~NodeConstraints.Rotatable & ~NodeConstraints.Menu & ~NodeConstraints.Resizable & ~NodeConstraints.Draggable & ~NodeConstraints.OutConnect & ~NodeConstraints.Connectable & ~NodeConstraints.Selectable; node.ZIndex = 0; } } } |
S.no |
Query |
Response |
1 |
- after having dragged a shape, I can't unselect it by clicking in the background image: the only way to "unseled" a shape is to add another one
- but then, I can't select/Edit a shape that has been previously added: the focus stays on the current shape
- in add, I need that the background image could adapt to several sizes: I currently use a static image, but this image must come from images that have been captured through the camera
|
In the sample, ZoomPan Constraints is enabled for Diagram so, we can’t able to interact with the Diagraming object. That is the cause of the issue. We have fixed and provided the modified sample as below. |
2 |
I don't see how to bind the shapes properties to the CombBox |
Could you please confirm your requirement is “Need to set different fill and Stroke value for the Node via ComboBox”? Please let us know the confirmation from your side to work on this requirement. |
3 |
Then I try to deactivate all the constraints for this node in the code-behind: |
Your requirement is need to deactivate the constraints for all the Nodes. In order to iterate and set the constraints to all the Nodes, we have directly deactivate the constraints for the Diagram. We have updated the sample with these changes. Please find the sample as below. |
4 |
Concerning my previous requests, there is only a problem that isn't solved: the move of shape with the finger.
There is no problem with the mouse, as we can see the "finger" icon:
But it's very difficult or impossible with the finger: I don't know if this come from the background image, the transparent background color or from the foreground size...
|
Please check the updated sample to solve your dragging the Node with Finger issue. |
In the sample, ZoomPan Constraints is enabled for Diagram so, we can’t able to interact with the Diagraming object. That is the cause of the issue. We have fixed and provided the modified sample as below. |
Could you please confirm your requirement is “Need to set different fill and Stroke value for the Node via ComboBox”? Please let us know the confirmation from your side to work on this requirement. |
Your requirement is need to deactivate the constraints for all the Nodes. In order to iterate and set the constraints to all the Nodes, we have directly deactivate the constraints for the Diagram. We have updated the sample with these changes. Please find the sample as below. |
S.no |
Query |
Response |
1 |
We can now select the previously dragged shapes, but isn't it possible to set the image as a "static" node, that must not be movable/selectable?
For the user, this must be like a "static background image" on which he will add some shapes. As we need to export the result as a JPEG file, we have used a node to add the background image to the diagram, I don't know if there is a better way...
|
Requirement: “Need to disable all the constraints to the Background Image (Added to the Node)”.
We have provided the Constraints property to Node to enable/disable the behavior/interactions over the Node. We have Modified the sample to represent this.
Sample link:127065__Stencil_Modified
Sample Details:
We have disabled all interactions on the Node which has the background Image.
|
2 |
=> yes it's that: the user must be able to change easily the forground color or the stroke value for the dragged shapes (that are in Node) through the 2 ComboBox that I have added in the view.
if it's more easy for you (and for us), our client accepts that the same color is setted to all the shapes through the ComboBox, instead of setting one to one.
in add, he would like that arrows shapes are "filled" (with the same color that the foreground color), but the other shapes must always be "empties" (or transparent) I don't know if this is easily feasable.
|
Requirement: “Need to set different fill and StrokeThickness value for the selected Node via ComboBox”.
We have support to customize the appearance of the Node by using Shape Style Property. In order to change the Style Properties (Fill and Stroke Thickness), we have created custom properties to achieve the reported requirement. Please refer the above sample.
Sample Details:
Whenever the Fill and StrokeThickness properties changes, we need to create a new Style and assign to ShapeStyle property of Node.
|
3 |
=> It's not really that: as I have mentioned in my previous reply, we would like only deactivate the constraints for the node that contains the background image. For the other nodes, that contain the shapes, the user must be able to resize them, change the color or the stroke value. |
Question 1 and 3 both are same. Please refer the Question no 1. |
//(diagram.SelectedItems as SelectorViewModel).SelectorConstraints &= ~SelectorConstraints.QuickCommands; |
private void colorList_SelectionChanged(object sender, SelectionChangedEventArgs e) { var color = (Colors)e.AddedItems[0]; if (diagram.Nodes != null) { foreach (NodeViewModel node in diagram.Nodes as DiagramCollection<NodeViewModel>) { if (node.IsSelected) { if (node.Key != null) { if (node.Key.ToString().ToLower().Contains("arrow")) { Fill = color.ColorBrush; Stroke = color.ColorBrush; node.ShapeStyle = GetCustomStyle(); } else { Stroke = color.ColorBrush; node.ShapeStyle = GetCustomStyle(); } } } } } //myGrid.Background = color.ColorBrush; } |
//(diagram.SelectedItems as SelectorViewModel).SelectorConstraints &= ~SelectorConstraints.QuickCommands; |
private void colorList_SelectionChanged(object sender, SelectionChangedEventArgs e) { var color = (Colors)e.AddedItems[0]; if (diagram.Nodes != null) { foreach (NodeViewModel node in diagram.Nodes as DiagramCollection<NodeViewModel>) { if (node.IsSelected) { if (node.Key != null) { if (node.Key.ToString().ToLower().Contains("arrow")) { Fill = color.ColorBrush; Stroke = color.ColorBrush; node.ShapeStyle = GetCustomStyle(); } else { Stroke = color.ColorBrush; node.ShapeStyle = GetCustomStyle(); } } } } } //myGrid.Background = color.ColorBrush; } |
<DataTemplate x:Key="nodeImageTemplate"> <Border Background="White" MaxHeight="800" MaxWidth="1200"> <Image Source="ms-appx:///Assets/Image.jpeg" Stretch="UniformToFill" /> </Border> </DataTemplate> |
<syncfusion:SfDiagram.Nodes> <syncfusion:NodeCollection> <syncfusion:NodeViewModel ContentTemplate="{StaticResource nodeImageTemplate}" Pivot="0,0" /> </syncfusion:NodeCollection> </syncfusion:SfDiagram.Nodes> |
S.no |
Query |
Response |
1 |
- is it possible to remove/to hide the "empty" area between "Shapes" title and the "Basic Shapes" group?
|
Requirement: Need to remove/hide the "empty" area between "Shapes" title and the "Basic Shapes" group.
Yes, we have a support to achieve your requirement by enabling ShowPreview Constraints to Stencil. We have added this requirement in the Sample. Please refer to the sample as below. |
2 |
could you give me the code of the "missing" arrow?
|
We have added 11 arrows to stencil in the sample. Please refer the sample as below. |
3 |
but then, the menu also allows to copy a shape or add a connector, and I don't need this:
=> Is there a way to authorize only the "Delete" but deactivate the connectors and copy options? |
Currently, we don’t have direct way to deactivate the Connector and Copy options from the QuickCommands. We have option to customize the Selector. We have provided code example to represent this. Please refer to the code example from the below document.
Document link: http://www.syncfusion.com/downloads/support/forum/127065/ze/SelectorCustomization-335895943
|
4 |
The basic shapes are always empties, and the color property only affect the stroke (foreground).
The arrows shapes are always filled, and color property affect both the stroke and the fill.
But sometimes, the basic shapes are also filled: this occurs when I have changed the color of a arrow, and that I change the color of the basic shape. |
Requirement: Need to apply stroke only for Basic shapes and stroke and fill apply for Arrow shapes.
We have modified the sample as per your requirement. Please refer to the modified sample as below.
|
5 |
But I don't found a way to specify this image dynamically. Is it easily feasable? In our project the background image will come from the camera. |
We have added the image path in code behind and bind in Xaml. Please refer the sample as below.
|
<DataTemplate x:Key="nodeImageTemplate"> <Border MaxWidth="1024"> <Viewbox Stretch="Uniform" StretchDirection="DownOnly"> <Image Source="{Binding ElementName=Root, Path=DataContext.PhotoBitmapImage}" HorizontalAlignment="Left" VerticalAlignment="Top" Stretch="None" /> </Viewbox> </Border> </DataTemplate> |
<ColumnDefinition Width="175" /> <ColumnDefinition Width="*" /> |
<syncfusion:SfDiagram x:Name="diagram" Background="Red"> |
<syncfusion:SfDiagram.Nodes> <syncfusion:NodeCollection> <syncfusion:NodeViewModel ContentTemplate="{StaticResource nodeImageTemplate}" Pivot="0,0" /> </syncfusion:NodeCollection> </syncfusion:SfDiagram.Nodes> |
<syncfusion:SfDiagram x:Name="diagram"> <syncfusion:SfDiagram.Background> <ImageBrush ImageSource="/Assets/BackgroundImage.jpg" Stretch="Uniform" AlignmentX="Left" AlignmentY="Top" /> </syncfusion:SfDiagram.Background> ... |
<syncfusion:SfDiagram.Nodes> <syncfusion:NodeCollection> </syncfusion:NodeCollection> </syncfusion:SfDiagram.Nodes> |
S.no |
Query |
Response |
1 |
Is it possible to get the "default" template code? So I could make a mix between the default values and the null values, to get the expected behavior.
|
We have provided Selector Template in the Document. Please refer the Document as below.
Document link: http://www.syncfusion.com/downloads/support/forum/127065/ze/Selector_template_code-47506655
|
2 |
This is the last point for which I encounter a problem, with the background image management,
|
We have set the image(BackgroundImage.jpg) as ContentTemplate of the Node. We were unable to see any empty spaces here. We have provided a video to represent this. Please refer to the Video link as Below.
|
IRandomAccessStream stream = new InMemoryRandomAccessStream(); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.PngEncoderId, stream); //1920 x 1080 = ratio 1.777 var resHeight = renderTargetBitmap.PixelWidth / 1.777; encoder.SetPixelData( BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)renderTargetBitmap.PixelWidth, //(uint)renderTargetBitmap.PixelHeight, (uint)resHeight, DisplayInformation.GetForCurrentView().LogicalDpi, DisplayInformation.GetForCurrentView().LogicalDpi, pixelBytes); |
S.no |
Query |
Response | |
1 |
Need to set image as Diagram Background |
Requirement: Need to set image as Diagram Background.
We have a support to achieve your requirement by using PageBackground property of the PageSettings to change the appearance of the Diagram Page. In the previous sample, we have set the image as Background property of the Diagram. Instead of that, please to set the image as PageBackground property of the PageSettings to the Diagram and also please to adjust the PageWidth and PageHeight as per your requirement. We have provided code example to represent this. Please refer to the code example as below.
Code Example:
| |
2 |
On wich one should I base myself to disable copying and relations in the Quick Access Menu, while retaining deletion, rotation and resizing? |
Requirement: Need to deactivate QuickCommand (Connector and Copy) from the Selector.
We have a support to achieve your requirement by customize the Selector. We have provided Sample and Screenshot to represent this. Please refer to the sample and screenshot as below.
Sample Link: http://www.syncfusion.com/downloads/support/forum/127065/ze/127065__Stencil_Modified_Selector1123478315
Screenshot:
|
<!--#Add the Below code into the Page.Resources--> <!--#Image Brush --> <ImageBrush x:Key="bgimage" ImageSource="/Assets/BackgroundImage.jpg" Stretch="Fill"/> <!--# PageSettings --> <syncfusion:PageSettings x:Key="diagrampage" PageWidth="1000" PageHeight="1000" PageBorderBrush="Red"PageBackground="{StaticResource bgimage}" /> <!--# Initializes Diagram and Bind the PageSettings properties--> <syncfusion:SfDiagram x:Name="diagram" PageSettings="{StaticResource diagrampage}"> |
<helpers:selectorDiagram x:Name="diagram"> <syncfusion:SfDiagram.Background> <ImageBrush ImageSource="/Assets/BackgroundImage.jpg" Stretch="Uniform" AlignmentX="Left" AlignmentY="Top" /> </syncfusion:SfDiagram.Background> |
protected async Task<IRandomAccessStream> GenerateImage(UIElement diagram) { // Render to an image at the current system scale and retrieve pixel contents var renderTargetBitmap = new RenderTargetBitmap(); DiagramCollection<NodeViewModel> nodes = (diagram as SfDiagram).Nodes as DiagramCollection<NodeViewModel>; if (nodes != null && nodes.Count > 0) { foreach (var node in nodes) { node.IsSelected = false; } } await renderTargetBitmap.RenderAsync(diagram); var pixelBuffer = await renderTargetBitmap.GetPixelsAsync(); var pixelBytes = new byte[pixelBuffer.Length]; using (var reader = DataReader.FromBuffer(pixelBuffer)) { reader.ReadBytes(pixelBytes); } IRandomAccessStream stream = new InMemoryRandomAccessStream(); var encoder = await BitmapEncoder.CreateAsync(BitmapEncoder.JpegEncoderId, stream); //1920 x 1080 = ratio de 1.777 var resHeight = renderTargetBitmap.PixelWidth / 1.777; encoder.SetPixelData( BitmapPixelFormat.Bgra8, BitmapAlphaMode.Straight, (uint)renderTargetBitmap.PixelWidth, //(uint)renderTargetBitmap.PixelHeight, (uint)resHeight, DisplayInformation.GetForCurrentView().LogicalDpi, DisplayInformation.GetForCurrentView().LogicalDpi, pixelBytes); await encoder.FlushAsync(); return stream; } |
"The buffer allocated is insufficient" |