Exemple #1
0
        public DependencyArrow(UMLElement firstBlock, UMLElement secondBlock, Tips type)
        {
            if (!(firstBlock is UMLClassBox) || !(secondBlock is UMLClassBox))
            {
                throw  new Exception("Один из элементов пустой");
            }
            fb    = firstBlock as UMLClassBox;
            sb    = secondBlock as UMLClassBox;
            fguid = fb.getGuid();
            sguid = sb.getGuid();
            mode  = type;
            t     = generateTip(type);
            switch (type)
            {
            case Tips.AssotiationArrow:
            case Tips.DerivArrow:
            case Tips.AggregationArrow:
            case Tips.CompositionArrow:
                r = new BetweenLine(getPointForFirstBLock(), t.GetEndPointForLine(), BetweenLine.Type.Solid);
                break;

            case Tips.DependenceArrow:
            case Tips.ImplementationArrow:
                r = new BetweenLine(getPointForFirstBLock(), t.GetEndPointForLine(), BetweenLine.Type.Dotted);
                break;
            }
            updateEvents();
            fieldsSync();
            fb.addObserver(this);
            sb.addObserver(this);
        }
Exemple #2
0
        public UMLClassBox generateParent(Point point, List <string> clases)
        {
            UMLClassBox box = new UMLClassBox("NewParentClass", UMLClassBox.BoxType.Class, new Point(point.X - 150, point.Y - 200), clases);

            foreach (var fitem in FiledListBox.SelectedItems)
            {
                var      umlBlockLine = ((FItem)fitem).LinkObj;
                TextBox  text         = new TextBox();
                ComboBox combo        = new ComboBox();
                text.Name         = combo.Name = umlBlockLine.GUID;
                text.Text         = umlBlockLine.Name.Text;
                combo.ItemsSource = umlBlockLine.Type.ItemsSource;
                combo.Text        = umlBlockLine.Type.Text;
                box.getFieldsList().Add(new UMLBlockLine()
                {
                    GUID = umlBlockLine.GUID, Name = text, Type = combo
                });
            }
            foreach (var fitem in MethodsList.SelectedItems)
            {
                var      umlBlockLine = ((FItem)fitem).LinkObj;
                TextBox  text         = new TextBox();
                ComboBox combo        = new ComboBox();
                text.Name         = combo.Name = umlBlockLine.GUID;
                text.Text         = umlBlockLine.Name.Text;
                combo.ItemsSource = umlBlockLine.Type.ItemsSource;
                combo.Text        = umlBlockLine.Type.Text;
                box.getMethodsList().Add(new UMLBlockLine()
                {
                    GUID = umlBlockLine.GUID, Name = text, Type = combo
                });
            }
            box.updateGUI();
            return(box);
        }
Exemple #3
0
        public void ContextMenuAddChild(object sender, RoutedEventArgs e)
        {
            if (!(sender is MenuItem))
            {
                return;
            }
            string guid = ((MenuItem)sender).Name.Substring(1, ((MenuItem)sender).Name.Length - 1).Replace("_", "-");

            foreach (var umlElement in elements)
            {
                if (umlElement is UMLClassBox && ((UMLClassBox)umlElement).getGuid() == guid)
                {
                    UMLClassBox f = umlElement as UMLClassBox;
                    Point       s = f.GetCenterPoint();
                    UMLClassBox n = new UMLClassBox("NewChildClass", UMLClassBox.BoxType.Class, new Point(s.X + 160, s.Y), classes);
                    n.draw(drawCanvas);
                    n.initMenu(this);
                    DependencyArrow dependency = new DependencyArrow(n, f, (f.getType() == UMLClassBox.BoxType.Class)? DependencyArrow.Tips.DerivArrow: DependencyArrow.Tips.ImplementationArrow);
                    dependency.draw(drawCanvas);
                    elements.Add(n);
                    elements.Add(dependency);
                    return;
                }
            }
        }
Exemple #4
0
        private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Point now = e.GetPosition((UIElement)sender);

            if (picked == State.ClassBox || picked == State.InterfaceBox)
            {
                drawCanvas.Children.Remove(rectangle);
                now = new Point(now.X - rectangle.Width / 2, now.Y - rectangle.Height / 2);
                UMLClassBox box = new UMLClassBox("SomeClass", (picked == State.ClassBox)? UMLClassBox.BoxType.Class: UMLClassBox.BoxType.Interface, now, classes);
                box.initMenu(this);
                box.draw(drawCanvas);
                elements.Add(box);
                setMode(State.Editing);
            }
            else if (picked == State.Editing && !isMoving && e.ChangedButton == MouseButton.Left && e.ChangedButton != MouseButton.Right)
            {
                UMLElement g = getPickedElement(now);
                if (g != null)
                {
                    g.setPicked(!g.getPicked());
                    return;
                }
            }
            else if (picked != State.Editing)
            {
                if (!doubleClick)
                {
                    doubleClick = true;
                    fblock      = getPickedElement(now);
                }
                else
                {
                    DependencyArrow.Tips s;
                    s           = convertTip();
                    doubleClick = false;
                    DependencyArrow line = new DependencyArrow(fblock, getPickedElement(now), s);
                    line.draw(drawCanvas);
                    elements.Add(line);
                    setMode(State.Editing);
                }
            }

            isMoving = false;
        }
Exemple #5
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);
            }
        }
Exemple #6
0
        private Tip generateTip(Tips type)
        {
            double ox   = (sb).GetCenterPoint().X - (fb).GetCenterPoint().X;
            int    indS = (ox < 0) ? 1 : 0;

            Tip.Turns   turn = (ox < 0) ? Tip.Turns.Left : Tip.Turns.Right;
            Tip         t    = null;
            UMLClassBox s    = sb;

            switch (type)
            {
            case Tips.AssotiationArrow:
                t = new AssociationTip(s.getStartPoints()[indS], turn);
                break;

            case Tips.DerivArrow:
                t = new DerivTip(s.getStartPoints()[indS], turn);
                break;

            case Tips.AggregationArrow:
                t = new AggregateTip(s.getStartPoints()[indS], turn, Brushes.White);
                break;

            case Tips.CompositionArrow:
                t = new AggregateTip(s.getStartPoints()[indS], turn, Brushes.Black);
                break;

            case Tips.DependenceArrow:
                t = new AssociationTip(s.getStartPoints()[indS], turn);
                break;

            case Tips.ImplementationArrow:
                t = new DerivTip(s.getStartPoints()[indS], turn);
                break;
            }

            return(t);
        }
Exemple #7
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: удалять отдельно связи
        }