Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Creating a Line instead of using a arrow (Read 3735 times)
James
Guest


Creating a Line instead of using a arrow
Jul 5th, 2006 at 9:37am
Print Post  
Hi ,

Is there a way to draw a line instead of using the arrow option.
This option is needed to draw a plain line between 2 points.

Regards,
James
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Creating a Line instead of using a arrow
Reply #1 - Jul 5th, 2006 at 10:01am
Print Post  
Hi,

Do you need to draw a free-form shape, e.g. as in MSPaint ? Or you just need a straight line segment that does not connect any nodes ?

You could do the former by handling the ArrowCreating and ArrowCreated events and adding a new point to an Arrow object for each mouse movement. You can do the latter by setting AllowUnconnectedArrows = true and hiding the ArrowHead in the InitializeArrow event.

Let me know if you need sample code for that.

Regards,
Stoyan
  
Back to top
 
IP Logged
 
James
Guest


Re: Creating a Line instead of using a arrow
Reply #2 - Jul 8th, 2006 at 4:26am
Print Post  
Hi Stoyan,

Kind of you to provide sample code, will be grateful to yoo to have a look on to the same for mouse events.

Regards,
James
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Creating a Line instead of using a arrow
Reply #3 - Jul 10th, 2006 at 6:05am
Print Post  
Hi James,

This code will draw a free-form shape when the boolean flag is set to true.

Code
Select All
bool drawLineMode;
Arrow line;

private void fc_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
  if (drawLineMode)
  {
    // disable the standard FlowChart.NET mouse handling
    fc.Behavior = BehaviorType.DoNothing;

    // start drawing the line
    PointF point = fc.ClientToDoc(new Point(e.X, e.Y));
    line = fc.CreateArrow(point, point);
    line.Style = ArrowStyle.Polyline;
    line.ArrowHead = ArrowHead.None;
    line.Selected = false;
    fc.Capture = true;
  }
}

private void fc_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
  if (line != null)
  {
    PointF point = fc.ClientToDoc(new Point(e.X, e.Y));

    // setting the number of segments will put all points on a straight line
    // so we remember their old positions
    PointCollection points = line.ControlPoints.Clone();

    // add the new point
    points.Add(point);
    line.SegmentCount = (short)(points.Count - 1);
    line.ControlPoints.Clear();
    line.ControlPoints.AddRange(points);
    }
}

private void fc_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
  if (line != null)
  {
    // stop drawing the line
    line = null;
    fc.Capture = false;
    fc.Behavior = BehaviorType.Modify;
  }
}
 



Regards,
Stoyan
  
Back to top
 
IP Logged
 
James
Guest


Re: Creating a Line instead of using a arrow
Reply #4 - Jul 11th, 2006 at 7:32am
Print Post  
Dear Stoyo,

Instead of selecting and moving the object at center, I want to move the object by selecting at any point in the object.

Is there any way?

Thanks in advance.


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


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Creating a Line instead of using a arrow
Reply #5 - Jul 11th, 2006 at 7:35am
Print Post  
Dear James,

Set the box HandlesStyle to EasyMove or MoveOnly.

Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint