Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Questions about ruler and Node Center handle, etc. (Read 3260 times)
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Questions about ruler and Node Center handle, etc.
Apr 30th, 2013 at 3:20pm
Print Post  
Hi Stoyan,

I need you help again -
1. Is there any way to add a tooltip to diagram ruler?
2. For center handle of a node - I'm using EasyMove for HandlesStype.
  1) Is there any way to make the center handle also able to move the node?
  2) Any way to make the center handle more observable? Like change to a blue color other than white or change size/shape
  3) Any way to make a Locked node display a small lock icon at the corner and make a solid border around it like HatchFrame(but hatchframe is too ugly) Tongue

Thank you!

Kyle
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Questions about ruler and Node Center handle, etc.
Reply #1 - May 1st, 2013 at 7:49am
Print Post  
Hi,

1. You could show a ToolTip control in response to ruler's mouse hover events:

Code
Select All
private void Form1_Load(object sender, System.EventArgs e)
{
	var hScale = ruler.Controls[1].Controls[0];
	var vScale = ruler.Controls[2].Controls[0].Controls[0];
	hScale.MouseHover += OnRulerMouseHover;
	vScale.MouseHover += OnRulerMouseHover;
}

ToolTip rulerTooltip = new ToolTip();

void OnRulerMouseHover(object sender, EventArgs e)
{
	var tooltipPos = ruler.PointToClient(MousePosition);
	tooltipPos.X += 16;

	var diagPos = diagramView.ClientToDoc(
		diagramView.PointToClient(MousePosition));
	rulerTooltip.Show("pos: " + diagPos, ruler, tooltipPos, 2000);
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Questions about ruler and Node Center handle, etc.
Reply #2 - May 1st, 2013 at 8:07am
Print Post  
2. You could set HandlesStyle to Custom and handle Draw/HitTest events:

Code
Select All
void OnDrawAdjustmentHandles(object sender, MindFusion.Diagramming.DrawItemEventArgs e)
{
	var node = (DiagramNode)e.Item;
	var style = node == diagram.ActiveItem ?
		diagram.ActiveItemHandlesStyle :
		diagram.SelectedItemHandlesStyle;

	InternalUtils.DrawSelHandles(
		e.Graphics,
		style,
		diagram.DisabledHandlesStyle,
		node.Bounds,
		node.RotationAngle,
		node.EnabledHandles,
		true,
		HandlesStyle.SquareHandles,
		diagram.AdjustmentHandlesSize);

	var c = node.GetCenter();
	var r = new RectangleF(c.X, c.Y, 0, 0);
	r.Inflate(2.5f, 2.5f);
	e.Graphics.FillEllipse(Brushes.Blue, r);

	var p = (System.Drawing.Pen)Pens.Black.Clone();
	p.Width = 0;
	e.Graphics.DrawEllipse(p, r);
	p.Dispose();
}

void OnHitTestAdjustmentHandles(object sender, HitTestEventArgs e)
{
	if (e.Item.ContainsPoint(e.MousePosition))
		e.HitResult = 8;
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Questions about ruler and Node Center handle, etc.
Reply #3 - May 1st, 2013 at 8:14am
Print Post  
3. Set node.CustomDraw = Additional2 and handle DrawNode event:

Code
Select All
private void diagram_DrawNode(object sender, DrawNodeEventArgs e)
{
	if (e.Node.Locked)
	{
		// draw icon
		e.Graphics.DrawImage(lockImage, 1, 1);

		// draw border
		e.Graphics.DrawRectangle(Pens.Black, e.Bounds);
	}
} 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Re: Questions about ruler and Node Center handle, etc.
Reply #4 - May 3rd, 2013 at 7:26pm
Print Post  
Hi Stoyan,

First thank you for so detailed code samples. They work well for all my questions except a little bug for Moving node.

When a node is small(like 10x8 pixels) and all the handles will stacked together. When this happens, I cannot move it any more. Whenever I drag it one or two pixels away, the mouse cursor will change from "move" to "cancel". And when mouse is released the node back to original place.

Can you look into this? Thanks.


Stoyo wrote on May 1st, 2013 at 8:07am:
Code
Select All
void OnHitTestAdjustmentHandles(object sender, HitTestEventArgs e)
{
	if (e.Item.ContainsPoint(e.MousePosition))
		e.HitResult = 8;
} 



I hope that helps,
Stoyan

  

1_002.png ( 29 KB | 100 Downloads )
1_002.png
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Questions about ruler and Node Center handle, etc.
Reply #5 - May 6th, 2013 at 6:08am
Print Post  
Hi,

Set Diagram.MinimumNodeSize to a size smaller than any nodes you create programmatically.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kyle Chen
Full Member
***
Offline


I Love MindFusion!

Posts: 104
Joined: Nov 29th, 2012
Re: Questions about ruler and Node Center handle, etc.
Reply #6 - May 6th, 2013 at 3:49pm
Print Post  
Thank you Stoyan. That does help!! Cool
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint