Esempio n. 1
0
		internal bool validateAnchor(Arrow arrow, bool outgoing, Node node, int pointIndex)
		{
			if (ValidateAnchorPoint != null)
			{
				AttachConfirmArgs args = new AttachConfirmArgs(arrow,
					node, outgoing, pointIndex, 0);
				ValidateAnchorPoint(this, args);

				return args.Confirm;
			}

			return true;
		}
Esempio n. 2
0
		internal bool requestAttach(Arrow arrow, bool changingOrg, Node node)
		{
			if (ArrowAttaching != null)
			{
				PointF endPt = changingOrg ? arrow.Points[0] : arrow.Points[arrow.Points.Count - 1];
				int id = 0;
				int row = -1;
				node.getAnchor(endPt, arrow, !changingOrg, ref id);

				// get the row if attaching to table
				Table table = node as Table;
				if (table != null)
					row = table.rowFromPt(endPt);

				AttachConfirmArgs args = new AttachConfirmArgs(arrow,
					node, changingOrg, id, row);
				ArrowAttaching(this, args);

				return args.Confirm;
			}

			return true;
		}
Esempio n. 3
0
        /// <summary>
        /// 箭头绘画
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void flowChart1_ArrowCreating(object sender, AttachConfirmArgs e)
        {
            Box destBox = (Box)e.Destination;
            Box originBox=(Box)e.Origin;

            //判断连接点的输入元件类型是否相同,相同则不允许连接
            if (MainFormExt.ConnectorElements.Contains(destBox))
            {
                foreach (Arrow arrow in destBox.IncomingArrows)
                {
                    Box box = (Box)arrow.Destination;
                    if (box.Text == destBox.Text)
                    {
                        e.Confirm = false;
                        return;
                    }
                }

            }

            if (MainFormExt.ComponentElements.Contains(originBox)&&
                MainFormExt.ComponentElements.Contains(destBox) &&
                (originBox.OutgoingArrows.Count > 0 || destBox.IncomingArrows.Count > 0))
            {
                e.Confirm = false;
                return;
            }
            else if (MainFormExt.StartElements.Contains(originBox) &&
                //originBox.OutgoingArrows.Count<=0&&
                MainFormExt.ComponentElements.Contains(destBox))
            {
                e.Confirm = true;
            }
            else if (MainFormExt.ConnectorElements.Contains(originBox) &&
                MainFormExt.ComponentElements.Contains(destBox))
            {
                e.Confirm = true;
            }
            else if (MainFormExt.ComponentElements.Contains(originBox) &&
                       (MainFormExt.ComponentElements.Contains(destBox) ||
                           (MainFormExt.EndElements.Contains(destBox)
                //&&destBox.IncomingArrows.Count<=0
                           ) ||
                           MainFormExt.ConnectorElements.Contains(destBox)
                       )
                   )
            {
                e.Confirm = true;
            }
            else
            {
                e.Confirm = false;
                return;
            }

            BoxPropertiesExt pro = new BoxPropertiesExt();
            pro.property = (Element)new ArrowElement();
            pro.model = "-3";
            e.Arrow.Tag = pro;

            ArrowConfirmArgs args = new ArrowConfirmArgs(e.Arrow);
            flowChart1_ArrowSelecting(this.propertyGrid1, args);
            //this.propertyGrid1.SelectedObject = pro;
        }
Esempio n. 4
0
		internal bool confirmCreate(ChartObject item)
		{
			PointF point = AlignPointToGrid(interaction.CurrentPoint);
			bool validated = true;

			switch (item.getType())
			{
				case ItemType.Box:
					if (BoxCreating != null)
					{
						BoxConfirmArgs args = new BoxConfirmArgs((Box)item, point, -1);
						BoxCreating(this, args);
						validated = args.Confirm;
					}
					break;
				case ItemType.ControlHost:
					if (ControlHostCreating != null)
					{
						ControlHostConfirmArgs args =
							new ControlHostConfirmArgs((ControlHost)item, point, -1);
						ControlHostCreating(this, args);
						validated = args.Confirm;
					}
					break;
				case ItemType.Table:
					if (TableCreating != null)
					{
						TableConfirmArgs args = new TableConfirmArgs((Table)item, point, -1);
						TableCreating(this, args);
						validated = args.Confirm;
					}
					break;
				case ItemType.Arrow:
					if (ArrowCreating != null)
					{
						Arrow arrow = (Arrow)item;

						PointF endPt = arrow.Points[arrow.Points.Count - 1];
						int id = 0;
						int row = -1;
						arrow.NewDest.getAnchor(endPt, arrow, true, ref id);
						if (arrow.NewDest is Table)
							row = ((Table)arrow.NewDest).rowFromPt(endPt);

						AttachConfirmArgs args = new AttachConfirmArgs(
							arrow, arrow.NewDest, false, id, row);
						ArrowCreating(this, args);

						validated = args.Confirm;
					}
					break;
			}

			return validated;
		}
Esempio n. 5
0
    private void fcFlowChart_ArrowCreating(object sender, AttachConfirmArgs e)
    {
      SysCAD.Protocol.Point originPos = new SysCAD.Protocol.Point(e.Arrow.ControlPoints[0]);
      Box originBox = fcFlowChart.GetBoxAt(originPos.ToPointF(), 2.0F);

      originBox = (originBox.Tag as EditorNode).ModelBox;

      if (originBox != null)
      {
        int closestI = 0;
        Double closestDistance = Double.MaxValue;

        for (int i = 0; i < originBox.AnchorPattern.Points.Count; i++)
        {

          if (originBox.AnchorPattern.Points[i].AllowOutgoing)
          {
            SysCAD.Protocol.Point anchorPointPos = GetRelativeAnchorPosition(new SysCAD.Protocol.Rectangle(originBox.BoundingRect),
              originBox.AnchorPattern.Points[i].X,
              originBox.AnchorPattern.Points[i].Y,
              originBox.RotationAngle);

            Double thisDistance = Distance(originPos, anchorPointPos);

            if (thisDistance < closestDistance)
            {
              closestDistance = thisDistance;
              closestI = i;
            }
          }
        }

        newOriginGuid = (originBox.Tag as EditorNode).Guid;
        newOriginTag = (originBox.Tag as EditorNode).Tag;
        newOriginBox = originBox;

        newOriginAnchor = closestI;
      }

      DoArrowModifyingOperations(e.Arrow, e.Arrow.ControlPoints.Count - 1);
      //arrowBeingModified = e.Arrow;
      //arrowBeingModified.CustomDraw = CustomDraw.Additional;
      //arrowBeingModified.ZTop();
      //fcFlowChart.RecreateCacheImage();
    }