Matrix matrixTranslate = new Matrix();
matrixTranslate.Translate(OffsetX, OffsetY);
b. Scale - I also tried:
Matrix matrix = new Matrix();
matrix.ScaleAt(ScaleX, ScaleY, OffsetX, OffsetY);
c. Rotate
matrixRotateAt.RotateAt(RotationAngle, OffsetX, OffsetY);
Is it possible to use input parameterers to change the node appearance and location?
Thanks
Shape = new RectangleGeometry { Rect = new Rect(0, 0, Width, Height) },
Node.Shape.ToString();
"System.Windows.Media.RectangleGeometry"
instead of the SVG format that I thought I will have, like this one:
"M0,0L30,0L30,30L0,30z"
Geometry.Parse("System.Windows.Media.RectangleGeometry");
|
Matrix Mat = new Matrix(node.OffsetX, node.OffsetY, node.OffsetX + node.UnitWidth, node.OffsetY + node.UnitHeight, node.OffsetX, node.OffsetY);
Mat.Rotate(-45);
Mat.Translate(node.OffsetX, node.OffsetY);
MatrixTransform matrix = new MatrixTransform() { Matrix = Mat};
PathGeometry geometry = Geometry.Combine(Geometry.Parse(node.Shape.ToString()),Geometry.Parse(node.Shape.ToString()), GeometryCombineMode.Union, matrix);
node.Shape = geometry;
|
|
Query |
Response | |
|
Is there a way to get a string of points from the Shape so I can use the GeometryParse as in your sample? |
For Shape property please use our default Rectangle shape not by using Rectangle geometry. This will help you to get the path data from the shape property. Please find the code example below.
Code example:
| |
|
Is there a way to get a list of points from the Shape in (x,y) format, so I can add OffsetX and OffsetY and apply my transformations?
|
If we used PathData directly as like the above example we can get the points directly. Please find the code example below.
|
|
(sfdiagram.Info as IGraphInfo).NodeChangedEvent += MainWindow_NodeChangedEvent;
// Here sfdiagram is the instance of SfDiagram.
private void MainWindow_NodeChangedEvent(object sender, ChangeEventArgs<object, NodeChangedEventArgs> args)
{
if(args.NewValue.InteractionState == NodeChangedInteractionState.Dragging)
{
// Write your necessary calculation.
// args.Item value is always node. So, you can get its property values here itself.
}
else if(args.NewValue.InteractionState == NodeChangedInteractionState.Resizing)
{
// Write your necessary calculation.
// args.Item value is always node. So, you can get its property values here itself.
}
}
|
Shape = DisplayVm.BasicShapesDictionary["Delay"],
style.Setters.Add(new Setter(Shape.FillProperty, Brushes.Transparent));
style.Setters.Add(new Setter(Shape.StretchProperty, Stretch.Fill));
style.Setters.Add(new Setter(Shape.StrokeProperty, Brushes.Black));
style.Setters.Add(new Setter(Shape.StrokeThicknessProperty, 2d));
but the shape appears closed.
I've tried using "Delay" shape in the "SfDiagram binding with TreeView" sample instead of the rectangle by changing the XAML file and it looked as expected, but I have to work in code behind.
Could you help me with that?
Thanks,
Tanya.
Hi,
Thank you for your
answer,
I have another question
I've attached two images, one that I would like to achieve and the one that I managed to achieve so far.
I would like to have a node shape that is colored, while some of its lines are visible and some are transparent.
You may see the example in the images that are attached, where the background is black - two lines are invisible, that is what I would like to achieve.
I've set the node shape and style, but I don't know how to set different styles (transparent for some and colored for others) for different lines.
I understand it would be possible if I could draw two different shapes with two different styles for a node, but I don't know whether it is possible.
Could you help me?
Thank you.
Tanya.
|
<sfdiagram:NodeViewModel.ContentTemplate>
<DataTemplate>
<Path Stroke="Black" StrokeThickness="2" Fill="CornflowerBlue" Stretch="Fill">
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigureCollection>
<PathFigure IsClosed="True" StartPoint="0,0">
<PathFigure.Segments>
<PathSegmentCollection>
<LineSegment Point="0,100" IsStroked="False"/>
<LineSegment Point="100,100" IsStroked="True"/>
<LineSegment Point="100,0" IsStroked="True"/>
<LineSegment Point="0,0" IsStroked="False"/>
</PathSegmentCollection>
</PathFigure.Segments>
</PathFigure>
</PathFigureCollection>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
</DataTemplate>
</sfdiagram:NodeViewModel.ContentTemplate>
|
|
Query |
Response | |
|
The values of the points in my segments are variables. Before drawing the node I create a path in code behind using the variables as point values and then set the node shape to the path.Data:
Node.Shape = path.Data.
Could you help me understand how I can set ContentTemplate of the node to the Path I create in code behind?
The ContentTemplate should be set to the path only for the specific node each time it is redrawn, no need for it to be reusable.
|
We have created a simple sample for your requirement of how to create DataTemplate in code behind. Please find the code example and sample below.
Code Example:
Sample link: https://www.syncfusion.com/downloads/support/forum/164716/ze/ShapeRequirement_Modified505942747
| |
|
Once I set ContentTemplate does it mean that I shouldn't set a value to node Shape and Shapestyle? Should I set them to null?
|
In our SfDiagram control, there is no need to set any value for Shape and ShapeStyle properties when we used ContentTemplate to set the shape for NodeViewModel. |
|
Query |
Response |
|
Is it possible to create a 3D node in the diagram, perhaps by setting the node shape to a 3d model somehow (maybe using svg)?
|
SfDiagram supports 2D drawing only. So we doesn’t have the support to create a node in 3D. We have provided our online documentation link. Please visit the below link for more details.
|
|
Is it possible to use openGL to create a 2D image for the node? Maybe by saving an openGL rendering to a frame buffer and use this buffer as an image in the node annotation? Or some better way perhaps?
|
We can achieve your requirement by creating an template with OpenGL and use the template in ViewTemplate of the Annotation. We have prepared a simple sample for this. Please find the sample below.
Sample link: https://www.syncfusion.com/downloads/support/forum/164716/ze/OpenGL_Requirement690678577
|
Hi, thank you for your answers!
I have another question about using NodeChangedEvent when the node is resized.
What I need to do sometimes is change the node height when the user resizes it's width.
The problem is that when I change the node height as the user resizes it's width , NodeChangedEvent is called for the height change as well, and that is not what I need.
It would help me if I could:
Thank you!
Another question please.
I would like the selection area (the rectangle around the node with the 9 circles you can use to resize) to be in the location that I can specify. For example, twice as big as my node or in a totally different location.
Is that possible?
Thanks!
Tanya.