Page Index Toggle Pages: 1 [2]  Send TopicPrint
Very Hot Topic (More than 25 Replies) Custom handles issue (Read 12222 times)
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom handles issue
Reply #15 - Jul 16th, 2014 at 10:55am
Print Post  
Quote:
A second trouble i found, is after resize node, if i try move the node, the node jump few pixels. ; (


Ok, you'll need to add these offsets only when resizing, e.g.:

Code
Select All
class MyBehavior : LinkShapesBehavior
{
	public MyBehavior(Diagram diagram) : base(diagram) { }

	protected override InteractionState StartDrawCommon(Point point, MindFusion.Diagramming.Wpf.MouseButton button)
	{
		var state = base.StartDrawCommon(point, button);
		Resizing = state != null &&
			state.Action == MindFusion.Diagramming.Wpf.Action.Modify &&
			state.AdjustmentHandle < 8;
		return state;
	}

	protected override void OnMouseMove(Point mousePosition)
	{
		if (Resizing)
		{
			mousePosition.X += MouseDX;
			mousePosition.Y += MouseDY;
		}
		base.OnMouseMove(mousePosition);
	}
	protected override void OnMouseUp(Point mousePosition, MindFusion.Diagramming.Wpf.MouseButton mouseButton)
	{
		if (Resizing)
		{
			mousePosition.X += MouseDX;
			mousePosition.Y += MouseDY;
		}
		base.OnMouseUp(mousePosition, mouseButton);

		MouseDX = MouseDY = 0;
		Resizing = false;
	}

	static public double MouseDX = 0;
	static public double MouseDY = 0;
	static public bool Resizing = false;
} 

  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Custom handles issue
Reply #16 - Jul 17th, 2014 at 4:19am
Print Post  
Oh Stoyo, some day I have to sent a great bottle of red wine to you!  Wink

Thanks for your help, this fixed the problema and also fix another issue I see. thanks!
« Last Edit: Jul 17th, 2014 at 9:02am by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom handles issue
Reply #17 - Jul 17th, 2014 at 10:12am
Print Post  
Cool I'm looking forward to it.
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Custom handles issue
Reply #18 - Jul 17th, 2014 at 10:37am
Print Post  
Sorry another question


I using

ModifyBehavior what provide nice mouse cursor when pass over handles etc

In some section of software I call to Mouse.OverrideCursor = Cursors.Cross;

The problem is after call Mouse.OverrideCursor = Cursors.Cross; I can call again to mouse cursors, of ModifyBehavior provide.

Well..dont worry, i not plain continue sending daily or ourly questions.
After solve this, I have only one more questions (for some long time lol), but i sent trough private message later today.

Thanks so much for your help. Really
« Last Edit: Jul 17th, 2014 at 11:52am by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom handles issue
Reply #19 - Jul 17th, 2014 at 12:26pm
Print Post  
If you are asking how to revert back to default cursors shown by ModifyBehavior, set Mouse.OverrideCursor = null.
« Last Edit: Jul 17th, 2014 at 1:35pm by Stoyo »  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Custom handles issue
Reply #20 - Jul 17th, 2014 at 8:16pm
Print Post  
Thanks!
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Custom handles issue
Reply #21 - Jul 18th, 2014 at 7:40am
Print Post  
A new question, i feel a Little of shame for this question. I cant find the way to make work.
Check under base.OnMouseMove(mousePosition);


Code
Select All
class MyBehavior : LinkShapesBehavior
{
	public MyBehavior(Diagram diagram) : base(diagram) { }

	protected override InteractionState StartDrawCommon(Point point, MindFusion.Diagramming.Wpf.MouseButton button)
	{
		var state = base.StartDrawCommon(point, button);
		Resizing = state != null &&
			state.Action == MindFusion.Diagramming.Wpf.Action.Modify &&
			state.AdjustmentHandle < 8;
		return state;
	}

	protected override void OnMouseMove(Point mousePosition)
	{
		if (Resizing)
		{
			mousePosition.X += MouseDX;
			mousePosition.Y += MouseDY;
		}
		base.OnMouseMove(mousePosition);

         //this is the correct way of get size?
            var node = form.ActiveItem;

            // how update sizebox.text ? is non static
            siseobject.Text =   node.ActualWidth.ToString() + "x" +  node.ActualHeight.ToString();



	}
	protected override void OnMouseUp(Point mousePosition, MindFusion.Diagramming.Wpf.MouseButton mouseButton)
	{
		if (Resizing)
		{
			mousePosition.X += MouseDX;
			mousePosition.Y += MouseDY;
		}
		base.OnMouseUp(mousePosition, mouseButton);

		MouseDX = MouseDY = 0;
		Resizing = false;
	}

	static public double MouseDX = 0;
	static public double MouseDY = 0;
	static public bool Resizing = false;
}

 

« Last Edit: Jul 18th, 2014 at 8:59am by PDM. »  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom handles issue
Reply #22 - Jul 18th, 2014 at 11:40am
Print Post  
Add an OnSizeChange method to your window class and show the new size from it, using the Bounds value instead of ActualWidth/Height. The latter are updated by the asynchronous WPF layout pass and might not reflect the final size yet.

Code
Select All
internal void OnSizeChange(DiagramNode node)
{
	var size = node.Bounds.Size;
	sizenodeobj.Text = Convert.ToInt16(size.Width) + "x" + Convert.ToInt16(size.Height);
} 



Pass a window reference to MyBehavior and call OnSizeChange through it:

Code
Select All
class MyBehavior : LinkShapesBehavior
{
	Window1 window;

	public MyBehavior(Diagram diagram, Window1 window) : base(diagram)
	{
		this.window = window;
	}

	protected override void OnMouseMove(Point mousePosition)
	{
		if (Resizing)
		{
			mousePosition.X += MouseDX;
			mousePosition.Y += MouseDY;
		}
		base.OnMouseMove(mousePosition);

		//this is the correct way of get size?
		var node = Diagram.ActiveItem as DiagramNode;
		if (node != null)
			window.OnSizeChange(node);
	}
... 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Custom handles issue
Reply #23 - Jul 18th, 2014 at 3:48pm
Print Post  
Me again
How call custom behaviour after this change?

  form.CustomBehavior = new MyBehavior(form);

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom handles issue
Reply #24 - Jul 18th, 2014 at 5:26pm
Print Post  
What do you mean by "how call"?
  
Back to top
 
IP Logged
 
PDM.
Senior Member
****
Offline


I love YaBB 1G - SP1!

Posts: 256
Joined: Dec 2nd, 2010
Re: Custom handles issue
Reply #25 - Jul 18th, 2014 at 11:31pm
Print Post  
Well not how call how stictyh from behaviour

By example if  do

form.Behavior = Behavior.DoNothing;


How then back to my custom behavior

form.CustomBehavior = new MyBehavior(form);
Error      3      'window6.Window6.MyBehavior' does not contain a constructor that takes 1 arguments      


public  class MyBehavior : ModifyBehavior
   {

   
    Window6 window;

    public MyBehavior(Diagram diagram, Window6 window): base(diagram)
     {
         this.window = window;
     }

     protected override InteractionState StartDrawCommon(Point point, MindFusion.Diagramming.Wpf.MouseButton button)
     {
           var state = base.StartDrawCommon(point, button);
           Resizing = state != null &&
                 state.Action == MindFusion.Diagramming.Wpf.Action.Modify &&
                 state.AdjustmentHandle < 8;
           return state;
     }

     protected override void OnMouseMove(Point mousePosition)
     {
           if (Resizing)
           {
                 mousePosition.X += MouseDX;
                 mousePosition.Y += MouseDY;
           }
           base.OnMouseMove(mousePosition);

        var node = Diagram.ActiveItem as DiagramNode;
        if (node != null)
            window.OnSizeChange(node);


    

     }

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Custom handles issue
Reply #26 - Jul 19th, 2014 at 6:16am
Print Post  
Now the constructor takes a second parameter specifying the window. If you are creating it from within a Window6 method, add a this argument:

Code
Select All
form.CustomBehavior = new MyBehavior(form, this); 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1 [2] 
Send TopicPrint