Example #1
0
 private void on_userList_button_release_event(object o, Gtk.ButtonReleaseEventArgs args)
 {
     if (args.Event.Button == 3) {
         UserMenu menu = new UserMenu(network, GetSelectedNode());
         menu.Popup();
     }
 }
Example #2
0
 void HandleActionsButtonClicked(object sender, EventArgs args)
 {
     var menu = new UserMenu(network, node);
     menu.Popup((Widget)sender);
 }
Example #3
0
        private void base_ButtonPressEvent(object sender, Gtk.ButtonPressEventArgs args)
        {
            Gdk.EventButton eb     = args.Event;
            double          mouseX = eb.X;
            double          mouseY = eb.Y;

            DeviceToUser(ref mouseX, ref mouseY);
            if (debug)
            {
                Console.Out.WriteLine("Button Pressed {0}: user coords {1},{2}", eb.Button, mouseX, mouseY);
            }
            PointD    thePoint          = new PointD(mouseX, mouseY);
            NodeGroup firstNodeGroupHit = null;
            Node      firstNodeHit      = null;

            foreach (Network network in networkZOrder)
            {
                Rectangle networkRect = (Rectangle)network.Properties["rect"];
                if (Inside(thePoint, networkRect))
                {
                    if (debug)
                    {
                        Console.Out.WriteLine("Click inside network {0}", network.NetworkName);
                    }
                    Hashtable nodegroups = (Hashtable)network.Properties["nodegroups"];
                    foreach (NodeGroup ng in nodegroups.Values)
                    {
                        //PointD ngPosition = new PointD (ng.Position.X + networkRect.X,
                        //                              ng.Position.Y + networkRect.Y);
                        if (Inside(thePoint, ng.Position, ng.Dimension))
                        {
                            if (debug)
                            {
                                Console.Out.WriteLine("Click inside group {0}", ng.Name);
                            }
                            firstNodeGroupHit = ng;
                            foreach (Node n in ng.Nodes)
                            {
                                PointD np = (PointD)n.Properties["position"];
                                //	np = new PointD (np.X + ngPosition.X,
                                //	                 np.Y + ngPosition.Y);
                                if (Inside(thePoint, np, AvatarSizeD))
                                {
                                    firstNodeHit = n;
                                    if (debug)
                                    {
                                        Console.Out.WriteLine("Click inside node {0}", n);
                                    }
                                    break;
                                    // clicked node n
                                }
                            }
                            break;
                            // click in ng but not any node
                        }
                    }
                    break;
                    // click in network but not any ng
                }
            }

            if (eb.Button == 1 | eb.Button == 3)
            {
                selectedNode = firstNodeHit;

                if (SelectedNodeChanged != null)
                {
                    SelectedNodeChanged(selectedNode);
                }
            }

            switch (eb.Button)
            {
            case 1:
                selectedGroup = firstNodeGroupHit;

                if (selectedGroup != null)
                {
                    this.nodeDragging = true;
                    nodeDraggingLastX = eb.X;
                    nodeDraggingLastY = eb.Y;

                    // we're dragging...
                    this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Plus);
                }

                if (selectedNode != null)
                {
                    if (eb.Type == Gdk.EventType.TwoButtonPress)
                    {
                        ResetDrag();
                        if (NodeDoubleClicked != null)
                        {
                            NodeDoubleClicked(selectedNode);
                        }
                    }
                }

                break;

            case 3:
                if (firstNodeGroupHit == null)
                {
                    // clicked on map background
                    Menu mapMenu = (Menu)Runtime.UIManager.GetWidget("/MapPopupMenu");
                    mapMenu.Popup();
                }
                else
                {
                    if (firstNodeHit != null)
                    {
                        UserMenu userMenu = new UserMenu(firstNodeHit.Network, firstNodeHit);
                        userMenu.Popup();
                    }
                }
                break;
            }
        }
        private void base_ButtonPressEvent(object sender, Gtk.ButtonPressEventArgs args)
        {
            Gdk.EventButton eb = args.Event;
            double mouseX = eb.X;
            double mouseY = eb.Y;
            DeviceToUser(ref mouseX, ref mouseY);
            if (debug)
                Console.Out.WriteLine("Button Pressed {0}: user coords {1},{2}", eb.Button, mouseX, mouseY);
            PointD thePoint = new PointD(mouseX, mouseY);
            NodeGroup firstNodeGroupHit = null;
            Node firstNodeHit = null;

            foreach (Network network in networkZOrder) {
                Rectangle networkRect = (Rectangle)network.Properties["rect"];
                if (Inside(thePoint, networkRect)) {
                    if (debug)
                        Console.Out.WriteLine("Click inside network {0}", network.NetworkName);
                    Hashtable nodegroups = (Hashtable)network.Properties["nodegroups"];
                    foreach (NodeGroup ng in nodegroups.Values) {
                        //PointD ngPosition = new PointD (ng.Position.X + networkRect.X,
                        //                              ng.Position.Y + networkRect.Y);
                        if (Inside(thePoint, ng.Position, ng.Dimension)) {
                            if (debug)
                                Console.Out.WriteLine("Click inside group {0}", ng.Name);
                            firstNodeGroupHit = ng;
                            foreach (Node n in ng.Nodes) {
                                PointD np = (PointD)n.Properties["position"];
                                //	np = new PointD (np.X + ngPosition.X,
                                //	                 np.Y + ngPosition.Y);
                                if (Inside(thePoint, np, AvatarSizeD)) {
                                    firstNodeHit = n;
                                    if (debug)
                                        Console.Out.WriteLine("Click inside node {0}", n);
                                    break;
                                    // clicked node n
                                }
                            }
                            break;
                            // click in ng but not any node
                        }

                    }
                    break;
                    // click in network but not any ng
                }
            }

            if (eb.Button == 1 | eb.Button == 3) {
                selectedNode = firstNodeHit;

                if (SelectedNodeChanged != null)
                    SelectedNodeChanged(selectedNode);
            }

            switch (eb.Button) {
            case 1:
                selectedGroup = firstNodeGroupHit;

                if (selectedGroup != null) {
                    this.nodeDragging = true;
                    nodeDraggingLastX = eb.X;
                    nodeDraggingLastY = eb.Y;

                    // we're dragging...
                    this.GdkWindow.Cursor = new Gdk.Cursor(Gdk.CursorType.Plus);
                }

                if (selectedNode != null) {
                    if (eb.Type == Gdk.EventType.TwoButtonPress) {
                        ResetDrag();
                        if (NodeDoubleClicked != null)
                            NodeDoubleClicked(selectedNode);
                    }
                }

                break;

            case 3:
                if (firstNodeGroupHit == null) {
                    // clicked on map background
                    Menu mapMenu = (Menu)Runtime.UIManager.GetWidget("/MapPopupMenu");
                    mapMenu.Popup();

                } else {
                    if (firstNodeHit != null) {
                        UserMenu userMenu = new UserMenu(firstNodeHit.Network, firstNodeHit);
                        userMenu.Popup();
                    }
                }
                break;
            }
        }
Example #5
0
        void HandleActionsButtonClicked(object sender, EventArgs args)
        {
            var menu = new UserMenu(network, node);

            menu.Popup((Widget)sender);
        }
        private void userList_ButtonPressEvent(object o, Gtk.ButtonPressEventArgs args)
        {
            TreePath path;
            if (userList.GetPathAtPos ((int)args.Event.X, (int)args.Event.Y, out path)) {
                userList.Selection.SelectPath (path);
            } else {
                userList.Selection.UnselectAll ();
            }

            var node = GetSelectedNode();

            if (map != null) {
                map.SelectNode(node);
            }

            if (args.Event.Button == 3) {
                if (node != null) {
                    UserMenu menu = new UserMenu(node.Network, node);
                    menu.Popup();
                }
            }
        }