Ejemplo n.º 1
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            Point locate = new Point(
                e.X + HorizontalScroll.Value,
                e.Y + VerticalScroll.Value);

            if (e.Button == MouseButtons.Left)
            {
                clickedItem = GetItemAtPoint(locate);
                if (clickedItem != null)
                {
                    if (clickedItem is CustomItemNode)
                    {
                        if (!drawingLine)
                        {
                            clickedItemPoint =
                                new Point(
                                    locate.X - clickedItem.ItemLocate.X,
                                    locate.Y - clickedItem.ItemLocate.Y);
                        }
                        else
                        {
                            if (!(clickedItem is ItemEnd))
                            {
                                currentDrawingLine            = CreateWorkFlowLine();
                                currentDrawingLine.ItemStatus = ItemStatus.Drawing;
                                currentDrawingLine.ItemFrom   = clickedItem as CustomItemNode;
                            }
                        }
                    }
                }
            }

            base.OnMouseDown(e);
        }
Ejemplo n.º 2
0
 private bool LinkLineExists(ItemLink link)
 {
     foreach (ItemLink itemLink in link.ItemFrom.NextLinks)
     {
         if (link.ItemFrom == itemLink.ItemFrom && link.ItemTo == itemLink.ItemTo)
         {
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 新建连接线后的链路校验。
 /// 缺省的检验是:如果形成闭合循环,则返回 false,否则返回 true
 /// </summary>
 protected virtual bool CheckValid(ItemLink link, CustomItemNode node)
 {
     if (NodeInPrevRouting(link, node))
     {
         MessageBox.Show(
             "当前流程不支持闭合循环!",
             "链路错误",
             MessageBoxButtons.OK,
             MessageBoxIcon.Error);
         return(false);
     }
     else
     {
         return(true);
     }
 }
Ejemplo n.º 4
0
        protected override void OnMouseUp(MouseEventArgs e)
        {
            Point location = new Point(
                e.X + HorizontalScroll.Value,
                e.Y + VerticalScroll.Value);

            if (e.Button == MouseButtons.Left)
            {
                if (drawingLine)
                {
                    if (currentDrawingLine != null)
                    {
                        IPaintItem item = GetItemAtPoint(location);
                        if (item != null && item is CustomItemNode)
                        {
                            if (item == currentDrawingLine.ItemFrom)
                            {
                            }
                            else if (item is ItemBegin)
                            {
                            }
                            else
                            {
                                if (CheckValid(
                                        currentDrawingLine,
                                        item as CustomItemNode))
                                {
                                    currentDrawingLine.ItemStatus = ItemStatus.Watting;
                                    currentDrawingLine.ItemTo     = item as CustomItemNode;

                                    if (!LinkLineExists(currentDrawingLine))
                                    {
                                        currentDrawingLine.ItemTo.PrevLinks.Add(currentDrawingLine);
                                        currentDrawingLine.ItemFrom.NextLinks.Add(currentDrawingLine);
                                    }
                                }
                            }
                        }
                        currentDrawingLine = null;
                    }
                }
            }

            base.OnMouseUp(e);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 检查指定的结点是否是当前连接线的起始结点
        /// </summary>
        protected virtual bool NodeInPrevRouting(ItemLink link, CustomItemNode node)
        {
            if (link.ItemFrom == node)
            {
                return(true);
            }
            else
            {
                foreach (ItemLink prevLink in link.ItemFrom.PrevLinks)
                {
                    if (NodeInPrevRouting(prevLink, node))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }