Exemplo n.º 1
0
        private void OnSceneMouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                var position = this.zoomControl.TranslatePoint(e.GetPosition(this.zoomControl), this.graphArea);
                if (this.elementProvider.Element?.InstanceMetatype == Repo.Metatype.Node)
                {
                    this.position = position;
                    this.CreateNewNode(this.elementProvider.Element);
                    this.ElementManipulationDone?.Invoke(this, EventArgs.Empty);
                }

                if (this.elementProvider.Element?.InstanceMetatype == Repo.Metatype.Edge)
                {
                    var vertexData    = new NodeViewModel();
                    var virtualVertex = this.AddVirtualVertexControl(vertexData);
                    if (this.previosVertex != null)
                    {
                        var virtualEdgeData    = new EdgeViewModel(previosVertex.GetDataVertex <NodeViewModel>(), virtualVertex.GetDataVertex <NodeViewModel>());
                        var virtualEdgeControl = new EdgeControl(previosVertex, virtualVertex, virtualEdgeData);
                        this.graphArea.AddEdge(virtualEdgeData, virtualEdgeControl);
                        this.editorManager.DestroyVirtualEdge();
                        this.previosVertex = null;
                        this.ElementManipulationDone?.Invoke(this, EventArgs.Empty);
                    }
                    else
                    {
                        this.editorManager.CreateVirtualEdge(virtualVertex, virtualVertex.GetPosition());
                        this.previosVertex = virtualVertex;
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void UnDo()
        {
            _Edge = new DataEdge(_source, _target);

            _sourceVC = _graph.VertexList.Where(pair => pair.Key == _source).Select(pair => pair.Value).FirstOrDefault();
            _targetVC = _graph.VertexList.Where(pair => pair.Key == _target).Select(pair => pair.Value).FirstOrDefault();

            if (_sourceVC == null || _targetVC == null)
            {
                throw new ArgumentNullException("VertexControl");
            }

            _eCtrl = new EdgeControl(_sourceVC, _targetVC, _Edge)
            {
                ShowArrows = true,
                ShowLabel  = true
            };

            _graph.Graph.AddEdge(_Edge);
            _graph.AddEdge(_Edge, _eCtrl);

            HighlightBehaviour.SetIsHighlightEnabled(_eCtrl, false);

            if (_undoCallback != null)
            {
                _undoCallback.Invoke(_eCtrl);
            }
        }
Exemplo n.º 3
0
        private void CreateEdgeControl(VertexControl vc)
        {
            if (_ecFrom == null)
            {
                _editorManager.CreateVirtualEdge(vc, vc.GetPosition());
                _ecFrom = vc;
                HighlightBehaviour.SetHighlighted(_ecFrom, true);
                return;
            }
            if (_ecFrom == vc)
            {
                return;
            }

            var data = new DataEdge((DataVertex)_ecFrom.Vertex, (DataVertex)vc.Vertex);

            graphArea.LogicCore.Graph.AddEdge(data);
            var ec = new EdgeControl(_ecFrom, vc, data);

            graphArea.InsertEdge(data, ec);

            HighlightBehaviour.SetHighlighted(_ecFrom, false);
            _ecFrom = null;
            _editorManager.DestroyVirtualEdge();
        }
Exemplo n.º 4
0
        public override void Do()
        {
            _Edge = new DataEdge(_source, _target);

            _sourceVC = _graph.VertexList.Where(pair => pair.Key.Id == _source.Id).Select(pair => pair.Value).FirstOrDefault();
            _targetVC = _graph.VertexList.Where(pair => pair.Key.Id == _target.Id).Select(pair => pair.Value).FirstOrDefault();

            if (_sourceVC == null || _targetVC == null)
            {
                throw new ArgumentNullException("Vertex Control");
            }

            _eCtrl = new EdgeControl(_sourceVC, _targetVC, _Edge)
            {
                ShowArrows = true,
                ShowLabel  = true
            };

            _graph.Graph.AddEdge(_Edge);
            _graph.AddEdge(_Edge, _eCtrl);

            if (_callback != null)
            {
                _callback.Invoke(_eCtrl);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        /// <param name="toggle"></param>
        public virtual void SelectEdge(EdgeControl control, bool toggle)
        {
            if (control == null)
            {
                return;
            }

            object edge = control.Edge;

            if (selected_edges_.Contains(edge))
            {
                if (toggle)
                {
                    control.SetValue(Selector.IsSelectedProperty, false);

                    selected_edges_.Remove(edge);
                    edge_controls_.Remove(edge);
                }
            }
            else
            {
                control.SetValue(Selector.IsSelectedProperty, true);

                selected_edges_.Add(edge);
                edge_controls_.Add(edge, control);
            }
        }
        public override void UnDo()
        {
            _graph.Graph.AddVertex(_vertex);
            _vCtrl = new VertexControl(_vertex);
            _graph.AddVertex(_vertex, _vCtrl);

            HighlightBehaviour.SetIsHighlightEnabled(_vCtrl, false);

            foreach (var edge in _relatedEdges)
            {
                var source = _graph.VertexList.FirstOrDefault(v => v.Key.Id == edge.Item2.Id);
                var target = _graph.VertexList.FirstOrDefault(v => v.Key.Id == edge.Item3.Id);

                if (source.Value == null || target.Value == null)
                {
                    throw new Exception("source or target vertex not found");
                }

                var edgeCtrl = new EdgeControl(source.Value, target.Value, edge.Item1)
                {
                    ShowArrows = true,
                    ShowLabel  = true
                };

                _graph.Graph.AddEdge(edge.Item1);
                _graph.AddEdge(edge.Item1, edgeCtrl);

                HighlightBehaviour.SetIsHighlightEnabled(edgeCtrl, false);
            }

            if (_undoCallback != null)
            {
                _undoCallback.Invoke(_vertex);
            }
        }
Exemplo n.º 7
0
        protected virtual void AddEdgeControl(PocEdge edge)
        {
            var edgeControl = new EdgeControl
            {
                Edge        = edge,
                DataContext = edge
            };

            //var edgeControl = _edgePool.GetObject();
            //edgeControl.Edge = edge;
            EdgeControls[edge] = edgeControl;

            //set the Source and the Target
            edgeControl.Source = VertexControls[edge.Source];
            edgeControl.Target = VertexControls[edge.Target];

            if (ActualLayoutMode == Algorithms.Layout.LayoutMode.Simple)
            {
                Children.Insert(0, edgeControl);
            }
            else
            {
                Children.Add(edgeControl);
            }
            SetHighlightProperties(edge, edgeControl);
            //RunCreationTransition(edgeControl);
        }
Exemplo n.º 8
0
        private void ScaleLabels()
        {
            if (Graph == null)
            {
                return;
            }

            double fontSize        = Math.Min(Scale(12), 3600);
            var    borderThickness = new Thickness(Scale(2.0));

            foreach (HierarchicalGraphVertex v in Graph.Vertices)
            {
                VertexControl vc = GetVertexControl(v);
                vc.FontSize        = fontSize;
                vc.BorderThickness = borderThickness;
            }

            double strokeThickness = Scale(1.0);

            foreach (HierarchicalGraphEdge e in Graph.Edges)
            {
                EdgeControl ec = GetEdgeControl(e);
                ec.StrokeThickness = strokeThickness;
            }
        }
Exemplo n.º 9
0
        public EdgeControl CreateEdgeControl(VertexControl source, VertexControl target, object edge, bool showLabels = false, bool showArrows = true, Visibility visibility = Visibility.Visible)
        {
            var edgectrl = new EdgeControl(source, target, edge, showLabels, showArrows) { Visibility = visibility, RootArea = FactoryRootArea};

            return edgectrl;

        }
Exemplo n.º 10
0
        /// <summary>
        /// Создает ребро и его визуальную часть.
        /// </summary>
        /// <param name="targetVertex">Вершина, инцидентная ребру.</param>
        private void CreateEdgeControl(VertexControl targetVertex)
        {
            if (sourceVertex == null)
            {
                sourceVertex = targetVertex;
                HighlightBehaviour.SetHighlighted(sourceVertex, true);
                return;
            }
            if (sourceVertex == targetVertex)
            {
                return;
            }
            if (!isUniqueEdge(sourceVertex, targetVertex))
            {
                return;
            }

            var dlg = new AddEdgeWigthDialog(this);

            if (dlg.ShowDialog() == false)
            {
                return;
            }

            double weidthR = dlg.RoadLength;

            var data    = new DataEdge((DataVertex)sourceVertex.Vertex, (DataVertex)targetVertex.Vertex, weidthR);
            var control = new EdgeControl(sourceVertex, targetVertex, data);

            graphArea.InsertEdgeAndData(data, control, 0, false);

            HighlightBehaviour.SetHighlighted(sourceVertex, false);
            sourceVertex = null;
        }
Exemplo n.º 11
0
        private void TryCreateEdge(object sender, RoutedEventArgs e)
        {
            if (_sceneMediator.GetSelectedMetamodelType() is MetamodelNode)
            {
                _firstSelectedVertexControl = null;
                return;
            }
            if (_firstSelectedVertexControl == null)
            {
                _firstSelectedVertexControl = sender as VertexControl;
                return;
            }
            var metaEdge = _sceneMediator.GetSelectedMetamodelType() as MetamodelEdge;
            var secondSelectedVertexControl = sender as VertexControl;

            var source = _firstSelectedVertexControl.DataContext as ModelNode;
            var target = secondSelectedVertexControl.DataContext as ModelNode;

            var edge        = _sceneMediator.GetModelEdge(metaEdge, source, target);
            var edgeControl = new EdgeControl(_firstSelectedVertexControl, sender as VertexControl, edge);

            _graphArea.AddEdge(edge, edgeControl);
            _graphArea.RelayoutGraph(true);
            _firstSelectedVertexControl = null;
        }
Exemplo n.º 12
0
        private void AddNewEdgeControlWithoutVCP(EdgeViewModel edgeViewModel)
        {
            var previousVertex = this.graphArea.VertexList.First(vc => vc.Key == edgeViewModel.Source).Value;
            var currentVertex  = this.graphArea.VertexList.First(vc => vc.Key == edgeViewModel.Target).Value;
            var ec             = new EdgeControl(previousVertex, currentVertex, edgeViewModel);

            this.graphArea.InsertEdge(edgeViewModel, ec);
        }
Exemplo n.º 13
0
        private void AddNewEdgeControl(EdgeViewModel edgeViewModel)
        {
            var ec = new EdgeControl(this.prevVer, this.ctrlVer, edgeViewModel);

            this.scene.InsertEdge(edgeViewModel, ec);
            this.prevVer = null;
            this.editorManager.DestroyVirtualEdge();
        }
Exemplo n.º 14
0
        private void AddNewEdgeControl(EdgeViewModel edgeViewModel)
        {
            var ec = new EdgeControl(this.previosVertex, this.currentVertex, edgeViewModel);

            this.graphArea.InsertEdge(edgeViewModel, ec);
            this.previosVertex = null;
            this.EditorManager.DestroyVirtualEdge();
        }
Exemplo n.º 15
0
    private void Awake()
    {
        player      = FindObjectOfType <Player>();
        scoreHandle = FindObjectOfType <ScoreHandle>();
        edgeControl = FindObjectOfType <EdgeControl>();

        LoadResourcesOnAwake();
    }
Exemplo n.º 16
0
 //dispose operation, release reference
 public virtual void Dispose()
 {
     _Edge.Dispose();
     _Edge         = null;
     _eCtrl        = null;
     _callback     = null;
     _undoCallback = null;
     _graph        = null;
 }
Exemplo n.º 17
0
 void clearEdgeDrawing()
 {
     _edGeo = null;
     if (_edFakeDV != null)
         dg_Area.LogicCore.Graph.RemoveVertex(_edFakeDV);
     _edFakeDV = null;
     _edVertex = null;
     _edEdge = null;
 }
Exemplo n.º 18
0
        public EdgeControl CreateEdgeControl(VertexControl source, VertexControl target, object edge, bool showLabels = false, bool showArrows = true, Visibility visibility = Visibility.Visible)
        {
            var edgectrl = new EdgeControl(source, target, edge, showLabels, showArrows)
            {
                Visibility = visibility, RootArea = FactoryRootArea
            };

            return(edgectrl);
        }
Exemplo n.º 19
0
        public PortInputView(PortData data)
        {
            this.AddStyleSheet("uNodeStyles/NativePortStyle");
            this.AddStyleSheet(UIElementUtility.Theme.portStyle);
            pickingMode = PickingMode.Ignore;
            ClearClassList();
            this.data = data;

            m_EdgeControl = new EdgeControl {
                from        = new Vector2(412f - 21f, 11.5f),
                to          = new Vector2(412f, 11.5f),
                edgeWidth   = 2,
                pickingMode = PickingMode.Ignore,
                visible     = false,
            };
            Add(m_EdgeControl);

            m_Container = new VisualElement {
                name = "container", visible = false
            };
            m_Container.SetOpacity(false);
            {
                if (this.data != null)
                {
                    m_Control = this.data.InstantiateControl();
                    if (m_Control != null)
                    {
                        m_Control.AddToClassList("port-control");
                        m_Container.Add(m_Control);
                    }
                }

                m_Dot = new VisualElement {
                    name = "dot"
                };
                m_Dot.style.backgroundColor = edgeColor;
                var slotElement = new VisualElement {
                    name = "slot"
                };
                {
                    slotElement.Add(m_Dot);
                }
                var slotContainer = new VisualElement()
                {
                    name = "slotContainer"
                };
                {
                    slotContainer.Add(slotElement);
                }
                m_Container.Add(slotContainer);
            }
            Add(m_Container);

            this.ScheduleAction(DoUpdate, 500);
            data?.owner?.RegisterCallback <GeometryChangedEvent>(OnGeometryChanged);
        }
Exemplo n.º 20
0
        public virtual EdgeControl CreateEdgeControl(VertexControl source, VertexControl target, object edge, bool showArrows = true, Visibility visibility = Visibility.Visible)
        {
            var edgectrl = new EdgeControl(source, target, edge, showArrows)
            {
                RootArea = FactoryRootArea
            };

            edgectrl.SetCurrentValue(UIElement.VisibilityProperty, visibility);
            return(edgectrl);
        }
Exemplo n.º 21
0
 void ClearEdgeDrawing()
 {
     _edGeo = null;
     if (_edFakeDv != null)
     {
         dg_Area.LogicCore.Graph.RemoveVertex(_edFakeDv);
     }
     _edFakeDv = null;
     _edVertex = null;
     _edEdge   = null;
 }
Exemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        public virtual void UnselectEdge(EdgeControl control)
        {
            if (control == null)
            {
                return;
            }

            control.SetValue(Selector.IsSelectedProperty, false);
            selected_edges_.Remove(control.Edge);
            edge_controls_.Remove(control.Edge);
        }
Exemplo n.º 23
0
 void clearEdgeDrawing()
 {
     _edGeo = null;
     if (_edFakeDV != null)
     {
         dg_Area.Graph.RemoveVertex(_edFakeDV);
     }
     _edFakeDV = null;
     _edVertex = null;
     _edEdge   = null;
 }
Exemplo n.º 24
0
        //private void XVertexClick(object sender, RoutedEventArgs e)
        //{
        //    if (xvertex.IsChecked == true)
        //    {
        //        Cursor = Cursors.Pen;
        //    }
        //    else
        //    {
        //        Cursor = Cursors.Arrow;
        //    }

        //    if (xvertex.IsChecked == true)
        //    {
        //        ACLine.IsChecked = false;
        //        xbutton.IsChecked = false;
        //    }

        //}

        private void Area_EdgeClicked(object sender, GraphX.Controls.Models.EdgeClickedEventArgs args)
        {
            EdgeControl ec = (EdgeControl)args.Control;


            if (xbutton.IsEnabled == true)
            {
                (this.DataContext as GraphViewModel).DeleteConnection((ec.Source.Vertex as DataVertex), (ec.Target.Vertex as DataVertex).Element_id);
            }

            //DeleteConnection();
        }
Exemplo n.º 25
0
        void dg_addedge_Click(object sender, RoutedEventArgs e)
        {
            //add new edge between random vertices
            var dataEdge = GenerateRandomEdge();

            if (dataEdge == null)
            {
                return;
            }
            var ec = new EdgeControl(dg_Area.VertexList.FirstOrDefault(a => a.Key == dataEdge.Source).Value, dg_Area.VertexList.FirstOrDefault(a => a.Key == dataEdge.Target).Value, dataEdge);

            dg_Area.InsertEdgeAndData(dataEdge, ec);
        }
 public EdgeConfigurationView(DataVertex dv, Dictionary <string, DataVertex> globalVertices,
                              TestFeederGenerator.Models.GraphX graph, string key, Dictionary <string, List <DataEdge> > globalEdges,
                              bool isUpdate, VertexControl vc, GraphArea area, MainWindow mn,
                              Dictionary <string, Models.CableConfiguration> globalCableConfiguration,
                              EdgeControl ec = null, DataEdge de = null, VertexControl _ecFrom = null)
 {
     InitializeComponent();
     _ec          = ec;
     data         = de;
     this._ecFrom = _ecFrom;
     initializeLocalVariablesNewEdge(dv, graph, globalVertices, key, globalEdges, isUpdate, area, vc, mn, globalCableConfiguration);
     mainWindow = App.Current.MainWindow as MainWindow;
 }
        /// <summary>
        ///  Unmark all edges
        /// </summary>
        /// <param name="graphLayout"></param>
        public void UnmarkAllEdges(GraphLayoutCity graphLayout)
        {
            EdgeControl edgeControl = new EdgeControl();

            foreach (EdgeCity edge in graphLayout.HighlightedEdges)
            {
                graphLayout.Dispatcher.Invoke(
                    new Action(delegate()
                {
                    graphLayout.RemoveHighlightFromEdge(edge);
                }),
                    DispatcherPriority.Normal, null);
            }
        }
        internal void RecreateSerializedEdgeData(DataVertex source, DataVertex target, VertexControl vc, double length)
        {
            DataEdge de = new DataEdge(source, target);

            VertexControl vc1 = GetVertexControlWithDataVertex(source.Element_id);
            VertexControl vc2 = GetVertexControlWithDataVertex(target.Element_id);

            this.length = length;

            EdgeControl ec = new EdgeControl(vc1, vc2, de);


            AddEdge(de, ec, vc1);
        }
        private void ReplaceEdgeTarget(DataVertex dataVertexRegulator, DataVertex dataVertexRegulatorPartial,
                                       string old_value, VertexControl dataVertexRegulatorControl,
                                       VertexControl dataVertexRegulatorPartialControl, string length)
        {
            foreach (DataEdge dataEdge in mainWindow.GlobalEdges[dataVertexRegulator.Element_id])
            {
                if (dataEdge.Target.Element_id == old_value)
                {
                    //setup new data edge
                    DataEdge de = new DataEdge(dataVertexRegulator, dataVertexRegulatorPartial);
                    if (dataEdge.Source.typeOfVertex == DataVertex.TypeOfVertex.REGULATOR_VERTEX || dataEdge.Source.typeOfVertex == DataVertex.TypeOfVertex.TRANSFORMER_VERTEX)
                    {
                        de.Configuration = new CableConfiguration()
                        {
                            Name = "xfm_1"
                        };
                    }
                    de.Length = Double.Parse(length);
                    de.Text   = length;



                    //setup new edge control
                    EdgeControl edgeControl = new EdgeControl(dataVertexRegulatorControl, dataVertexRegulatorPartialControl, de);

                    setEdgesDashStyle(edgeControl, dataVertexRegulator.typeOfVertex);


                    //update area edges
                    mainWindow.graphView.Area.RemoveEdge(dataEdge);
                    mainWindow.graphView.Area.EdgesList.Remove(dataEdge);

                    if (dataVertexRegulator.typeOfVertex == DataVertex.TypeOfVertex.TRANSFORMER_VERTEX)
                    {
                        mainWindow.graphView.Area.AddEdge(de, edgeControl, false);
                    }
                    else
                    {
                        mainWindow.graphView.Area.AddEdge(de, edgeControl, true);
                    }


                    //update global edges
                    mainWindow.GlobalEdges[dataVertexRegulator.Element_id].Remove(dataEdge);
                    mainWindow.GlobalEdges[dataVertexRegulator.Element_id].Add(de);

                    break;
                }
            }
        }
Exemplo n.º 30
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);
                }
            }
        }
Exemplo n.º 31
0
        internal void AddLink(MyVertex v1, MyVertex v2)
        {
            var e = new MyEdge(v1, v2, 1);

            LogicCore.Graph.AddEdge(e);

            //VC DataContext will be bound to v1 by default. You can control this by specifing additional property in the constructor
            var vc1 = VertexList[v1];
            var vc2 = VertexList[v2];

            var ec = new EdgeControl(vc1, vc2, e);

            InsertEdge(e, ec); //inserts edge into the start of the children list to draw it below vertices
        }
Exemplo n.º 32
0
        public void preparar_GUI()
        {
            control = new EdgeControl();
            control.set_edge(this);

            redraw_control();

            //Se um evento deve acontecer na area da AUREA e do NODE/EDGE, entao quando entrar ou sair do node, repassar o mesmo evento da aurea...
            //Se nao for assim, ao entrar/sair no NODE/EDGE ele sai/entra na AUREA e nao mantem o comportamento...

            control.MouseEnter        += Control_MouseEnter;
            control.MouseLeave        += Control_MouseLeave;
            control.MouseLeftButtonUp += Control_MouseLeftButtonUp;
        }
Exemplo n.º 33
0
 void dg_addedge_Click(object sender, RoutedEventArgs e)
 {
     if (dg_Area.VertexList.Count() < 2) return;
     var vlist = dg_Area.LogicCore.Graph.Vertices.ToList();
     var rnd1 = vlist[ShowcaseHelper.Rand.Next(0, vlist.Count -1)];
     vlist.Remove(rnd1);
     var rnd2 = vlist[ShowcaseHelper.Rand.Next(0, vlist.Count - 1)];
     var data = new DataEdge(rnd1, rnd2);
     dg_Area.LogicCore.Graph.AddEdge(data);
     var ec = new EdgeControl(dg_Area.VertexList.FirstOrDefault(a => a.Key == rnd1).Value, dg_Area.VertexList.FirstOrDefault(a => a.Key == rnd2).Value, data) { DataContext = data };
     dg_Area.InsertEdge(data, ec);
     //dg_Area.RelayoutGraph(true);
 }
Exemplo n.º 34
0
 public EdgeSelectedEventArgs(EdgeControl ec, MouseButtonEventArgs e, ModifierKeys keys)
 {
     EdgeControl = ec;
     Modifiers = keys;
     MouseArgs = e;
 }
Exemplo n.º 35
0
 public EdgeSelectedEventArgs(EdgeControl ec, PointerRoutedEventArgs e)
     : base()
 {
     EdgeControl = ec;
     Args = e;
 }
Exemplo n.º 36
0
        private void CreateEdgeControl(VertexControl vc)
        {
            if(_ecFrom == null)
            {
                _editorManager.CreateVirtualEdge(vc, vc.GetPosition());
                _ecFrom = vc;
                HighlightBehaviour.SetHighlighted(_ecFrom, true);
                return;
            }
            if(_ecFrom == vc) return;

            var data = new DataEdge((DataVertex)_ecFrom.Vertex, (DataVertex)vc.Vertex);
            graphArea.LogicCore.Graph.AddEdge(data);
            var ec = new EdgeControl(_ecFrom, vc, data);
            graphArea.InsertEdge(data, ec);

            HighlightBehaviour.SetHighlighted(_ecFrom, false);
            _ecFrom = null;
            _editorManager.DestroyVirtualEdge();
        }
Exemplo n.º 37
0
 public EdgeEventOptions(EdgeControl ec)
 {
     _ec = ec;
 }
Exemplo n.º 38
0
 public void Clean()
 {
     _ec = null;
 }
Exemplo n.º 39
0
 public void AnimateEdge(EdgeControl target)
 {
     RunAnimation(target);
 }
Exemplo n.º 40
0
 public EdgeSelectedEventArgs(EdgeControl ec)
     : base()
 {
     EdgeControl = ec; 
 }
Exemplo n.º 41
0
        void dg_Area_VertexSelectedForED(object sender, GraphX.Models.VertexSelectedEventArgs args)
        {
            if (_isInEDMode)
            {
                if (_edVertex == null) //select starting vertex
                {
                    _edVertex = args.VertexControl;
                    _edFakeDV = new DataVertex() { ID = -666 };
                    _edGeo = new PathGeometry(new PathFigureCollection() { new PathFigure() { IsClosed = false, StartPoint = _edVertex.GetPosition(), Segments = new PathSegmentCollection() { new PolyLineSegment(new List<Point>() { new Point() }, true) } } });
                    var dedge = new DataEdge(_edVertex.Vertex as DataVertex, _edFakeDV);
                    _edEdge = new EdgeControl(_edVertex, null, dedge) { ManualDrawing = true };
                    dg_Area.AddEdge(dedge, _edEdge);
                    dg_Area.LogicCore.Graph.AddVertex(_edFakeDV);
                    dg_Area.LogicCore.Graph.AddEdge(dedge);
                    _edEdge.SetEdgePathManually(_edGeo);
                }
                else if (_edVertex != args.VertexControl) //finish draw
                {
                    _edEdge.Target = args.VertexControl;
                    var dedge = _edEdge.Edge as DataEdge;
                    dedge.Target = args.VertexControl.Vertex as DataVertex;
                    var fig = _edGeo.Figures[0];
                    var seg = fig.Segments[_edGeo.Figures[0].Segments.Count - 1] as PolyLineSegment;

                    if (seg.Points.Count > 0)
                    {
                        var targetPos = _edEdge.Target.GetPosition();
                        var sourcePos = _edEdge.Source.GetPosition();
                        //get the size of the source
                        var sourceSize = new Size()
                        {
                            Width = _edEdge.Source.ActualWidth,
                            Height = _edEdge.Source.ActualHeight
                        };
                        var targetSize = new Size()
                        {
                            Width = _edEdge.Target.ActualWidth,
                            Height = _edEdge.Target.ActualHeight
                        };

                        var src_start = seg.Points.Count == 0 ? fig.StartPoint : seg.Points[0];
                        var src_end = seg.Points.Count > 1 ? (seg.Points[seg.Points.Count - 1] == targetPos ? seg.Points[seg.Points.Count - 2] : seg.Points[seg.Points.Count - 1]) : fig.StartPoint;
                        Point p1 = GeometryHelper.GetEdgeEndpoint(sourcePos, new Rect(sourceSize), src_start, _edEdge.Source.MathShape);
                        Point p2 = GeometryHelper.GetEdgeEndpoint(targetPos, new Rect(targetSize), src_end, _edEdge.Target.MathShape);

                        fig.StartPoint = p1;
                        if (seg.Points.Count > 1)
                            seg.Points[seg.Points.Count - 1] = p2;
                    }
                    GeometryHelper.TryFreeze(_edGeo);
                    _edEdge.SetEdgePathManually(new PathGeometry(_edGeo.Figures));
                    _isInEDMode = false;
                    clearEdgeDrawing();
                }
            }
        }
Exemplo n.º 42
0
 public void AnimateEdgeForward(EdgeControl target)
 {
     //not implemented
 }
Exemplo n.º 43
0
 void dg_addedge_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     if (dg_Area.VertexList.Count() < 2) return;
     var vlist = (dg_Area.VertexList as Dictionary<DataVertex, VertexControl>).Keys.ToList();
     var rnd1 = vlist[Rand.Next(0, dg_Area.VertexList.Count() - 1)];
     var rnd2 = vlist[Rand.Next(0, dg_Area.VertexList.Count() - 1)];
     var data = new DataEdge(rnd1, rnd2);
     dg_Area.LogicCore.Graph.AddEdge(data);
     var ec = new EdgeControl(dg_Area.VertexList.FirstOrDefault(a => a.Key == rnd1).Value, dg_Area.VertexList.FirstOrDefault(a => a.Key == rnd2).Value, data) { DataContext = data };
     dg_Area.InsertEdge(data, ec);
     //dg_Area.RelayoutGraph(true);
 }
Exemplo n.º 44
0
 public void AnimateEdge(EdgeControl target)
 {
     //ALWAYS fire completed event to init delete procedure after the animation process
     OnCompleted(target);
 }
Exemplo n.º 45
0
 internal virtual void OnEdgeSelected(EdgeControl ec, MouseButtonEventArgs e, ModifierKeys keys)
 {
     if (EdgeSelected != null)
         EdgeSelected(this, new EdgeSelectedEventArgs(ec, e, keys));
 }
Exemplo n.º 46
0
 internal void OnEdgeMouseMove(EdgeControl edgeControl, MouseButtonEventArgs e, ModifierKeys keys)
 {
     if (EdgeMouseMove != null)
         EdgeMouseMove(this, new EdgeSelectedEventArgs(edgeControl, e, keys));
 }
Exemplo n.º 47
0
 internal void OnEdgeMouseLeave(EdgeControl edgeControl, MouseButtonEventArgs e, ModifierKeys keys)
 {
     if (EdgeMouseLeave != null)
         EdgeMouseLeave(this, new EdgeSelectedEventArgs(edgeControl, e, keys));
     if (MouseOverAnimation != null)
         MouseOverAnimation.AnimateEdgeBackward(edgeControl);
 }