Page Index Toggle Pages: 1 [2]  Send TopicPrint
Very Hot Topic (More than 25 Replies) Operate on the image of the ShapeNode (Read 8340 times)
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: Operate on the image of the ShapeNode
Reply #15 - Aug 28th, 2020 at 6:11am
Print Post  
Quote:
How to determine which ShapeNode the mouse has selected in the diagram? Which attribute of ShapeNode is used?


Selected nodes are listed in diagram.Selection.Nodes.

Quote:
In your explanation of this question, I don’t know how to use a custom ShapeNode containing a triangles instead.


You can draw your rectangle using the Shape Designer tool (Samples\C#\ShapeDesign), save that to a shape library file and load it into your application. Assign the custom shape to ShapeNode.Shape property.

Quote:
And how does the AttachTo method view the custom node template?


These are two different ways to add your additional elements to main node. For AttachTo see Samples\C#\Entities. For custom templates see Samples\C#\Tutorial3.
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Operate on the image of the ShapeNode
Reply #16 - Aug 30th, 2020 at 2:19am
Print Post  
Thank you very much,Slavcho Smiley

I have the following questions:

1.After compilation, the output bar prompts that the Utilities object in the function DistToRect does not exist. Is it necessary to add additional libraries?

2.How to change the style of ShapeNode after being selected by the mouse and how to change its size?As shown in Figure 1.

3.I need to hold down Ctrl and click the left mouse button on the ShapeNode to drag to generate rectangle 3. So I implemented it like this:
if (Keyboard.Modifiers == ModifierKeys.Control)
{
diagram.Behavior = Behavior.DrawShapes;
}
put it in the NodeClicked event. But it doesn't work. The result is that you can directly click the mouse and drag on the ShapeNode without holding down Ctrl. Obviously this is not the result I want. What corrections need to be made? And I need to modify the generation of rectangle 3 from the existing ellipse to rectangle. As shown in Figure 2.

4.I want to double-click any item in the treeview in one tabControl to switch to another tabControl, as shown in Figure 3 and Figure 4. I want to implement it. The idea I thought of is to create another Window to save the second tabControl, and then perform the first tabControl and the second tabControl to switch between the two Windows, but what I can’t figure out is How can the second form be placed on the Grid position of the first tabControl? Is my thinking wrong? How should I achieve it?

5.I try to convert the Image type of ShapeNode to the Mat type of OpenCvShape, and the parameter type of the conversion function requires Bitmap type. Shouldn't the Image type of ShapeNode be the Bitmap type? It was created using new BitmapImage. Why did it report an error: Cannot convert from "System.Windows.Media.ImageSource" to "System.Drawing.Bitmap". What is the reason and how to correct it? As shown in Figure 5 and Figure 6.

6.I use this code to switch the focus of the mouse between ShapeNodes at will, but as shown in Figure 7, the mouse still cannot select the inner ShapeNode, but can only select the outer one. What changes need to be made?

Best regards.

« Last Edit: Aug 31st, 2020 at 8:21am by JackPan »  

8_30_0.png ( 7 KB | 101 Downloads )
8_30_0.png
8_30_1.png ( 8 KB | 99 Downloads )
8_30_1.png
8_31_2.png ( 34 KB | 96 Downloads )
8_31_2.png
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Operate on the image of the ShapeNode
Reply #17 - Aug 30th, 2020 at 2:21am
Print Post  
Add Figure 4, Figure 5, Figure 6:
« Last Edit: Aug 30th, 2020 at 3:46am by JackPan »  

8_31_3.png ( 19 KB | 104 Downloads )
8_31_3.png
8_31_5.png ( 49 KB | 94 Downloads )
8_31_5.png
8_31_4.png ( 29 KB | 100 Downloads )
8_31_4.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: Operate on the image of the ShapeNode
Reply #18 - Aug 31st, 2020 at 6:58am
Print Post  
Quote:
1.After compilation, the output bar prompts that the Utilities object in the function DistToRect does not exist. Is it necessary to add additional libraries?


Use the MindFusion namespace, or fully-qualify it as MindFusion.Utilities.DistToLineSegment(...)
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Operate on the image of the ShapeNode
Reply #19 - Aug 31st, 2020 at 7:15am
Print Post  
Thanks, Slavcho Smiley

Please answer me the remaining questions I wrote above, I really need it.

Any assistance would be appreciated.

Cheers,

Best regards.
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Operate on the image of the ShapeNode
Reply #20 - Aug 31st, 2020 at 8:22am
Print Post  
Add Figure 7:
  

8_31_6.png ( 235 KB | 101 Downloads )
8_31_6.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: Operate on the image of the ShapeNode
Reply #21 - Aug 31st, 2020 at 9:22am
Print Post  
Quote:
2.How to change the style of ShapeNode after being selected by the mouse and how to change its size?As shown in Figure 1.


you can customize adjustment handles through AdjustmentHandlesSize and ActiveItemHandlesStyle properties of Diagram class.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: Operate on the image of the ShapeNode
Reply #22 - Aug 31st, 2020 at 9:33am
Print Post  
Quote:
3.I need to hold down Ctrl and click the left mouse button on the ShapeNode to drag to generate rectangle 3. So I implemented it like this ... put it in the NodeClicked event.


Behavior value is checked when mouse is pressed down and moved a bit, while NodeClicked is raised when you release mouse without moving. Try changing it from PreviewMouseDown instead:

Code
Select All
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
	diagram.ModifierKeyActions.Control = ModifierKeyAction.None;
	if (Keyboard.Modifiers == ModifierKeys.Control)
		diagram.Behavior = Behavior.DrawShapes;
	else
		diagram.Behavior = Behavior.Modify;
} 

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


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: Operate on the image of the ShapeNode
Reply #23 - Aug 31st, 2020 at 9:42am
Print Post  
Quote:
5.I try to convert the Image type of ShapeNode to the Mat type of OpenCvShape, and the parameter type of the conversion function requires Bitmap type. Shouldn't the Image type of ShapeNode be the Bitmap type? It was created using new BitmapImage. Why did it report an error: Cannot convert from "System.Windows.Media.ImageSource" to "System.Drawing.Bitmap". What is the reason and how to correct it? As shown in Figure 5 and Figure 6.


This and 4 are not related to our product, and I have no idea what you are talking about in 4. For conversion from WPF images to OpenCV Mat, try this:

https://github.com/shimat/opencvsharp

https://www.csharpcodi.com/csharp-examples/OpenCvSharp.Extensions.BitmapSourceCo...
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: Operate on the image of the ShapeNode
Reply #24 - Aug 31st, 2020 at 9:48am
Print Post  
Quote:
6.I use this code to switch the focus of the mouse between ShapeNodes at will, but as shown in Figure 7, the mouse still cannot select the inner ShapeNode, but can only select the outer one. What changes need to be made?


You use which code? This selects nodes by border in my test:

Code
Select All
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
	diagram.ModifierKeyActions.Control = ModifierKeyAction.None;
	if (Keyboard.Modifiers == ModifierKeys.Control)
	{
		diagram.Behavior = Behavior.DrawShapes;
	}
	else
	{
		diagram.Behavior = Behavior.Modify;
	}
}

protected override void OnPreviewMouseMove(MouseEventArgs e)
{
	base.OnPreviewMouseMove(e);

	if (diagram.Interaction == null)
	{
		var point = e.GetPosition(diagram.DocumentPlane);
		var node = NearestRect(point);
		if (node != null)
		{
			node.ZTop(false);
			diagram.Selection.Change(node);
		}
	}
}
 



If you set their HandlesStyle to SquareHandles2, you will also be able to resize by dragging rectangle borders instead of just handles.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3171
Joined: Oct 19th, 2005
Re: Operate on the image of the ShapeNode
Reply #25 - Aug 31st, 2020 at 9:52am
Print Post  
Please post one question per forum thread.
  
Back to top
 
IP Logged
 
JackPan
Full Member
***
Offline


I Love MindFusion!

Posts: 134
Joined: Apr 9th, 2020
Re: Operate on the image of the ShapeNode
Reply #26 - Aug 31st, 2020 at 1:30pm
Print Post  
Thank you very much,Slavcho Smiley Smiley
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint