Esempio n. 1
0
    private void flowChart1_ArrowModified(object sender, ArrowMouseArgs e)
    {
      if (e.Arrow.Tag is Line)
      {
        Line line = e.Arrow.Tag as Line;

        line.pointF1 = GridUnfix(e.Arrow.ControlPoints[0]);
        line.pointF2 = GridUnfix(e.Arrow.ControlPoints[1]);
      }
      else if (e.Arrow.Tag is Bezier)
      {
        Bezier bezier = e.Arrow.Tag as Bezier;
        bezier.pointF1 = GridUnfix(e.Arrow.ControlPoints[0]);
        bezier.pointF2 = GridUnfix(e.Arrow.ControlPoints[1]);
        bezier.pointF3 = GridUnfix(e.Arrow.ControlPoints[2]);
        bezier.pointF4 = GridUnfix(e.Arrow.ControlPoints[3]);
      }

      SetStencil(modelStencil);
    }
Esempio n. 2
0
		internal void fireObjModified(ChartObject obj, PointF pt, int mnpHandle)
		{
			switch (obj.getType())
			{
				case ItemType.Box:
					if (BoxModified != null)
					{
						Box box = (Box)obj;
						BoxMouseArgs args = new BoxMouseArgs(
							box, pt.X, pt.Y, mnpHandle);
						BoxModified(this, args);
					}
					break;
				case ItemType.ControlHost:
					if (ControlHostModified != null)
					{
						ControlHost host = (ControlHost)obj;
						ControlHostMouseArgs args = new ControlHostMouseArgs(
							host, pt.X, pt.Y, mnpHandle);
						ControlHostModified(this, args);
					}
					break;
				case ItemType.Table:
					if (TableModified != null)
					{
						Table table = (Table)obj;
						TableMouseArgs args = new TableMouseArgs(
							table, pt.X, pt.Y, mnpHandle);
						TableModified(this, args);
					}
					break;
				case ItemType.Arrow:
					if (ArrowModified != null)
					{
						Arrow arrow = (Arrow)obj;
						ArrowMouseArgs args = new ArrowMouseArgs(
							arrow, pt.X, pt.Y, mnpHandle);
						ArrowModified(this, args);
					}
					break;
			}
		}
Esempio n. 3
0
    private void fcFlowChart_ArrowModified(object sender, ArrowMouseArgs e)
    {
      {
        int i = 2;

        while ((oldControlPoints.Count > 3) && (i < oldControlPoints.Count - 1))
        {

          if (MergePoints(oldControlPoints[i - 1], oldControlPoints[i]))
          {
            oldControlPoints.RemoveAt(i - 1);
            oldControlPoints.RemoveAt(i - 1);

            // Deal with the adjacent points being slightly out of algnment.
            if (Math.Abs(oldControlPoints[i - 1].X - oldControlPoints[i - 2].X) < Math.Abs(oldControlPoints[i - 1].Y - oldControlPoints[i - 2].Y))
            {
              oldControlPoints[i - 1].X = oldControlPoints[i - 2].X;
            }
            else
            {
              oldControlPoints[i - 1].Y = oldControlPoints[i - 2].Y;
            }
            i = 2;
          }

          else
          {
            i++;
          }
        }
      }

      if (MergePoints(oldControlPoints[0], oldControlPoints[1]))
      {
        oldControlPoints.RemoveAt(0);

        if (e.Arrow.CascadeOrientation == MindFusion.FlowChartX.Orientation.Horizontal)
          e.Arrow.CascadeOrientation = MindFusion.FlowChartX.Orientation.Vertical;

        else
          e.Arrow.CascadeOrientation = MindFusion.FlowChartX.Orientation.Horizontal;
      }

      if (MergePoints(oldControlPoints[oldControlPoints.Count - 1], oldControlPoints[oldControlPoints.Count - 2]))
      {
        oldControlPoints.RemoveAt(oldControlPoints.Count - 1);
      }

      form1.ToolStripStatusLabel.Text = "";

      //arrowBeingModified.CustomDraw = CustomDraw.None;
      arrowBeingModifiedSelectionHandle = -1;
      arrowBeingModified = null;
      originAnchorChosen = null;
      destinationAnchorChosen = null;

      GraphicLink graphicLink = (e.Arrow.Tag as EditorLink).GraphicLink as GraphicLink;

      if (oldOriginBox != null)
      {
        (e.Arrow.Tag as EditorLink).GraphicLink.Origin = oldOriginGuid;
        e.Arrow.Origin = oldOriginBox;
        e.Arrow.OrgnAnchor = oldOriginAnchor;
      }

      else if (newOriginBox != null)
      {
        (e.Arrow.Tag as EditorLink).GraphicLink.Origin = newOriginGuid;
        e.Arrow.Origin = newOriginBox;
        e.Arrow.OrgnAnchor = newOriginAnchor;
      }

      if (oldDestinationBox != null)
      {
        (e.Arrow.Tag as EditorLink).GraphicLink.Destination = oldDestinationGuid;
        e.Arrow.Destination = oldDestinationBox;
        e.Arrow.DestAnchor = oldDestinationAnchor;
      }

      else if (newDestinationBox != null)
      {
        (e.Arrow.Tag as EditorLink).GraphicLink.Destination = newDestinationGuid;
        e.Arrow.Destination = newDestinationBox;
        e.Arrow.DestAnchor = newDestinationAnchor;
      }

      State.SetControlPoints(e.Arrow, oldControlPoints);

      EditorNode originItem = e.Arrow.Origin.Tag as EditorNode;
      EditorNode destinationItem = e.Arrow.Destination.Tag as EditorNode;

      //Guid originGuid = Guid.Empty;
      //Guid destinationGuid = Guid.Empty;

      //if (originItem != null)
      //  originGuid = originItem.Guid;

      //if (destinationItem != null)
      //  destinationGuid = destinationItem.Guid;

      String originFullAnchor = null;
      String destinationFullAnchor = null;
      String originAnchorName = null;
      String destinationAnchorName = null;

      originItem.anchorIntToTag.TryGetValue(e.Arrow.OrgnAnchor, out originFullAnchor);

      if (originFullAnchor != null)
      {
        originAnchorName = originFullAnchor.TrimEnd(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
        graphicLink.OriginPortID = Convert.ToInt16(originFullAnchor.Substring(originAnchorName.Length), CultureInfo.InvariantCulture);
      }

      destinationItem.anchorIntToTag.TryGetValue(e.Arrow.DestAnchor, out destinationFullAnchor);

      if (destinationFullAnchor != null)
      {
        destinationAnchorName = destinationFullAnchor.TrimEnd(new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' });
        graphicLink.DestinationPortID = Convert.ToInt16(destinationFullAnchor.Substring(destinationAnchorName.Length), CultureInfo.InvariantCulture);
      }

      SysCAD.Protocol.Action action = new SysCAD.Protocol.Action();
      if (graphicLink != null)
      {
        GraphicLink newGraphicLink = graphicLink.Clone();
        newGraphicLink.ControlPoints = State.GetControlPoints(e.Arrow.ControlPoints);
        action.Modify.Add(newGraphicLink);
      }


      AddAction(action);

      //if (!state.ModifyGraphicLink(out requestId,
      //  graphicLink.Guid,
      //  graphicLink.Tag,
      //  originGuid,
      //  destinationGuid,
      //  originAnchorName,
      //  originAnchorID,
      //  destinationAnchorName,
      //  destinationAnchorID,
      //  oldControlPoints,
      //  graphicLink.TagArea,
      //  graphicLink.TagAngle))
      //{ // failure, revert back to previous.
      //  // do something here...
      //}

      oldOriginGuid = Guid.Empty;
      oldOriginBox = null;
      oldOriginAnchor = -1;

      oldDestinationGuid = Guid.Empty;
      oldDestinationBox = null;
      oldDestinationAnchor = -1;

      newOriginGuid = Guid.Empty;
      newOriginTag = String.Empty;
      newOriginBox = null;
      newOriginAnchor = -1;

      newDestinationGuid = Guid.Empty;
      newDestinationTag = String.Empty;
      newDestinationBox = null;
      newDestinationAnchor = -1;
    }