Page Index Toggle Pages: 1 [2]  Send TopicPrint
Very Hot Topic (More than 25 Replies) Apply to images in the control (Read 11563 times)
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Apply to images in the control
Reply #15 - Mar 17th, 2020 at 6:52am
Print Post  
I mean to put the shape in the middle of the diagram, not the picture in the middle of the diagram, how to achieve it? Smiley
  

QQzh__e__20200317145024.png (Attachment deleted)
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Apply to images in the control
Reply #16 - Mar 17th, 2020 at 6:57am
Print Post  
I don't quite understand that create an additional node with allowed coordinates (either ContainerNode or a ShapeNode that will be set as a group master), attach the image node to the former / add is as a container child, and then set imageNode.NodeConstraints.KeepInsideParent - that will let users drag the image node only within its container's boundaries.Do you have sample code? Smiley
  

QQzh__e__20200317144326.png (Attachment deleted)
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3444
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #17 - Mar 17th, 2020 at 8:20am
Print Post  
Quote:
I mean to put the shape in the middle of the diagram, not the picture in the middle of the diagram, how to achieve it?


With some 2nd grade math Wink

Code
Select All
imageNode.Bounds = CenterRect(
	imageNode.Bounds, diagram.Bounds);


Rect CenterRect(Rect inner, Rect outer)
{
	var innerCenter = new Point(
		(inner.Left + inner.Right) / 2,
		(inner.Top + inner.Bottom) / 2);
	var outerCenter = new Point(
		(outer.Left + outer.Right) / 2,
		(outer.Top + outer.Bottom) / 2);

	var delta = outerCenter - innerCenter;
	inner.Offset(delta);
	return inner;
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3444
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #18 - Mar 17th, 2020 at 8:27am
Print Post  
Quote:
I don't quite understand that create an additional node with allowed coordinates (either ContainerNode or a ShapeNode that will be set as a group master), attach the image node to the former / add is as a container child, and then set imageNode.NodeConstraints.KeepInsideParent - that will let users drag the image node only within its container's boundaries.Do you have sample code?


try this -
Code
Select All
var imageNode = diagram.Factory.CreateShapeNode(0, 0, 300, 300);
imageNode.Brush = Brushes.Red;
imageNode.Bounds = CenterRect(
	imageNode.Bounds, diagram.Bounds);

var allowedRangeNode = diagram.Factory.CreateShapeNode(0, 0, 900, 900);
allowedRangeNode.ZIndex = 0;
allowedRangeNode.Bounds = CenterRect(
	allowedRangeNode.Bounds, diagram.Bounds);
allowedRangeNode.Locked = allowedRangeNode.Transparent = true;

imageNode.AttachTo(allowedRangeNode, AttachToNode.TopLeft);
imageNode.Constraints.KeepInsideParent = true; 



If you are looking for a way to keep node inside diagram's boundaries, you could set Constraints.KeepInsideDiagram instead, along with disabling diagram.AutoResize.
  
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Apply to images in the control
Reply #19 - Mar 17th, 2020 at 9:47am
Print Post  
How to change the diagram with the size of the window, and how to lengthen the cross in the diagram to the length and width of the entire diagram? Smiley
  

QQzh__e__20200317173904.png (Attachment deleted)
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Apply to images in the control
Reply #20 - Mar 17th, 2020 at 9:54am
Print Post  
How do I get the size of the imageNode to match the size of the local image that I'm exporting? Smiley
  

QQzh__e__20200317174902.png (Attachment deleted)
QQzh__e__20200317175000.png (Attachment deleted)
QQzh__e__20200317175127.png (Attachment deleted)
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Apply to images in the control
Reply #21 - Mar 17th, 2020 at 10:07am
Print Post  
Added:How do I get the size of the imageNode to match the size of the local image that I'm exporting? Smiley
  

QQzh__e__20200317174902.png (Attachment deleted)
QQzh__e__20200317175000.png (Attachment deleted)
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Apply to images in the control
Reply #22 - Mar 17th, 2020 at 1:06pm
Print Post  
What does the code in the red box do? What does the code in the red box do?We didn't find the ShapeNode allowedRangeNode after the program runs. Smiley
  

QQzh__e__20200317205730.png (Attachment deleted)
QQzh__e__20200317175000_001.png (Attachment deleted)
QQzh__e__20200317205903.png (Attachment deleted)
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Apply to images in the control
Reply #23 - Mar 17th, 2020 at 1:08pm
Print Post  
Added:What does the code in the red box do?We didn't find the ShapeNode allowedRangeNode after the program runs. Smiley
  

QQzh__e__20200317205730.png (Attachment deleted)
QQzh__e__20200317205831.png (Attachment deleted)
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3444
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #24 - Mar 17th, 2020 at 4:43pm
Print Post  
That's the node whose coordinates fence your image node, preventing users to drag the image outside. Remove the allowedRangeNode.Transparent = true assignment and you will see it.

Quote:
How do I get the size of the imageNode to match the size of the local image that I'm exporting?


You can get the size from BitmapSource' Width and Height properties.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
D
Full Member
***
Offline


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Re: Apply to images in the control
Reply #25 - Mar 19th, 2020 at 1:18am
Print Post  
Thanks Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint