Пример #1
0
        public Storage(Stream context, EventBridge bridge, List <string> classes)
        {
            BinaryFormatter formatter = new BinaryFormatter();

            sList = (List <T>)formatter.Deserialize(context);
            foreach (var v in sList)
            {
                if (!(v is DependencyArrow))
                {
                    (v as UMLClassBox).initMenu(bridge);
                    (v as UMLClassBox).beforeLoadSets(classes);
                    continue;
                }

                DependencyArrow arrow = v as DependencyArrow;
                UMLClassBox     f     = null;
                UMLClassBox     s     = null;
                foreach (var block in sList)
                {
                    if (!(block is UMLClassBox))
                    {
                        continue;
                    }
                    if ((block as UMLClassBox).getGuid() == arrow.getFGUID())
                    {
                        f = block as UMLClassBox;
                    }
                    else if ((block as UMLClassBox).getGuid() == arrow.getSGUID())
                    {
                        s = block as UMLClassBox;
                    }
                    if (f != null && s != null)
                    {
                        break;
                    }
                }
                arrow.setDependencyBeforeLoad(f, s);
            }
        }
Пример #2
0
        public void ContextMenuAddParent(object sender, RoutedEventArgs e)
        {
            if (!(sender is MenuItem))
            {
                return;
            }
            string          guid   = ((MenuItem)sender).Name.Substring(1, ((MenuItem)sender).Name.Length - 1).Replace("_", "-");
            DependencyArrow link   = null;
            UMLClassBox     fblock = null;
            UMLClassBox     sblock = null;

            foreach (var val in elements)
            {
                if (val is DependencyArrow && (val as DependencyArrow).getFGUID() == guid && ((val as DependencyArrow).GetTip() == DependencyArrow.Tips.ImplementationArrow || (val as DependencyArrow).GetTip() == DependencyArrow.Tips.DerivArrow))
                {
                    link = val as DependencyArrow;
                }
                else if (val is UMLClassBox && (val as UMLClassBox).getGuid() == guid)
                {
                    fblock = val as UMLClassBox;
                }
                if (link != null && fblock != null)
                {
                    break;
                }
            }

            if (link != null)
            {
                foreach (var umlElement in elements)
                {
                    if (umlElement is UMLClassBox && (umlElement as UMLClassBox).getGuid() == link.getSGUID())
                    {
                        sblock = umlElement as UMLClassBox;
                        break;
                    }
                }
            }
            ParentDependencyWindow dependencyWindow = new ParentDependencyWindow(fblock.getFieldsList(), fblock.getMethodsList());

            if (dependencyWindow.ShowDialog() != true)
            {
                return;
            }
            if (link != null)
            {
                elements.Remove(link);
                link.removeGraphicFromCanvas(drawCanvas);
            }
            UMLClassBox newbox = dependencyWindow.generateParent(fblock.GetCenterPoint(), classes);

            fblock.move(new Point(160, 0), drawCanvas);
            DependencyArrow arrow = new DependencyArrow(fblock, newbox, DependencyArrow.Tips.DerivArrow);

            arrow.draw(drawCanvas);
            newbox.draw(drawCanvas);
            newbox.beforeLoadSets(classes);
            newbox.initMenu(this);
            elements.Add(arrow);
            elements.Add(newbox);
            if (link != null)
            {
                DependencyArrow sArrow = new DependencyArrow(newbox, sblock, link.GetTip());
                sArrow.draw(drawCanvas);
                elements.Add(sArrow);
            }
            //TODO: удалять отдельно связи
        }