Hi,
D wrote on Mar 23
rd, 2020 at 3:08am:
I want to change the mouse wheel to the center point in the view during the zoom in and zoom out events of the diagram instead of the current coordinate position of the mouse as the base point.
How to achieve? Is there any sample code?
Change the mouse wheel handler to this:
private void OnDiagramMouseWheel(object sender, MouseWheelEventArgs e)
{
var zoomRect = diagram.Viewport;
if (e.Delta < 0)
zoomRect.Inflate(10, 10);
else
zoomRect.Inflate(-10, -10);
diagram.ZoomToRect(zoomRect, true);
}
D wrote on Mar 23
rd, 2020 at 4:07am:
After the size of the ShapeNode is changed by the value of the TextBox, the size of the image in the ShapeNode should not be changed accordingly, and it should be kept at the original size. How to achieve this? Is there any sample code?
You can either change the size of the original image and use the ImageAlign.Center option (or another alignment depending on your requirements), or use the ImageAlign.Fit option while adjusting the ImagePadding value to correct for the new node size. For example, if your image needs to be 20,20px and your node's size is 40,40px - you'll set an ImagePadding value of 10. If the node's size is increased to 50,50px, padding will be increased to 15, etc.
D wrote on Mar 23
rd, 2020 at 4:17am:
After double-clicking on any point in the ShapeNode, this point will coincide with the center point of the centerline, thereby moving the entire ShapeNode. How to achieve this? Is there any sample code?
Use the following code:
diagram.NodeDoubleClicked += (sender, args) =>
{
var node = args.Node;
var posX = args.MousePosition.X - node.GetCenter().X;
var posY = args.MousePosition.Y - node.GetCenter().Y;
var newPos = new Point(
diagram.Viewport.X + diagram.Viewport.Width / 2 - node.Bounds.Width / 2 - posX,
diagram.Viewport.Y + diagram.Viewport.Height / 2 - node.Bounds.Height / 2 - posY);
node.SetBounds(new Rect(newPos, node.Bounds.Size), true, true);
};
Regards,
Lyubo,
MindFusion