Esempio n. 1
0
        public void ReAddedCanvasItem(CanvasItem item)
        {
            item.ClearDecorator();
            item.RedrawNeeded     -= HandleRedraw;
            item.LayoutChanged    -= HandleItemLayoutChange;
            item.PositionChanging -= HandleItemPositionChange;
            item.SizeChanging     -= HandleItemSizeChange;

            AddCanvasItem(item);
        }
Esempio n. 2
0
        /// <summary>
        /// Retruns a copy of the the canvas items list as an array.
        /// </summary>
        public CanvasItem[] GetCanvasItems()
        {
            CanvasItem[] items = new CanvasItem[itemsList.Count];
            int          i     = 0;

            foreach (CanvasItemData item in itemsList)
            {
                items[i++] = item.Item;
            }
            return(items);
        }
Esempio n. 3
0
            public CanvasItemData(CanvasItem item,
                                  EventHandler <SizeGripEventArgs> SizeGripMouseEntered,
                                  EventHandler <SizeGripEventArgs> SizeGripMouseLeft)
            {
                this.item = item;

                focusDecorator    = new FocusDecorator(item);
                sizeGripDecorator = new SizeGripDecorator(item);

                sizeGripDecorator.SizeGripMouseEnter += SizeGripMouseEntered;
                sizeGripDecorator.SizeGripMouseLeave += SizeGripMouseLeft;

                item.AddDecorator(focusDecorator);
                item.AddDecorator(sizeGripDecorator);
            }
Esempio n. 4
0
        public void SetFocusedCanvasItem(CanvasItem ci)
        {
            CanvasItemData value = null;

            if (itemsData.TryGetValue(ci, out value))
            {
                LinkedListNode <CanvasItemData> itemNode = new LinkedListNode <CanvasItemData>(value);
                SetItemFocus(itemNode);
                ClearAllItemsFocus(itemNode);
                if (itemsList.Last.Value != itemNode.Value)
                {
                    itemsList.Remove(itemNode.Value);
                    itemsList.AddLast(itemNode.Value);
                }
            }
        }
Esempio n. 5
0
        public void RemoveCanvasItem(CanvasItem item)
        {
            if (item == null)
            {
                return;
            }

            itemsList.Remove(itemsData[item]);
            Stack <Route> routesToRemove = new Stack <Route>();

            foreach (Route r in diagramRouter.Routes)
            {
                if (r.From == item || r.To == item)
                {
                    routesToRemove.Push(r);
                }
            }

            foreach (Route r in routesToRemove)
            {
                diagramRouter.RemoveRoute(r);
            }

            diagramRouter.RemoveItem(item);

            NodeCanvasItem classItem = item as NodeCanvasItem;

            if (classItem != null)
            {
                nodesToData.Remove(classItem.GetNodeData);
            }

            itemsData.Remove(item);

            LayoutChanged(this, EventArgs.Empty);
        }
Esempio n. 6
0
        /// <summary>
        /// добавление новой ноды
        /// </summary>
        /// <param name="item"></param>
        public void AddCanvasItem(CanvasItem item, CanvasItem itemAt = null)
        {
            NodeCanvasItem classItem = item as NodeCanvasItem;

            if (classItem != null)
            {
                classItem.OffsetPointTo();
            }

            diagramRouter.AddItem(item);
            CanvasItemData itemData = new CanvasItemData(item, SizeGripMouseEntered, SizeGripMouseLeft);

            itemsData[item] = itemData;

            if (classItem != null)
            {
                nodesToData.Add(classItem.GetNodeData, item);
                foreach (CanvasItemData ci in itemsList)
                {
                    NodeCanvasItem cci = ci.Item as NodeCanvasItem;
                    if (cci != null)
                    {
                        //Route r = null;
                        foreach (LinkTo link in cci.GetNodeData.LinkedToNodes)
                        {
                            if (link.NameTo == classItem.GetNodeData.Name)
                            {
                                //                  link: from  >>>  to
                                Route r = diagramRouter.AddRoute(cci, classItem, link.ContentLine);
                                r.EndShape   = new RouteInheritanceShape();
                                r.StartShape = new RouteStartShape();
                            }
                        }
                        //if (r != null) {}
                        foreach (LinkTo link in classItem.GetNodeData.LinkedToNodes)
                        {
                            if (link.NameTo == cci.GetNodeData.Name)
                            {
                                //                  link: from  >>>  to
                                Route r = diagramRouter.AddRoute(classItem, cci, link.ContentLine);
                                r.EndShape   = new RouteInheritanceShape();
                                r.StartShape = new RouteStartShape();
                            }
                        }
                        //if (r != null && r.EndShape == null) {}
                    }
                }
            }

            // добавление ноды в лист
            if (itemAt != null)
            {
                LinkedListNode <CanvasItemData> find = itemsList.Find(itemsData[itemAt]);
                if (find != null)
                {
                    itemsList.AddBefore(find, itemData);
                }
                else
                {
                    itemsList.AddLast(itemData);
                }
            }
            else
            {
                itemsList.AddLast(itemData);
            }

            item.RedrawNeeded     += HandleRedraw;
            item.LayoutChanged    += HandleItemLayoutChange;
            item.PositionChanging += HandleItemPositionChange;
            item.SizeChanging     += HandleItemSizeChange;
        }
Esempio n. 7
0
 public CanvasItemEventArgs(CanvasItem canvasItem)
 {
     this.canvasItem = canvasItem;
 }