Exemple #1
0
 void graphArea_EdgeSelected(object sender, EdgeSelectedEventArgs args)
 {
     if (args.MouseArgs.LeftButton == MouseButtonState.Pressed && _opMode == EditorOperationMode.Delete)
     {
         graphArea.LogicCore.Graph.RemoveEdge(args.EdgeControl.Edge as DataEdge);
         graphArea.RemoveEdge(args.EdgeControl.Edge as DataEdge);
     }
 }
Exemple #2
0
        private void EdgeSelectedAction(object sender, GraphX.Controls.Models.EdgeSelectedEventArgs args)
        {
            this.edgeControl = args.EdgeControl;

            this.edgeControl.PreviewMouseUp += this.OnEdgeMouseUp;
            this.zoomControl.MouseMove      += this.OnEdgeMouseMove;

            this.EdgeSelected?.Invoke(this,
                                      new EventArguments.EdgeSelectedEventArgs {
                Edge = this.edgeControl.GetDataEdge <EdgeViewModel>()
            });

            var dataEdge      = this.edgeControl.GetDataEdge <EdgeViewModel>();
            var mousePosition = args.MouseArgs.GetPosition(this.graphArea).ToGraphX();

            // Adding new routing point.
            if (args.MouseArgs.LeftButton == MouseButtonState.Pressed)
            {
                this.HandleRoutingPoints(dataEdge, mousePosition);
            }

            if (args.MouseArgs.RightButton == MouseButtonState.Pressed)
            {
                this.zoomControl.MouseMove  -= this.OnEdgeMouseMove;
                args.EdgeControl.ContextMenu = new ContextMenu();
                var mi = new MenuItem {
                    Header = "Delete item", Tag = args.EdgeControl
                };
                mi.Click += this.MenuItemClickEdge;
                args.EdgeControl.ContextMenu.Items.Add(mi);
                args.EdgeControl.ContextMenu.IsOpen = true;
                if (dataEdge.RoutingPoints == null)
                {
                    return;
                }

                var isRoutingPoint = dataEdge.RoutingPoints.Where(point => Geometry.GetDistance(point, mousePosition).CompareTo(3) <= 0).ToArray().Length != 0;

                // Adding MenuItem to routing point in order to delete it.
                if (isRoutingPoint)
                {
                    var routingPoint = Array.Find(dataEdge.RoutingPoints, point => Geometry.GetDistance(point, mousePosition).CompareTo(3) <= 0);
                    var mi2          = new MenuItem {
                        Header = "Delete routing point", Tag = routingPoint
                    };
                    mi2.Click += this.MenuItemClickRoutingPoint;
                    args.EdgeControl.ContextMenu.Items.Add(mi2);
                }
            }
        }
Exemple #3
0
        private void EdgeSelectedAction(object sender, GraphX.Controls.Models.EdgeSelectedEventArgs args)
        {
            this.ctrlEdg = args.EdgeControl;

            this.ctrlEdg.PreviewMouseUp += this.OnEdgeMouseUp;
            this.zoomControl.MouseMove  += this.OnEdgeMouseMove;

            this.EdgeSelected?.Invoke(this,
                                      new EdgeSelectedEventArgs {
                Edge = this.ctrlEdg.GetDataEdge <EdgeViewModel>()
            });

            if (args.MouseArgs.RightButton == MouseButtonState.Pressed)
            {
                args.EdgeControl.ContextMenu = new ContextMenu();
                var mi = new MenuItem {
                    Header = "Delete item", Tag = args.EdgeControl
                };
                mi.Click += this.MenuItemClickEdge;
                args.EdgeControl.ContextMenu.Items.Add(mi);
                args.EdgeControl.ContextMenu.IsOpen = true;
            }
        }
Exemple #4
0
        private void EdgeSelectedAction(object sender, GraphX.Controls.Models.EdgeSelectedEventArgs args)
        {
            this.edgeControl = args.EdgeControl;

            this.edgeControl.PreviewMouseUp += this.OnEdgeMouseUp;
            this.zoomControl.MouseMove      += this.OnEdgeMouseMove;

            this.EdgeSelected?.Invoke(this,
                                      new EventArguments.EdgeSelectedEventArgs {
                Edge = this.edgeControl.GetDataEdge <EdgeViewModel>()
            });

            var dataEdge      = this.edgeControl.GetDataEdge <EdgeViewModel>();
            var mousePosition = args.MouseArgs.GetPosition(this.graphArea).ToGraphX();

            // Adding new routing point.
            if (args.MouseArgs.LeftButton == MouseButtonState.Pressed)
            {
                this.HandleRoutingPoints(dataEdge, mousePosition);
            }

            if (args.MouseArgs.RightButton == MouseButtonState.Pressed)
            {
                this.zoomControl.MouseMove -= this.OnEdgeMouseMove;
                var edgeControl = args.EdgeControl;
                edgeControl.ContextMenu = new ContextMenu();
                var mi = new MenuItem {
                    Header = "Delete item", Tag = edgeControl
                };
                if (edgeControl.Source.GetDataVertex <NodeViewModel>().IsVirtual || edgeControl.Target.GetDataVertex <NodeViewModel>().IsVirtual)
                {
                    // TODO: real delete with virtual edge
                    mi.Click += (senderObj, eventArgs) => MenuItemDeleteClickedOnVirtualEdge(edgeControl, EventArgs.Empty);
                }
                else
                {
                    mi.Click += this.MenuItemClickEdge;
                    var miSource = new MenuItem {
                        Header = "Unpin Source", Tag = edgeControl
                    };
                    miSource.Click += (senderObj, eventArgs) => UnpinEdgeFromVertex(edgeControl, true);
                    var miTarget = new MenuItem {
                        Header = "Unpin Target", Tag = edgeControl
                    };
                    miTarget.Click += (senderObj, eventArgs) => UnpinEdgeFromVertex(edgeControl, false);
                    edgeControl.ContextMenu.Items.Add(miSource);
                    edgeControl.ContextMenu.Items.Add(miTarget);
                }

                edgeControl.ContextMenu.Items.Add(mi);
                edgeControl.ContextMenu.IsOpen = true;

                if (dataEdge.RoutingPoints == null)
                {
                    return;
                }
                var isRoutingPoint = dataEdge.RoutingPoints.Where(point => Geometry.GetDistance(point, mousePosition).CompareTo(3) <= 0).ToArray().Length != 0;

                // Adding MenuItem to routing point in order to delete it.
                if (isRoutingPoint)
                {
                    var routingPoint = Array.Find(dataEdge.RoutingPoints, point => Geometry.GetDistance(point, mousePosition).CompareTo(3) <= 0);
                    var mi2          = new MenuItem {
                        Header = "Delete routing point", Tag = routingPoint
                    };
                    mi2.Click += this.MenuItemClickRoutingPoint;
                    edgeControl.ContextMenu.Items.Add(mi2);
                }
            }
        }
        private void GgAreaEdgeSelected(object sender, EdgeSelectedEventArgs args)
        {
            if ((args.MouseArgs.LeftButton == MouseButtonState.Pressed)
                && (operationMode == SenteceGraphOperationMode.Delete))
            {
                var edge = args.EdgeControl.Edge as WordEdge;
                if (edge != null)
                {
                    GgArea.RemoveEdge(edge, true);
                    var targetVertex = edge.Target;
                    targetVertex.WordWrapper.SetAttributeByName(
                        CurrentConfiguration.Edge.SourceVertexAttributeName,
                        "0");
                    targetVertex.WordWrapper.SetAttributeByName(
                        CurrentConfiguration.Edge.LabelAttributeName,
                        string.Empty);

                    viewModel.InvalidateCommands();
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            //Customize Zoombox a bit
            //Set minimap (overview) window to be visible by default
            ZoomControl.SetViewFinderVisibility(zoomctrl, Visibility.Visible);
            //Set Fill zooming strategy so whole graph will be always visible
            zoomctrl.ZoomToFill();

            var modes = new List<string>() { "By hopes", "By speed" };
            protocols = new List<string>() { "TCP", "UDP" };
            routingModeBox.ItemsSource = modes;
            routingModeBox.SelectedItem = modes[0];
            protocolBox.ItemsSource = protocols;
            protocolBox.SelectedItem = protocols[0];

            //Lets setup GraphArea settings
            GraphAreaExample_Setup();

            zoomctrl.MouseRightButtonUp += ((o, s) => { VertexInputBox.Visibility = Visibility.Visible; });

            //Vertex settings
            Area.VertexSelected += ((h, j) => {
                _selectedVertexEvent = j;
                _selectedVertex = (DataVertex)j.VertexControl.Vertex;
                VertexBox.Visibility = Visibility.Visible; });

            Area.EdgeSelected += ((h, j) => {
                _selectedEdgeEvent = j;
                _selectedEdge = (DataEdge)j.EdgeControl .Edge;
                EdgeBox.Visibility = Visibility.Visible;
            });

            Area.EdgeMouseEnter += ((h,j) =>
            {

                foreach (var item in logicCore.Graph.Edges)
                {
                    if (item.Equals(j.EdgeControl.Edge))
                    {
                        j.EdgeControl.ToolTip = item.GetEdgeType();
                    }
                }

            });

            //Vertex tooltip
            Area.VertexMouseEnter += ((h,j) =>
            {
                foreach(var item in logicCore.Graph.Vertices)
                {
                    if(item.Text == j.VertexControl.Vertex.ToString())
                    {
                        if (item.IsEnabled)
                        {
                            j.VertexControl.ToolTip = item.Text + "\n\n" + item.Routing;
                            StatsText.Text = "";
                            StatsText.Text += "  " + item.Text + Environment.NewLine;
                            StatsText.Text += "  Recieved TCP" + Environment.NewLine + "  control packets: " + item.RecievedTCPControlPackets + Environment.NewLine;
                            StatsText.Text += "  Recieved TCP" + Environment.NewLine + "  data packets: " + item.RecievedTCPDataPackets + Environment.NewLine;
                            StatsText.Text += "  Sended TCP" + Environment.NewLine + "  control packets: " + item.SendedTCPControlPackets + Environment.NewLine;
                            StatsText.Text += "  Sended TCP" + Environment.NewLine + "  data packets: " + item.SendedTCPDataPackets + Environment.NewLine;
                            StatsText.Text += "  Recieved UDP" + Environment.NewLine + "  data packets: " + item.RecivedUDPPackets + Environment.NewLine;
                            StatsText.Text += "  Sended UDP" + Environment.NewLine + "  data packets: " + item.SendedUDPPackets + Environment.NewLine;
                            CurrentIterBox.Text = "  Current iteration: " + Environment.NewLine + "  " + _iterationNumber;
                        }
                        else
                            j.VertexControl.ToolTip = item.Text;
                    }
                }
            });

            Area.VertexMouseLeave += ((h,j) => { StatsText.Text = "";
                CurrentIterBox.Text = "";
            });

            gg_but_randomgraph.Click += gg_but_randomgraph_Click;

            gg_but_relayout.Click += gg_but_relayout_Click;

            Loaded += MainWindow_Loaded;

            Graph = NetworkGraph.GetDefaultGraph();

            SearchShortestWay(true);
        }