Beispiel #1
0
 // fills gui_objects, AroundObjects (active_objects has been filled during XML load)
 private void PreLoadRegisterObjects(GuiObject o)
 {
     if (o is IHasID)
     {
         IHasID p = o as IHasID;
         if (p.ID == null)
         {
             throw new ArgumentException("no id");
         }
         if (gui_objects.ContainsKey(p.ID))
         {
             throw new ArgumentException("two identical ids");
         }
         gui_objects[p.ID] = o;
     }
     if (o is IAroundObject)
     {
         AroundObjects.Add(o);
     }
     if (o.children != null)
     {
         foreach (GuiBound b in o.children)
         {
             PreLoadRegisterObjects(b);
         }
     }
 }
Beispiel #2
0
        // processes main menu operation
        public override void DoOperation(UMLDes.GUI.View.EditOperation op)
        {
            int i;

            switch (op)
            {
            case EditOperation.Delete:
                i = 0;
                while (i < SelectedObjects.Count)
                {
                    GuiObject   obj = SelectedObjects[i];
                    IRemoveable o   = obj as IRemoveable;
                    if (o != null && Destroy(o))
                    {
                        SelectedObjects.Remove(obj);
                    }
                    else
                    {
                        i++;
                    }
                }
                break;

            case EditOperation.SelectAll:
                foreach (GuiObject o in active_objects)
                {
                    SelectedObjects.Add(o);
                }
                break;

            case EditOperation.SelectNone:
                SelectedObjects.Clear();
                break;
            }
        }
Beispiel #3
0
 public override void UpdateCoords(GuiObject orig)
 {
     if (orig == root)
     {
         (root as IUniversalCoords).translate_coords(ref ux_bind, ref uy_bind);
     }
 }
Beispiel #4
0
        public void AddObject(GuiItem item, string name_base)
        {
            item.parent = this;
            if (item is INeedRefresh)
            {
                RefreshObject((INeedRefresh)item);
            }
            item.id = RegisterItemID(name_base, item);
            item.Invalidate();
            Undo.Push(new CreateOperation((IRemoveable)item), false);

            // add relations
            if (item is GuiClass)
            {
                GuiClass cl = (GuiClass)item;
                for (int i = 0; i < active_objects.Count; i++)
                {
                    GuiObject obj = (GuiObject)active_objects[i];
                    if (obj is GuiClass)
                    {
                        foreach (UmlRelation rel in RelationsHelper.GetRelations(((GuiClass)obj).st, proj.model))
                        {
                            if (rel.dest == cl.st || rel.src == cl.st)
                            {
                                NewRelation(rel);
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
 public override void UpdateCoords(GuiObject orig)
 {
     if (orig == item)
     {
         item.translate_coords(ref ux, ref uy);
     }
 }
Beispiel #6
0
 public void Remove( GuiObject obj )
 {
     if( !obj.selected )
         throw new ArgumentException( "item is not from the collection" );
     obj.selected = false;
     obj.SelectionChanged();
     obj.Invalidate();
     objs.Remove( obj );
 }
Beispiel #7
0
 public int Add( GuiObject value )
 {
     if( objs.Contains( value ) )
         return 0;
     if( value == null || value.selected )
         throw new ArgumentException( "wrong item for collection" );
     value.selected = true;
     value.SelectionChanged();
     value.Invalidate();
     return objs.Add( value );
 }
Beispiel #8
0
 public void Remove(GuiObject obj)
 {
     if (!obj.selected)
     {
         throw new ArgumentException("item is not from the collection");
     }
     obj.selected = false;
     obj.SelectionChanged();
     obj.Invalidate();
     objs.Remove(obj);
 }
Beispiel #9
0
        public GuiBoundStringObject(string s, GuiObject pt, int x, int y, int ux, float uy, bool hidden)
        {
            root        = pt;
            parent      = root.parent;
            pos_x       = x;
            pos_y       = y;
            ux_bind     = ux;
            uy_bind     = uy;
            this.hidden = hidden;

            RecalculatePosition();
            Text = s;
        }
Beispiel #10
0
 public int Add(GuiObject value)
 {
     if (objs.Contains(value))
     {
         return(0);
     }
     if (value == null || value.selected)
     {
         throw new ArgumentException("wrong item for collection");
     }
     value.selected = true;
     value.SelectionChanged();
     value.Invalidate();
     return(objs.Add(value));
 }
Beispiel #11
0
        private void UpdateConnections()
        {
            // save current connections
            Hashtable ht = new Hashtable();

            foreach (GuiObject obj in active_objects)
            {
                if (obj is GuiConnection)
                {
                    string id = ((GuiConnection)obj).relation_id;
                    if (id != null)
                    {
                        ht[id] = obj;
                    }
                }
            }

            // add new relations
            for (int i = 0; i < active_objects.Count; i++)
            {
                GuiObject obj = (GuiObject)active_objects[i];
                if (obj is GuiClass)
                {
                    foreach (UmlRelation rel in RelationsHelper.GetRelations(((GuiClass)obj).st, proj.model))
                    {
                        if (ht.ContainsKey(rel.ID))
                        {
                            ((GuiConnection)ht[rel.ID]).AdjustRelation(rel);
                            ht.Remove(rel.ID);
                        }
                        else
                        {
                            NewRelation(rel);
                        }
                    }
                }
            }

            // remove old
            foreach (GuiConnection old_conn in ht.Values)
            {
                Destroy((IRemoveable)old_conn);
            }
        }
Beispiel #12
0
        void PaintChildren(Graphics g, Rectangle r, int offx, int offy, IDrawable dr, Rectangle piece)
        {
            GuiObject o = dr as GuiObject;

            foreach (GuiBound b in o.children)
            {
                if (!b.Hidden)
                {
                    if (b.NeedRepaint(piece))
                    {
                        b.Paint(g, r, offx, offy);
                    }
                    if (b.children != null)
                    {
                        PaintChildren(g, r, offx, offy, b, piece);
                    }
                }
            }
        }
Beispiel #13
0
        // searchs for the children under the point (x,y)
        GuiObject FindItemInChildren(GuiObject obj, int x, int y, out int ux, out float uy)
        {
            ux = 0; uy = 0f;

            foreach (GuiObject s in obj.children)
            {
                if (s.children != null && !s.Hidden)
                {
                    GuiObject searched = FindItemInChildren(s, x, y, out ux, out uy);
                    if (searched != null)
                    {
                        return(searched);
                    }
                }
                if (s is ISelectable && !s.Hidden && (s as ISelectable).HasPoint(x, y, out ux, out uy))
                {
                    return(s);
                }
            }

            return(null);
        }
        private bool MouseMoveAction(int x, int y, MouseButtons b)
        {
            switch (action)
            {
            case MouseAction.Select:
                if (selrect != Rectangle.Empty)
                {
                    parent.cview.InvalidatePage(selrect);
                }

                selrect.X      = Math.Min(x, selx);
                selrect.Y      = Math.Min(y, sely);
                selrect.Width  = Math.Abs(x - selx);
                selrect.Height = Math.Abs(y - sely);
                parent.cview.InvalidatePage(selrect);
                break;

            case MouseAction.Move:

                // on first move
                if (first_move)
                {
                    if (original_selected != null)
                    {
                        parent.SelectedObjects.Remove(original_selected);
                        original_selected = null;
                    }
                    if (moveitem != null)
                    {
                        if (moveitem is IStateObject)
                        {
                            movestates[moveitem] = (moveitem as IStateObject).GetState();
                        }
                        if (!(moveitem as GuiObject).selected)
                        {
                            parent.SelectedObjects.Clear();
                            parent.SelectedObjects.Add(moveitem as GuiObject);
                        }
                    }
                    else
                    {
                        parent.SelectedObjects.Clear();
                        foreach (GuiObject t in movelist)
                        {
                            parent.SelectedObjects.Add(t);
                        }
                        foreach (GuiObject t in movelist)
                        {
                            if (t is IStateObject)
                            {
                                movestates[t] = (t as IStateObject).GetState();
                            }
                        }
                    }
                    AddAssociatedObjects();
                    first_move = false;
                }

                // usual move
                if (moveitem != null)
                {
                    moveitem.Moving(x, y, ref moveux, ref moveuy);
                }
                else
                {
                    foreach (IMoveMultiple i in movelist)
                    {
                        i.ShiftShape(x - selx, y - sely);
                    }
                    selx = x;
                    sely = y;
                }
                break;

            case MouseAction.Scroll:
                parent.cview.AdjustPageCoords(selx - x, sely - y);
                first_move = false;
                break;

            case MouseAction.CreateConnection:
                conn.Invalidate();
                conn.InvalidateTemporary();

                conn.second.item = parent.FindItem(x, y, out moveux, out moveuy, true) as IAcceptConnection;
                if (conn.second.item == null || conn.second.item == conn.first.item)
                {
                    conn.second.x    = x;
                    conn.second.y    = y;
                    conn.second.item = null;
                }
                else
                {
                    conn.second.item.coord_nearest(x, y, out conn.second.ux, out conn.second.uy);
                    conn.second.UpdatePosition(true);
                }
                conn.DoCreationFixup();
                conn.InvalidateTemporary();
                conn.Invalidate();
                break;
            }
            return(action != MouseAction.Scroll);
        }
Beispiel #15
0
 public virtual void UpdateCoords(GuiObject orig)
 {
 }
Beispiel #16
0
        // searchs for the children under the point (x,y)
        GuiObject FindItemInChildren( GuiObject obj, int x, int y, out int ux, out float uy )
        {
            ux = 0; uy = 0f;

            foreach( GuiObject s in obj.children ) {
                if( s.children != null && !s.Hidden	) {
                    GuiObject searched = FindItemInChildren( s, x, y, out ux, out uy );
                    if( searched != null )
                        return searched;
                }
                if( s is ISelectable && !s.Hidden && (s as ISelectable).HasPoint( x, y, out ux, out uy ) )
                    return s;
            }

            return null;
        }
Beispiel #17
0
 public virtual void UpdateCoords( GuiObject orig )
 {
 }
Beispiel #18
0
 public GuiBoundStereotype(string s, GuiObject pt, int x, int y, int ux, float uy, bool hidden) : base(s, pt, x, y, ux, uy, hidden)
 {
 }
Beispiel #19
0
 // fills gui_objects, AroundObjects (active_objects has been filled during XML load)
 private void PreLoadRegisterObjects( GuiObject o )
 {
     if( o is IHasID ) {
         IHasID p = o as IHasID;
         if( p.ID == null )
             throw new ArgumentException( "no id" );
         if( gui_objects.ContainsKey( p.ID ) )
             throw new ArgumentException( "two identical ids" );
         gui_objects[p.ID] = o;
     }
     if( o is IAroundObject )
         AroundObjects.Add( o );
     if( o.children != null )
         foreach( GuiBound b in o.children )
             PreLoadRegisterObjects( b );
 }
Beispiel #20
0
 public override void UpdateCoords( GuiObject orig )
 {
     if( orig == item )
         item.translate_coords( ref ux, ref uy );
 }
        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;
                }
            }
        }
        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;
        }
 public override void UpdateCoords( GuiObject orig )
 {
     if( orig == root )
         (root as IUniversalCoords).translate_coords( ref ux_bind, ref uy_bind );
 }
Beispiel #24
0
 // Unlinks object from diagram
 public void UnregisterObject( string id, GuiObject o )
 {
     gui_objects.Remove( id );
     active_objects.Remove( o );
     AroundObjects.Remove( o );
 }
Beispiel #25
0
        public GuiObject FindItem(int x, int y, out int dx, out float dy, bool direct_search)
        {
            GuiObject res = null;

            // search in selected GuiObjects
            if (direct_search)
            {
                foreach (GuiObject b in SelectedObjects)
                {
                    if (b.children != null && !b.Hidden)
                    {
                        res = FindItemInChildren(b, x, y, out dx, out dy);
                        if (res != null)
                        {
                            return(res);
                        }
                    }
                    if ((b is ISelectable) && !b.Hidden && (b as ISelectable).HasPoint(x, y, out dx, out dy))
                    {
                        return(b);
                    }
                }
            }
            else
            {
                foreach (GuiObject i in SelectedObjects)
                {
                    GuiObject b = i;
                    do
                    {
                        if (b.children != null)
                        {
                            foreach (GuiObject sel in b.children)
                            {
                                if (sel is ISelectable && !sel.Hidden && (sel as ISelectable).HasPoint(x, y, out dx, out dy))
                                {
                                    return(sel);
                                }
                            }
                        }
                        b = (b is GuiBound) ? (b as GuiBound).root : null;
                    } while(b != null);
                }
            }

            // search in other
            for (int i = active_objects.Count - 1; i >= 0; i--)
            {
                GuiObject p = (GuiObject)active_objects[i];
                if (p.children != null && !p.Hidden)
                {
                    res = FindItemInChildren(p, x, y, out dx, out dy);
                    if (res != null)
                    {
                        if (direct_search)
                        {
                            return(res);
                        }
                        else
                        {
                            return(p);
                        }
                    }
                }
                if (p is ISelectable && !p.Hidden && (p as ISelectable).HasPoint(x, y, out dx, out dy))
                {
                    return(p);
                }
            }
            dx = 0;
            dy = 0f;
            return(null);
        }
        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;
        }
 public GuiBoundString( string s, GuiObject pt, int x, int y, int ux, float uy, bool hidden )
     : base(s, pt, x, y, ux, uy, hidden)
 {
 }
        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;
                }
            }
        }
Beispiel #29
0
 // Unlinks object from diagram
 public void UnregisterObject(string id, GuiObject o)
 {
     gui_objects.Remove(id);
     active_objects.Remove(o);
     AroundObjects.Remove(o);
 }
        private bool MouseMoveAction( int x, int y, MouseButtons b )
        {
            switch( action ) {
                case MouseAction.Select:
                    if( selrect != Rectangle.Empty )
                        parent.cview.InvalidatePage( selrect );

                    selrect.X = Math.Min( x, selx );
                    selrect.Y = Math.Min( y, sely );
                    selrect.Width = Math.Abs( x - selx );
                    selrect.Height = Math.Abs( y - sely );
                    parent.cview.InvalidatePage( selrect );
                    break;
                case MouseAction.Move:

                    // on first move
                    if( first_move ) {
                        if( original_selected != null ) {
                            parent.SelectedObjects.Remove( original_selected );
                            original_selected = null;
                        }
                        if( moveitem != null ) {
                            if( moveitem is IStateObject )
                                movestates[moveitem] = (moveitem as IStateObject).GetState();
                            if( !(moveitem as GuiObject).selected ) {
                                parent.SelectedObjects.Clear();
                                parent.SelectedObjects.Add( moveitem as GuiObject );
                            }
                        } else {
                            parent.SelectedObjects.Clear();
                            foreach( GuiObject t in movelist )
                                parent.SelectedObjects.Add( t );
                            foreach( GuiObject t in movelist )
                                if( t is IStateObject )
                                    movestates[t] = (t as IStateObject).GetState();
                        }
                        AddAssociatedObjects();
                        first_move = false;
                    }

                    // usual move
                    if( moveitem != null ) {
                        moveitem.Moving( x, y, ref moveux, ref moveuy );

                    } else {
                        foreach( IMoveMultiple i in movelist ) {
                            i.ShiftShape( x - selx, y - sely );
                        }
                        selx = x;
                        sely = y;
                    }
                    break;
                case MouseAction.Scroll:
                    parent.cview.AdjustPageCoords( selx-x, sely-y );
                    first_move = false;
                    break;
                case MouseAction.CreateConnection:
                    conn.Invalidate();
                    conn.InvalidateTemporary();

                    conn.second.item = parent.FindItem( x, y, out moveux, out moveuy, true ) as IAcceptConnection;
                    if( conn.second.item == null || conn.second.item == conn.first.item ) {
                        conn.second.x = x;
                        conn.second.y = y;
                        conn.second.item = null;
                    } else {
                        conn.second.item.coord_nearest( x, y, out conn.second.ux, out conn.second.uy );
                        conn.second.UpdatePosition( true );
                    }
                    conn.DoCreationFixup();
                    conn.InvalidateTemporary();
                    conn.Invalidate();
                    break;
            }
            return action != MouseAction.Scroll;
        }
        public GuiBoundStringObject( string s, GuiObject pt, int x, int y, int ux, float uy, bool hidden )
        {
            root = pt;
            parent = root.parent;
            pos_x = x;
            pos_y = y;
            ux_bind = ux;
            uy_bind = uy;
            this.hidden = hidden;

            RecalculatePosition();
            Text = s;
        }