Page Index Toggle Pages: [1] 2  Send TopicPrint
Hot Topic (More than 10 Replies) Drag to change ShapeNode.Bounds (Read 9315 times)
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Drag to change ShapeNode.Bounds
Apr 10th, 2020 at 9:56am
Print Post  
Hello,

I need to implement this feature: after clicking the left mouse button on the edge or diagonal of the ShapeNode, hold down and drag the edge or diagonal of the ShapeNode to change the shapenode.bounds.

Any assistance would be appreciated.

Cheers,

JackPan
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Drag to change ShapeNode.Bounds
Reply #1 - Apr 10th, 2020 at 10:12am
Print Post  
Hello,

Try setting Diagram.Behavior to PanAndModify, that will let you modify existing nodes and keep the panning mode. You may want to change the default node.HandlesStyle to another value, depending on your requirements.

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Drag to change ShapeNode.Bounds
Reply #2 - Apr 10th, 2020 at 12:55pm
Print Post  
Yes, you're right. I set the Diagram.Behavior to PanAndModify, and I can drag the overlayNode to change its Bounds size now .
Currently overlaynode. HandleStyle is set to handlesstyle. DashFrame, imagelayNode does not set the property HandleStyle.
I want to change the value of the drag.Because now this value is too big, it's going to be a big drag.I want to make it smaller.

Any assistance would be appreciated.

Cheers,

Jack
  

4_10_2.png (Attachment deleted)
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Drag to change ShapeNode.Bounds
Reply #3 - Apr 10th, 2020 at 1:56pm
Print Post  
Hello,

To enable free resize, set Diagram.AlignToGrid property to false. If you wish to keep alignment, you can leave the property to true, and set the Diagram.GridSizeX and GridSizeY to values more suitable for your scenario.

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Drag to change ShapeNode.Bounds
Reply #4 - Apr 10th, 2020 at 2:05pm
Print Post  
Smiley Smiley Smiley Smiley Smiley Smiley Smiley

Yes, you are right.I did what you said.

Thanks to you, Lyubo.

Cheers,

Jack
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Drag to change ShapeNode.Bounds
Reply #5 - Apr 13th, 2020 at 12:51am
Print Post  
Hi All,

How to control overlayNode can only drag the right and the bottom, or can only drag the left and the bottom, how to use cs code to achieve. And this blue area how do I change the color?

Any assistance would be appreciated.

Cheers,

Jack
  

4_13.png (Attachment deleted)
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Drag to change ShapeNode.Bounds
Reply #6 - Apr 13th, 2020 at 4:56am
Print Post  
Hello,

JackPan wrote on Apr 13th, 2020 at 12:51am:
How to control overlayNode can only drag the right and the bottom, or can only drag the left and the bottom, how to use cs code to achieve.


Modify your NodeModifying handler to this:
Code
Select All
private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
	if (e.Node == overlayNode)
	{
		if (e.Node.Bounds.Right > imageNode.Bounds.Right ||
			e.Node.Bounds.Bottom > imageNode.Bounds.Bottom)
			e.Cancel = true;

		diagram.InvalidateForeground();
	}
} 



JackPan wrote on Apr 13th, 2020 at 12:51am:
And this blue area how do I change the color?


Set the Ruler.ProjectionColor property.

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Drag to change ShapeNode.Bounds
Reply #7 - Apr 13th, 2020 at 6:18am
Print Post  
Yes, you're right, Lyubo. Smiley

I've done everything you told me above, and I've understood.

But one of the things that's bothering me right now is that when I click on overlayNode, I don't need to drag it, I just need to drag its specified edge. If you want to drag, you want the overlayNode to be dragged along with the imageNode as a whole. What's a good way to do that?
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Drag to change ShapeNode.Bounds
Reply #8 - Apr 13th, 2020 at 6:19am
Print Post  
And I want to display the overlayNode's length and width in two textboxes in real time while dragging the specified edge of the overlayNode.I only know these two code: textBoxW. Text = overlayNode. Bounds. Width. ToString ();TextBoxH. Text = overlayNode. Bounds. Height. ToString (); But I don't know where to put it together.

Any assistance would be appreciated.

Cheers,

Jack
« Last Edit: Apr 13th, 2020 at 8:01am by JackPan »  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Drag to change ShapeNode.Bounds
Reply #9 - Apr 13th, 2020 at 12:10pm
Print Post  
Hello,

JackPan wrote on Apr 13th, 2020 at 6:18am:
But one of the things that's bothering me right now is that when I click on overlayNode, I don't need to drag it, I just need to drag its specified edge. If you want to drag, you want the overlayNode to be dragged along with the imageNode as a whole. What's a good way to do that?


You can toggle the move handle on the overlayNode off:
Code
Select All
overlayNode.EnabledHandles ^= AdjustmentHandles.Move; 



JackPan wrote on Apr 13th, 2020 at 6:19am:
And I want to display the overlayNode's length and width in two textboxes in real time while dragging the specified edge of the overlayNode.I only know these two code: textBoxW. Text = overlayNode. Bounds. Width. ToString ();TextBoxH. Text = overlayNode. Bounds. Height. ToString (); But I don't know where to put it together.


Update the textboxes' Text values from the NodeModifying handler that you already have.

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Drag to change ShapeNode.Bounds
Reply #10 - Apr 13th, 2020 at 12:29pm
Print Post  
Yes, you're right, Lyubo. Thanks a lot to you, Lyubo. Smiley Smiley Smiley Smiley Smiley

I've done it.

Now I put this code overlayNode EnabledHandles ^ = AdjustmentHandles. Move;Put it in the NodeModifying of the Diagram.Need to put the overlayNode. EnabledHandles ^ = AdjustmentHandles. Move; Put it in a better place? What event is the NodeModifying function of Diagram?

private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
overlayNode.EnabledHandles ^= AdjustmentHandles.Move;
if (e.Node == overlayNode)
{
if (e.Node.Bounds.Right > imageNode.Bounds.Right || e.Node.Bounds.Bottom > imageNode.Bounds.Bottom)
e.Cancel = true;
textBoxW.Text = overlayNode.Bounds.Width.ToString();
textBoxH.Text = overlayNode.Bounds.Height.ToString();
diagram.InvalidateForeground();
}
}

Cheers,

Jack
  
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Drag to change ShapeNode.Bounds
Reply #11 - Apr 13th, 2020 at 1:03pm
Print Post  
Set the enabled handles where you're creating your overlayNode.

JackPan wrote on Apr 13th, 2020 at 12:29pm:
What event is the NodeModifying function of Diagram?


For general questions like these, plaese resort to the documentation in the WpfDiagram package or online here: https://www.mindfusion.eu/onlinehelp/wpfdiagram/index.htm

Regards,
Lyubo
MindFusion
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Drag to change ShapeNode.Bounds
Reply #12 - Apr 13th, 2020 at 1:32pm
Print Post  
Thank you, Lyubo. Smiley Smiley Smiley Smiley Smiley

This online document is really a good thing!

Cheers,

Jack
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Drag to change ShapeNode.Bounds
Reply #13 - Apr 14th, 2020 at 3:05am
Print Post  
Hello,

I want to prohibit the dragging of the right and bottom edges of overlayNode, and I can only drag the left and top edges of overlayNode. Currently, the ovelayNode has been prohibited from dragging to the right and down, but this has also caused the left drag of overlayNode to be prohibited. How should I change it in the following code:

private void diagram_NodeModifying(object sender, NodeValidationEventArgs e)
{
if (e.Node == overlayNode)
{
if (e.Node.Bounds.Right > imageNode.Bounds.Right || e.Node.Bounds.Bottom > imageNode.Bounds.Bottom)
e.Cancel = true;
textBoxW.Text = overlayNode.Bounds.Width.ToString();
textBoxH.Text = overlayNode.Bounds.Height.ToString();
diagram.InvalidateForeground();
}
}

Any assistance would be appreciated.
  

4_14_1.jpg (Attachment deleted)
Back to top
 
IP Logged
 
Lyubo
God Member
*****
Offline


MindFusion team

Posts: 511
Joined: Jun 17th, 2010
Re: Drag to change ShapeNode.Bounds
Reply #14 - Apr 14th, 2020 at 5:16am
Print Post  
Hello,

This piece of code doesn't prohibit left resize and indeed, I can resize beyond the left and top edge without problem with it in my test (see attached image).

Check if you're manually changing overlayNode Bounds in another location, by setting the bottom and right edges to a bigger value than those of imageNode. If overlayNode.Bounds.Bottom or overlayNode.Bounds.Right are already bigger than imageNode's, it will prevent further modifications to overlayNode.

Regards,
Lyubo
MindFusion
  

resize.png (Attachment deleted)
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint