Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram.HitTestAdjustmentHandles Event (Read 4630 times)
Kuzya
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Joined: Dec 19th, 2011
Diagram.HitTestAdjustmentHandles Event
Jan 11th, 2012 at 11:26am
Print Post  
Hello,

with the function HitTestAdjustmentHandles I lack one  function if an element is selected. If with left mouse key a click is made in internal area of the element, it must be indicated.
It must tramp exactly like with ShapeHandlesStyle = SquareHandles (8 quadrangles on the edge of the element and a quadrangle in the middle).
Could you inform me like me of this better can make?!

Many thanks in advance.
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.HitTestAdjustmentHandles Event
Reply #1 - Jan 11th, 2012 at 11:51am
Print Post  
Hi,

I'm not sure if I understand you correctly. If you need your custom hit-testing code to be based on some of the standard handle styles, you could do something like this in the HitTestAdjustmentHandles handler:

Code
Select All
e.Node.HandlesStyle = HandlesStyle.SquareHandles;
int handle = 8;
e.Node.HitTest(e.MousePosition, ref handle);
e.Node.HandlesStyle = HandlesStyle.Custom;

// additional custom testing
// ...

e.HitResult = handle; 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kuzya
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Joined: Dec 19th, 2011
Re: Diagram.HitTestAdjustmentHandles Event
Reply #2 - Jan 11th, 2012 at 12:56pm
Print Post  
Sorry for my English Smiley
If a click is made with the left mouse key in the internal area of the element, it must appear as it does when for ShapeHandlesStyle = SquareHandles   the left mouse key in the element is clicked.

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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.HitTestAdjustmentHandles Event
Reply #3 - Jan 11th, 2012 at 1:52pm
Print Post  
If dragging from any point within the node's interior should start moving the node, while resize is still enabled at the corners, you could handle it like this:

Code
Select All
private void diagram_HitTestAdjustmentHandles(object sender, HitTestEventArgs e)
{
    int handle = 8;

    DiagramNode node = (DiagramNode)e.Item;
    node.HandlesStyle = HandlesStyle.SquareHandles;
    node.HitTestHandle(e.MousePosition, ref handle);
    node.HandlesStyle = HandlesStyle.Custom;

    if (handle > 0 && handle <= 8)
    {
        // a resize or move handle was hit
        e.HitResult = handle;
        return;
    }

    if (node.ContainsPoint(e.MousePosition))
        e.HitResult = 8;
}

private void diagram_DrawAdjustmentHandles(object sender, MindFusion.Diagramming.DrawItemEventArgs e)
{
    DiagramNode node = (DiagramNode)e.Item;
    InternalUtils.DrawSelHandles(
        e.Graphics,
        diagram.SelectedItemHandlesStyle,
        diagram.DisabledHandlesStyle,
        node.Bounds, 0,
        node.EnabledHandles,
        false,
        HandlesStyle.SquareHandles2,
        diagram.AdjustmentHandlesSize);
} 



You could also set ModificationStart = AutoHandles to allow moving a node without having to select it first.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kuzya
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 45
Joined: Dec 19th, 2011
Re: Diagram.HitTestAdjustmentHandles Event
Reply #4 - Jan 11th, 2012 at 3:47pm
Print Post  
If we have ShapeHandlesStyle = SquareHandles and with left mouse key a click in internal area of the element is made, then element looks thus:

Attachment1
I have HitTestAdjustmentHandles, so ShapeHandlesStyle = Custom; if with left mouse key a click is made in internal area of the element, element looks thus:

Attachment2
And now my Asking: how do I make this that with me with the click with left mouse key in internal area of the element is just like with ShapeHandlesStyle = SquareHandles?

  

Dok2.docx (Attachment deleted)
Dok3.docx (Attachment deleted)
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram.HitTestAdjustmentHandles Event
Reply #5 - Jan 11th, 2012 at 5:19pm
Print Post  
If you set HandlesStyle to Custom, you must also handle the DrawAdjustmentHandles event. The code from my previous post contained a sample handler. You can replace SquareHandles2 with SquareHandles there to get exactly the same look as the standard SquareHandles style.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint