Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic CustomBehavior sample code (Read 3205 times)
ooswald
YaBB Newbies
*
Offline



Posts: 16
Joined: Jun 15th, 2006
CustomBehavior sample code
Jul 24th, 2006 at 8:27am
Print Post  
Is there some source code for implementing a custom behaviour similar to BehaviorType.CreateArrow?

CreateArrow is very close to what we want, however it doesn't cover all our requirements. For example
- we don't want the selection handles to be shown when the mouse hovers over a box
- arrows should only be created when the user starts drawing at an anchor point (and not somewhere within the border region of the box)

We don't want to spend time to rebuild the CreateArrow behaviour - it would help us much if MindFusion could provide the community with some guidances in the form of source code.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: CustomBehavior sample code
Reply #1 - Jul 24th, 2006 at 9:52am
Print Post  
The easiest solution will be to inherit from the Flowchart.NET's CreateArrowBehavior class, but unfortunately it is "internal sealed" at this time. We are just releasing a new version of the control and cannot change that right now, but once we release it we will make that class public and post some sample code here, I promise  Grin
  
Back to top
 
IP Logged
 
ooswald
YaBB Newbies
*
Offline



Posts: 16
Joined: Jun 15th, 2006
Re: CustomBehavior sample code
Reply #2 - Jul 24th, 2006 at 11:43am
Print Post  
great.

at the same time you could look through all the internally sealed classes, properties, methods and events. check which ones really need to be sealed. make all others public for the next release.
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: CustomBehavior sample code
Reply #3 - Jul 24th, 2006 at 12:15pm
Print Post  
we'll do as you say  Grin
  
Back to top
 
IP Logged
 
ooswald
YaBB Newbies
*
Offline



Posts: 16
Joined: Jun 15th, 2006
Re: CustomBehavior sample code
Reply #4 - Jul 24th, 2006 at 12:25pm
Print Post  
that's what i expected  Wink
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3153
Joined: Oct 19th, 2005
Re: CustomBehavior sample code
Reply #5 - Aug 2nd, 2006 at 8:44am
Print Post  
That can be done like this

Code
Select All
class MyBehavior : MindFusion.FlowChartX.Behaviors.CreateArrowBehavior
{
 public MyBehavior(FlowChart fc) : base(fc)
 {
 }

 public override InteractionState StartDraw(PointF point)
 {
   InteractionState ist = base.StartDraw(point);

   if (ist.Action == Action.Create && ist.CurrentObject is Arrow)
   {
     Node node = fc.GetNodeAt(point, true, false);
     if (node != null)
     {
       if (node.AnchorPattern == null)
         return ist;

       foreach (AnchorPoint p in node.AnchorPattern.Points)
      {
       RectangleF r = node.BoundingRect;
       PointF appos = new PointF(r.X + r.Width * p.X / 100, r.Y + r.Height * p.Y / 100);

       if (p.AllowOutgoing && Math.Abs(point.X - appos.X) < 3 && Math.Abs(point.Y - appos.Y) < 3)
        return ist;
      }

      return null;
     }
   }

   return ist;
 }
}
 



Contact us at support@mindfusion.org to get the updated dll.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint