Пример #1
0
        public void NewRelation(UmlRelation rel)
        {
            GuiClass c1 = FindClass(rel.src), c2 = FindClass(rel.dest);

            if (c1 != null && c2 != null)
            {
                int   ux1 = 1, ux2 = 3;
                float uy1 = .5f, uy2 = .5f;

                if (rel.type == UmlRelationType.Association)
                {
                    ux1 = 0;
                    uy1 = c1.get_empty_point_on_edge(ux1);
                    ux2 = 2;
                    uy2 = c2.get_empty_point_on_edge(ux2);
                }
                else if (rel.type == UmlRelationType.Realization || rel.type == UmlRelationType.Inheritance)
                {
                    uy2 = c2.get_empty_point_on_edge(ux2);
                }

                GuiConnection c = new GuiConnection(new GuiConnectionPoint(c1, ux1, uy1, 0), new GuiConnectionPoint(c2, ux2, uy2, 1), rel.type, this, rel.type == UmlRelationType.Attachment ? GuiConnectionStyle.Line : MouseAgent.conn_style);
                if (rel.type == UmlRelationType.Association)
                {
                    c.nav = GuiConnectionNavigation.Left;
                }
                c.relation_id = rel.ID;
                c.first.UpdatePosition(true);
                c.second.UpdatePosition(true);
                c.DoCreationFixup();
                c.ConnectionCreated(this, rel.src_role, rel.dest_role, rel.name, rel.stereo);
                Undo.Push(new CreateOperation(c), false);
            }
        }
Пример #2
0
 public bool validate_connection(IAcceptConnection obj, GuiConnection connection)
 {
     return(true);
 }
 public ConnectionStateSegmented(GuiConnection c)
 {
     conn = c;
 }
Пример #4
0
 public ConnectionStateQuadric(GuiConnection c)
 {
     conn = c;
 }
Пример #5
0
        public override void MouseUp(MouseButtons b)
        {
            if (scroll_active)
            {
                StopScrolling();
            }

            parent.SetDefaultDrawingMode();
            original_selected = null;

            switch (action)
            {
            case MouseAction.Scroll:
                Cursor.Current = Cursors.Arrow;
                if (first_move)
                {
                    System.Windows.Forms.ContextMenu m = new ContextMenu();
                    parent.AddMenuItems(m);
                    if (m.MenuItems.Count > 0)
                    {
                        m.Show(parent.cview, new Point(menurealx, menurealy));
                    }
                }
                break;

            case MouseAction.CreateConnection:
                if (conn.second.item == null)
                {
                    conn.Invalidate();
                }
                else
                {
                    conn.ConnectionCreated(parent, null, null, null, null);
                    parent.Undo.Push(new CreateOperation(conn), false);
                }
                conn = null;
                break;

            case MouseAction.Move:

                ArrayList movedobjects = new ArrayList();
                foreach (GuiObject o in movestates.Keys)
                {
                    if (o is IAroundObject)
                    {
                        movedobjects.Add(o);
                    }
                }
                if (movedobjects.Count > 0)
                {
                    parent.AroundObjectsMoved(movedobjects, movestates);
                }

                foreach (IMoveable o in movestates.Keys)
                {
                    o.Moved();
                }

                if (movestates.Count == 1)
                {
                    foreach (IStateObject t in movestates.Keys)
                    {
                        parent.Undo.Push(new StateOperation(t, movestates[t] as ObjectState, t.GetState()), false);
                    }
                }
                else if (movestates.Count > 1)
                {
                    MultipleOperation p = new MultipleOperation();
                    foreach (IStateObject t in movestates.Keys)
                    {
                        p.l.Add(new StateOperation(t, movestates[t] as ObjectState, t.GetState()));
                    }
                    parent.Undo.Push(p, false);
                }
                movestates.Clear();
                moveitem = null;
                movelist = null;
                break;

            case MouseAction.Select:
                parent.SelectedObjects.Clear();
                parent.SelectInRectangle(selrect);
                parent.cview.InvalidatePage(selrect);
                selrect = Rectangle.Empty;
                break;
            }
            action = MouseAction.None;
        }
Пример #6
0
        public override void MouseDown(int x, int y, MouseButtons b, Keys modif, int realx, int realy)
        {
            // Left mouse button

            if (action != MouseAction.None)
            {
                return;
            }

            if (b == MouseButtons.Left)
            {
                if (current_operation == MouseOperation.DrawComment || current_operation == MouseOperation.DrawPackage)
                {
                    switch (current_operation)
                    {
                    case MouseOperation.DrawComment:
                        moveitem = GuiElementFactory.CreateMemo(parent, x, y);
                        break;

                    case MouseOperation.DrawPackage:
                        moveitem = GuiElementFactory.CreatePackage(parent, x, y);
                        break;
                    }

                    first_move = true;
                    moveux     = 0;
                    moveuy     = 0;
                    action     = MouseAction.Move;
                }
                else if ((modif & Keys.Control) == Keys.Control || current_operation == MouseOperation.DrawConnection)
                {
                    conn_item = parent.FindItem(x, y, out moveux, out moveuy, true) as IAcceptConnection;
                    if (conn_item == null)
                    {
                        action = MouseAction.Scroll;
                        selx   = x;
                        sely   = y;
                        return;
                    }

                    int   ux;
                    float uy;
                    conn_item.coord_nearest(x, y, out ux, out uy);
                    action = MouseAction.CreateConnection;

                    conn = new GuiConnection(new GuiConnectionPoint(conn_item, ux, uy, 0), new GuiConnectionPoint(x, y, 1), conn_type, parent, conn_type == UmlRelationType.Attachment ? GuiConnectionStyle.Line : conn_style);
                    conn.first.item.coord_nearest(x, y, out conn.first.ux, out conn.first.uy);
                    conn.first.UpdatePosition(true);
                    conn.DoCreationFixup();
                    conn.InvalidateTemporary();
                    conn.Invalidate();
                }
                else if ((modif & Keys.Shift) == Keys.Shift)
                {
                    GuiObject obj = parent.FindItem(x, y, false);
                    if (obj != null)
                    {
                        parent.SelectedObjects.Add(obj);
                        obj.Invalidate();
                    }
                }
                else
                {
                    //   Left button click:
                    //      select
                    //      move, move multiple

                    GuiObject s = parent.FindItem(x, y, out moveux, out moveuy, false);
                    if (s == null)
                    {
                        parent.SelectedObjects.Clear();
                        action = MouseAction.Select;
                        selx   = x;
                        sely   = y;
                        return;
                    }

                    if (!s.selected)
                    {
                        parent.SelectedObjects.Clear();
                        parent.SelectedObjects.Add(s);
                    }

                    // deciding: to move, or not ...

                    moveitem = null;
                    movelist = null;
                    movestates.Clear();
                    original_selected = null;
                    GuiObject t = parent.FindItem(x, y, out moveux, out moveuy, true);
                    if (t != null)
                    {
                        if (t is IMoveRedirect)
                        {
                            if (t.selected)
                            {
                                original_selected = t;
                            }
                            moveitem = (t as IMoveRedirect).MoveRedirect(ref moveux, ref moveuy);
                        }
                        else if (t is IMoveMultiple && (t as IMoveMultiple).CanMoveInGroup)
                        {
                            movelist = new ArrayList();
                            if (!t.selected)
                            {
                                movelist.Add(t);
                            }
                            foreach (GuiObject o in parent.SelectedObjects)
                            {
                                if (o is IMoveMultiple && (o as IMoveMultiple).CanMoveInGroup)
                                {
                                    movelist.Add(o);
                                }
                            }
                            selx = x;
                            sely = y;
                        }
                        else if (t is IMoveable && (t as IMoveable).IsMoveable(x, y))
                        {
                            moveitem = t as IMoveable;
                        }

                        if (moveitem != null || movelist != null)
                        {
                            first_move = true;
                            action     = MouseAction.Move;
                        }
                        else if (t is IClickable)
                        {
                            (t as IClickable).LeftClick(false, x, y);
                        }
                    }
                }
            }
            else if (b == MouseButtons.Right)
            {
                ISelectable obj = parent.FindItem(x, y, true) as ISelectable;
                if (obj != null)
                {
                    if (obj is IDropMenu)
                    {
                        parent.SelectedObjects.Clear();
                        parent.SelectedObjects.Add(obj as GuiObject);

                        System.Windows.Forms.ContextMenu m = new ContextMenu();
                        (obj as IDropMenu).AddMenuItems(m, x, y);
                        if (m.MenuItems.Count > 0)
                        {
                            m.Show(parent.cview, new Point(realx, realy));
                        }
                    }
                }
                else
                {
                    action         = MouseAction.Scroll;
                    Cursor.Current = Cursors.Hand;
                    selx           = x;
                    sely           = y;
                    menurealx      = realx;
                    menurealy      = realy;
                    first_move     = true;
                }
            }
        }
Пример #7
0
 public ConnectionStateLine(GuiConnection c)
 {
     conn = c;
 }