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


I Love MindFusion!

Posts: 158
Joined: Mar 16th, 2020
Apply to images in the control
Mar 16th, 2020 at 9:47am
Print Post  
I want to open up a local image, which is what it looks like.Then scroll the mouse wheel to achieve the picture and ruler in accordance with the scale zoom in and out, how to achieve?And how to draw the yellow cross on the control? Smiley
  

QQzh__e__20200316174110.png (Attachment deleted)
QQzh__e__20200316174136.png ( 809 KB | 131 Downloads )
QQzh__e__20200316174136.png
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 #1 - Mar 16th, 2020 at 10:09am
Print Post  
D wrote on Mar 16th, 2020 at 9:47am:
I want to open up a local image, which is what it looks like.Then scroll the mouse wheel to achieve the picture and ruler in accordance with the scale zoom in and out, how to achieve?And how to draw the yellow cross on the control? Smiley

  

11_001.png ( 580 KB | 118 Downloads )
11_001.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3176
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #2 - Mar 16th, 2020 at 10:44am
Print Post  
You should be able to show local image by assigning it to diagram's BackgroundImage, and also set BackgroundImageAlign and Bounds properties to whatever scale you'd need. Alternatively use a locked ShapeNode to show the image via its Image property.

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 #3 - Mar 16th, 2020 at 10:51am
Print Post  
I have understood the diagram's BackgroundImage property, but not the Bounds property set to any scale required. Please give me a code example that I want to understand.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3176
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #4 - Mar 16th, 2020 at 10:53am
Print Post  
Maybe easiest way to implement the yellow cross is to draw it from DrawForeground event handler by calling DrawingContext.DrawLine method. Other options would be to add DiagramLink objects on top of the bitmap, or a ShapeNode  whose Shape is set to a cross geometry. Depending on whether you need that cross to scroll and zoom with the diagram, it might be possible to add some Line objects to the diagram's template as well.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3176
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #5 - Mar 16th, 2020 at 10:56am
Print Post  
Quote:
I have understood the diagram's BackgroundImage property, but not the Bounds property set to any scale required. Please give me a code example that I want to understand.


E.g. if you want to show ruler's range as 0,0,250,150 rectangle, set diagram.Bounds = new Rect(0,0,250,150). Also make sure ruler's unit and diagram's unit are the same.
  
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 #6 - Mar 16th, 2020 at 11:00am
Print Post  
Other options are to add the DiagramLink object to the top of the ShapeNode with the bitmap or Shape set to cross geometry.Do you have sample code
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3176
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #7 - Mar 16th, 2020 at 12:15pm
Print Post  
something like this -

Code
Select All
var r = diagram.Bounds;
var mx = (r.Left + r.Right) / 2;
var my = (r.Top + r.Bottom) / 2;
var hline = diagram.Factory.CreateDiagramLink(
	new Point(mx, r.Top), new Point(mx, r.Bottom));
var vline = diagram.Factory.CreateDiagramLink(
	new Point(r.Left, my), new Point(r.Right, my));
hline.HeadShape = vline.HeadShape = null;
hline.Locked = vline.Locked = true; 

  
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 #8 - Mar 16th, 2020 at 1:35pm
Print Post  
I put this code in the DrawForeground event, but the program appears to be suspended animation, and there is no cross drawn. How to solve this problem? Smiley
  

QQzh__e__20200316212937.png ( 238 KB | 118 Downloads )
QQzh__e__20200316212937.png
QQzh__e__20200316213147.png ( 156 KB | 122 Downloads )
QQzh__e__20200316213147.png
QQzh__e__20200316213240.png ( 17 KB | 121 Downloads )
QQzh__e__20200316213240.png
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 #9 - Mar 16th, 2020 at 2:03pm
Print Post  
I want to control the image to appear on the specified coordinates, how to achieve
  

QQzh__e__20200316220126.png ( 1301 KB | 118 Downloads )
QQzh__e__20200316220126.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3176
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #10 - Mar 16th, 2020 at 4:16pm
Print Post  
You should run this code just once after loading your bitmap, e.g. in window_loaded handler. If handling DrawDoreground, call e.Graphics.DrawLine instead, with similar coordinates as ones from the DiagramLink code above.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3176
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #11 - Mar 16th, 2020 at 4:18pm
Print Post  
Quote:
I want to control the image to appear on the specified coordinates, how to achieve


Create a ShapeNode and set its Bounds to those coordinates, assign the bitmap to its Image property, and set node.Locked to prevent users from selecting it.
  
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 #12 - Mar 17th, 2020 at 2:00am
Print Post  
How to keep the shape unchanged in the middle of the diagram?How do I make the image in my shape drag around and fix the image in the specified coordinates of the shape?  Smiley
  

QQzh__e__20200317095321.png (Attachment deleted)
QQzh__e__20200317094138.png ( 550 KB | 126 Downloads )
QQzh__e__20200317094138.png
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 #13 - Mar 17th, 2020 at 2:20am
Print Post  
Smileyadded:
  

QQzh__e__20200317101713.png ( 388 KB | 128 Downloads )
QQzh__e__20200317101713.png
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3176
Joined: Oct 19th, 2005
Re: Apply to images in the control
Reply #14 - Mar 17th, 2020 at 6:16am
Print Post  
Quote:
How to keep the shape unchanged in the middle of the diagram?


If by unchanged you mean user should not be able to modify it, set the node's Locked property. If you mean the image should stay centered inside current viewport regardless of scroll position, you'd need to update the node's position from scroll changed event handler.

Quote:
How do I make the image in my shape drag around and fix the image in the specified coordinates of the shape?


You could 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.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: [1] 2 
Send TopicPrint