Пример #1
0
        protected GraphSetting graphSetting; // 绘图参数配置对象

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="line">连接线控制点所属的连接线</param>
        /// <param name="location">连接点的位置</param>
        /// <param name="size">连接线的大小</param>
        public ConnectorGraphElement(ConnectorContainer line, Point location, Size size)
            : base(location)
        {
            this.line = line;
            this.location = location;
            this.elementSize = size;
        }
Пример #2
0
        /// <summary>
        /// 获取与连接线绑定的出口插槽的索引
        /// </summary>
        /// <param name="line">连接线</param>
        /// <returns>索引</returns>
        public int GetBindedOutSlotIndex(ConnectorContainer line)
        {
            int index = -1;
            SlotGraphElement slot = GetBindedOutSlot(line);

            if (slot != null)
            {
                index = slot.Priority;
            }

            return index;
        }
Пример #3
0
        /// <summary>
        /// 获取与连接线绑定的出口插槽
        /// </summary>
        /// <param name="line">连接线</param>
        /// <returns>出口插槽</returns>
        public SlotGraphElement GetBindedOutSlot(ConnectorContainer line)
        {
            SlotGraphElement slotGraphElement = null;

            foreach (SlotGraphElement slot in outSlotList)
            {
                if (slot.Binded && slot.BindingConnector.Line == line)
                {
                    slotGraphElement = slot;
                    break;
                }
            }

            return slotGraphElement;
        }
Пример #4
0
        /// <summary>
        /// 绑定连出的连接线
        /// </summary>
        /// <param name="line">连接线</param>
        /// <param name="index">索引</param>
        public virtual void BindOutLine(ConnectorContainer line, int index)
        {
            if (index >= 0 && index < outSlotCount)
            {
                SlotGraphElement slot = outSlotList[index];

                if (!slot.Binded)
                {
                    slot.Bind(line.TailConnector);
                }
            }
        }
Пример #5
0
        /// <summary>
        /// 绑定连出的连接线
        /// </summary>
        /// <param name="line">连接线</param>
        public virtual void BindOutLine(ConnectorContainer line)
        {
            SlotGraphElement slot = GetOutSlot();

            if (slot != null)
            {
                slot.Bind(line.TailConnector);
            }
        }
Пример #6
0
        /// <summary>
        /// 绑定连入的连接线
        /// </summary>
        /// <param name="line">连接线</param>
        /// <param name="index">索引</param>
        public virtual void BindInLine(ConnectorContainer line, int index)
        {            
            if (index >= 0 && index < inSlotCount)
            {
                SlotGraphElement slot = inSlotList[index];

                if (!slot.Binded)
                {
                    slot.Bind(line.HeadConnector);
                }
            }
        }
Пример #7
0
        /// <summary>
        /// 绑定连入的连接线
        /// </summary>
        /// <param name="line">连接线</param>
        public virtual void BindInLine(ConnectorContainer line)
        {
            SlotGraphElement slot = GetInSlot();

            if (slot != null)
            {
                slot.Bind(line.HeadConnector);
            }
        }
Пример #8
0
 /// <summary>
 /// 添加连接线到区域
 /// </summary>
 /// <param name="line">添加连接线到区域</param>
 public void Add(ConnectorContainer line)
 {
     if (!connectorContainers.Contains(line))
     {
         connectorContainers.Add(line);
     }
 }
Пример #9
0
        /// <summary>
        /// 检查是否连接有事件结点
        /// </summary>
        /// <param name="line">当前连接线</param>
        /// <returns>是否连接有事件结点</returns>
        public bool IsConnectEventNode(ConnectorContainer line)
        {
            bool result = false;

            if (line.RequireEvent) // 需要入口事件
            {
                if (GetEventList(line).Count > 0)
                {
                    result = true;
                }
            }
            else
            {
                result = true;
            }            

            return result;
        }
Пример #10
0
        /// <summary>
        /// 获取连接线对应的事件结点数据链表
        /// </summary>
        /// <param name="connectorContainer">当前连接线</param>
        /// <returns>连接线对应的事件结点数据链表</returns>
        public List<DataElement> GetEventList(ConnectorContainer line)
        {
            List<DataElement> list = new List<DataElement>();
            SlotContainer slotContainer = line.InSlotContainer;

            if(slotContainer != null)
            {
                List<SlotContainer> slotContainerList = GetAllPreviousSlotContainers(slotContainer);
                foreach (SlotContainer s in slotContainerList)
                {
                    if (s is EventGraphElement)
                    {
                        DataElement dataElement = graphTable[s] as DataElement;
                        if (dataElement != null)
                        {
                            list.Add(dataElement);
                        }
                    }
                }
            }

            return list;
        }
Пример #11
0
            /// <summary>
            /// 检查区域中是否包含当前连接线
            /// </summary>
            /// <param name="line">当前连接线</param>
            /// <returns>区域中是否包含当前连接线</returns>
            public bool Contains(ConnectorContainer line)
            {
                bool result = connectorContainers.Contains(line);

                return result;
            }
Пример #12
0
 /// <summary>
 /// 删除区域中的连接线
 /// </summary>
 /// <param name="line">当前连接线</param>
 public void Remove(ConnectorContainer line)
 {
     connectorContainers.Remove(line);
 }
Пример #13
0
        /// <summary>
        /// 更新连接线所在的区域
        /// </summary>
        /// <param name="line">当前连接线</param>
        private void ChangeRegion(ConnectorContainer line)
        {
            bool added = false; // 是否已经添加到区域中

            foreach (RegionData regionData in regionDataList)
            {
                if (regionData.Contains(line) && !regionData.IsInRegion(line.InvalidRectangle))
                {
                    regionData.Remove(line);
                }

                if (!regionData.Contains(line) && regionData.IsInRegion(line.InvalidRectangle))
                {
                    regionData.Add(line);
                    added = true;
                }
            }

            if (!added)
            {
                backupRegionData.Add(line);
            }
        }
Пример #14
0
        /// <summary>
        /// 将连接线从区域中删除
        /// </summary>
        /// <param name="line">当前连接线</param>
        private void DeleteFromRegion(ConnectorContainer line)
        {
            foreach (RegionData regionData in regionDataList)
            {
                regionData.Remove(line);
            }

            backupRegionData.Remove(line);
        }
Пример #15
0
        /// <summary>
        /// 将连接线加入区域中
        /// </summary>
        /// <param name="line">当前连接线</param>
        private void AddToRegion(ConnectorContainer line)
        {
            bool added = false;

            foreach (RegionData regionData in regionDataList)
            {
                if (regionData.IsInRegion(line.InvalidRectangle))
                {
                    regionData.Add(line);
                    added = true;
                }
            }

            if (!added)
            {
                backupRegionData.Add(line);
            }
        }
Пример #16
0
        /// <summary>
        /// 调整连接线
        /// </summary>
        /// <param name="line">当前连接线</param>
        /// <param name="slotContainer">相关的插槽容器</param>
        private void AdjustLine(ConnectorContainer line , SlotContainer slotContainer)
        {
            Rectangle adjustRectangle = line.GetAdjustRectangle(background.CanvasSize, background.GridSize.Width);
            List<SlotContainer> totalSlotContainerList = regionManager.GetSlotContainerList(adjustRectangle);
            List<ConnectorContainer> totalLineList = regionManager.GetConnectorContainerList(adjustRectangle);

            line.AdjustLine(slotContainer, totalSlotContainerList, totalLineList, background.GridSize.Width, background.BaseSize, regionManager.CanvasGridBoard);
            line.AdjustRectangle();  
        }
Пример #17
0
        /// <summary>
        /// 复制图元
        /// </summary>
        /// <returns>复制的图元</returns>
        public virtual ConnectorContainer Clone()
        {
            ConnectorContainer newLine = new ConnectorContainer(tailConnector.Location, headConnector.Location);
            newLine.Text = text;
            newLine.DisplayText = displayText;
            newLine.TooltipText = tooltipText;
            newLine.ShowText = showText;
            newLine.ShowID = showID;

            newLine.Init();
            newLine.Refresh();

            newLine.ConnectorCount = connectorCount;
            List<ConnectorGraphElement> list = newLine.GetConnectorList();

            for(int i = 0; i < connectorList.Count; i++)
            {
                list[i].Location = connectorList[i].Location;
            }

            return newLine;
        }
Пример #18
0
        /// <summary>
        /// 取消绑定连接线
        /// </summary>
        /// <param name="line">连接线</param>
        public virtual void UnBindLine(ConnectorContainer line)
        {
            SlotGraphElement deleteSlot = null;

            foreach(SlotGraphElement slot in slotList)
            {
                if(slot.Binded && ((slot.BindingConnector == line.HeadConnector) || slot.BindingConnector == line.TailConnector))
                {
                    slot.UnBind();
                    deleteSlot = slot;
                    break;
                }
            }

            if (deleteSlot != null && deleteSlot.CanDelete) // 插槽可以删除
            {
                if(deleteSlot.IsInSlot || outSlotCount > 1)
                {
                    RemoveSlot(deleteSlot);
                }                
            }
        }