Ejemplo n.º 1
0
        /// <summary>
        /// Do not call it directly
        /// </summary>
        public void AddSingleCanvasItem(CanvasItem item)
        {
            diagramRouter.AddItem(item);
            CanvasItemData itemData = new CanvasItemData(item, SizeGripMouseEntered, SizeGripMouseLeft);

            itemsData[item] = itemData;

            itemsList.Add(itemData);
            item.RedrawNeeded     += HandleRedraw;
            item.LayoutChanged    += HandleItemLayoutChange;
            item.PositionChanging += HandleItemPositionChange;
            item.SizeChanging     += HandleItemSizeChange;

            LayoutChanged(this, EventArgs.Empty);
        }
Ejemplo n.º 2
0
        public void AddCanvasItem(CanvasItem item)
        {
            diagramRouter.AddItem(item);
            CanvasItemData itemData = new CanvasItemData(item, SizeGripMouseEntered, SizeGripMouseLeft);

            itemsData[item] = itemData;

            ClassCanvasItem classItem = item as ClassCanvasItem;

            if (classItem != null)
            {
                classesToData.Add(classItem.RepresentedClassType, itemData);
                foreach (CanvasItemData ci in itemsList)
                {
                    ClassCanvasItem cci = ci.Item as ClassCanvasItem;
                    if (cci != null)
                    {
                        Route r = null;
                        if (cci.RepresentedClassType == classItem.RepresentedClassType.BaseClass)
                        {
                            r = diagramRouter.AddRoute(item, cci);
                        }
                        else if (classItem.RepresentedClassType == cci.RepresentedClassType.BaseClass)
                        {
                            r = diagramRouter.AddRoute(cci, classItem);
                        }

                        if (r != null)
                        {
                            r.EndShape = new RouteInheritanceShape();
                        }
                    }
                }
            }

            itemsList.AddLast(itemData);
            item.RedrawNeeded     += HandleRedraw;
            item.LayoutChanged    += HandleItemLayoutChange;
            item.PositionChanging += HandleItemPositionChange;
            item.SizeChanging     += HandleItemSizeChange;
        }
Ejemplo n.º 3
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;
        }