public VertexSelectedEventArgs(VertexControl vc, MouseButtonEventArgs e, ModifierKeys keys)
     : base()
 {
     VertexControl = vc;
     MouseArgs = e;
     Modifiers = keys;
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        protected void OnVertexSelected(object sender, VertexSelectedEventArgs args)
        {
            // Toggle and append selection occurs in area selection only. No need to worry about it here
            var control = args.VertexControl;
            var vertex  = args.VertexControl.Vertex as VertexBase;

            if (args.MouseArgs.LeftButton == MouseButtonState.Pressed)
            {
                // Is this a new selection and/or a toggle selection?
                if (!selected_vertices_.Contains(vertex))
                {
                    ClearSelection();

                    // User is only selecting one vertex
                    SelectVertex(control, false);
                }

                last_vertex_control_ = control;
                //last_vertex_position_.X = last_vertex_control_.GetPosition().X;
                //last_vertex_position_.Y = last_vertex_control_.GetPosition().Y;
                var position = zoom_control_.TranslatePoint(args.MouseArgs.GetPosition(zoom_control_), graph_area_);
                last_vertex_position_.X = position.X;
                last_vertex_position_.Y = position.Y;
            }
        }
Пример #3
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;

        }
Пример #4
0
        public void AnimateVertexBackward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                target.RenderTransformOrigin = CenterScale ? new Point(.5, .5) : new Point(0, 0);
                return; //no need to back cause default already
            }

            if (transform.ScaleX <= 1 || transform.ScaleY <= 1) return;

#if WPF
            var scaleAnimation = new DoubleAnimation(transform.ScaleX, 1, new Duration(TimeSpan.FromSeconds(Duration)));
            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
#elif METRO
            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation{ Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = transform.ScaleX, To = 1 };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);
            sb.Begin();
#else
            throw new NotImplementedException();
#endif
        }
Пример #5
0
        public override void DisconnectControl(VertexControl vertexControl)
        {
            ViewModel.PositionChanged -= ViewModel_PositionChanged;
            vertexControl.MouseUp     -= VertexControl_MouseUp;

            this.vertexControl = null;
        }
Пример #6
0
 /// <summary>
 /// The basic constructor
 /// </summary>
 /// <param name="source">Source vertex of a new edge</param>
 /// <param name="brush">Brush to draw a blueprint</param>
 public EdgeBlueprint(VertexControl source, Brush brush)
 {
     EdgePath = new Path {
         Stroke = brush, Data = new LineGeometry()
     };
     Source = source;
 }
Пример #7
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();
        }
Пример #8
0
        private void ScaleLabels()
        {
            if (Graph == null)
            {
                return;
            }

            double fontSize        = Scale(12);
            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;
            }
        }
Пример #9
0
 /// <summary>
 /// Create edge control
 /// </summary>
 /// <param name="source"></param>
 /// <param name="target"></param>
 /// <param name="edge"></param>
 /// <param name="showLabels"></param>
 /// <param name="showArrows"></param>
 /// <param name="visibility"></param>
 /// <returns></returns>
 public EdgeControl CreateEdgeControl(VertexControl source, VertexControl target, object edge, bool showArrows = true, Visibility visibility = Visibility.Visible)
 {
     return(new NodeEdgeControl(source, target, edge, showArrows)
     {
         Visibility = visibility, RootArea = FactoryRootArea
     });
 }
Пример #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="control"></param>
        /// <param name="toggle"></param>
        public virtual void SelectVertex(VertexControl control, bool toggle)
        {
            if (control == null)
            {
                return;
            }

            VertexBase vertex = (VertexBase)control.Vertex;

            if (selected_vertices_.Contains(vertex))
            {
                if (toggle)
                {
                    control.SetValue(Selector.IsSelectedProperty, false);
                    DragBehaviour.SetIsTagged(control, false);

                    selected_vertices_.Remove(vertex);
                    vertex_controls_.Remove(vertex);
                }
            }
            else
            {
                control.SetValue(Selector.IsSelectedProperty, true);
                DragBehaviour.SetIsTagged(control, true);

                selected_vertices_.Add(vertex);
                vertex_controls_.Add(vertex, control);
            }
        }
        public void AnimateVertexForward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);

            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                target.RenderTransformOrigin = CenterScale ? new Point(.5, .5) : new Point(0, 0);
            }

#if WPF
            var scaleAnimation = new DoubleAnimation(1, ScaleTo, new Duration(TimeSpan.FromSeconds(Duration)));
            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
#elif METRO
            var sb             = new Storyboard();
            var scaleAnimation = new DoubleAnimation {
                Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo
            };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation {
                Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo
            };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);
            sb.Begin();
#else
            throw new NotImplementedException();
#endif
        }
Пример #12
0
        private bool IsCenterOfFirstVertexOnAnother(VertexControl vertex1, VertexControl vertex2)
        {
            Point         center      = this.graphArea.TranslatePoint(vertex1.GetCenterPosition(), vertex1);
            Point         coordinates = vertex1.TranslatePoint(center, vertex2);
            HitTestResult hit         = VisualTreeHelper.HitTest(vertex2, coordinates);

            return(hit != null);
        }
Пример #13
0
 /// <summary>
 /// Очищает режим создания.
 /// </summary>
 private void ClearCreateMode()
 {
     if (sourceVertex != null)
     {
         HighlightBehaviour.SetHighlighted(sourceVertex, false);
     }
     sourceVertex = null;
 }
Пример #14
0
 public VisualEdgeControl(VertexControl source, VertexControl target, VisualEdge edgeData, bool showLabels = false, bool showArrows = true) : base(source, target, edgeData, showLabels, showArrows)
 {
     BindingOperations.SetBinding(this, ForegroundProperty, new Binding(nameof(EdgeBase <VertexBase> .StrokeBrush))
     {
         Source = edgeData.Edge,
         UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
     });
 }
Пример #15
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();
        }
Пример #16
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();
        }
Пример #17
0
        internal void AddJob(MyVertex job, Point pos)
        {
            LogicCore.Graph.AddVertex(job);
            var vc = new VertexControl(job);

            vc.SetPosition(pos);
            AddVertex(job, vc);
        }
Пример #18
0
 private void ClearEditMode()
 {
     if (_ecFrom != null)
     {
         HighlightBehaviour.SetHighlighted(_ecFrom, false);
     }
     _editorManager.DestroyVirtualEdge();
     _ecFrom = null;
 }
Пример #19
0
 public EdgeBlueprint(VertexControl source, Point targetPos, Brush brush)
 {
     this.EdgePath = new Path {
         Stroke = brush, Data = new LineGeometry()
     };
     this.Source    = source;
     this.TargetPos = targetPos;
     this.Source.PositionChanged += this.Source_PositionChanged;
 }
Пример #20
0
 void clearEdgeDrawing()
 {
     _edGeo = null;
     if (_edFakeDV != null)
         dg_Area.LogicCore.Graph.RemoveVertex(_edFakeDV);
     _edFakeDV = null;
     _edVertex = null;
     _edEdge = null;
 }
Пример #21
0
 //dispose operation, release reference
 public virtual void Dispose()
 {
     _vertex.Dispose();
     _vertex       = null;
     _vCtrl        = null;
     _callback     = null;
     _undoCallback = null;
     _graph        = null;
 }
Пример #22
0
        private void Area_VertexDoubleClick(object sender, GraphX.Controls.Models.VertexSelectedEventArgs args)
        {
            VertexControl vc        = (VertexControl)args.VertexControl;
            DataVertex    dv        = (DataVertex)vc.Vertex;
            string        vertex_id = dv.Element_id;
            bool          found     = FindVertexInCollection(vertex_id);

            FindSelectedVertex(vertex_id, found, args.VertexControl);
        }
 public EdgeBlueprint(VertexControl source, Point targetPos, Brush brush)
 {
     EdgePath = new Path()
     {
         Stroke = brush, Data = new LineGeometry()
     };
     Source = source;
     Source.PositionChanged += Source_PositionChanged;
 }
Пример #24
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);
        }
        public VertexPositionChangeOperation(GraphArea graph, VertexControl vc, double offsetX, double offsetY, DataVertex data = null, Action <DataVertex, VertexControl> callback = null, Action <DataVertex> undoCallback = null)
            : base(graph, data, callback, undoCallback)
        {
            _vc      = vc;
            _offsetX = offsetX;
            _offsetY = offsetY;

            Status = Orc.GraphExplorer.Status.Done;
        }
Пример #26
0
        public static void CenterOnVertexControl(this ZoomControl zoomControl, VertexControl vertex)
        {
            var vPos   = vertex.GetPosition();
            var width  = zoomControl.ActualWidth / zoomControl.Zoom;
            var height = zoomControl.ActualHeight / zoomControl.Zoom;
            var x      = vPos.X - width / 2 + vertex.RenderSize.Width / 2;;
            var y      = vPos.Y - height / 2 + vertex.RenderSize.Height / 2;

            zoomControl.ZoomToContent(new Rect(x, y, width, height));
        }
Пример #27
0
        private void OnCreateVertex(IElement el)
        {
            var v      = el as Vertex;
            var vertex = new VertexControl(this, v.Id, v.Position)
            {
                DataContext = v
            };

            _elementsGraph.Add(v.Id, vertex);
        }
Пример #28
0
        private void AddNewVertexControlWithoutPos(NodeViewModel nodeViewModel)
        {
            var vc = new VertexControl(nodeViewModel);

            if (this.model.ModelName == "GreenhouseTestModel")
            {
                vc = new VertexControlWithVCP(nodeViewModel);
            }
            this.graphArea.AddVertex(nodeViewModel, vc);
        }
Пример #29
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);
        }
Пример #30
0
        public VertexControl AddVirtualVertexControl(NodeViewModel innerNodeData)
        {
            innerNodeData.IsVirtual = true;
            var virtualControl = new VertexControl(innerNodeData);

            this.position = this.zoomControl.TranslatePoint(Mouse.GetPosition(this.zoomControl), this.graphArea);
            virtualControl.SetPosition(this.position);
            this.graphArea.AddVertex(innerNodeData, virtualControl);
            return(virtualControl);
        }
Пример #31
0
        private void VertexSelectedAction(object sender, VertexSelectedEventArgs args)
        {
            this.currentVertex = args.VertexControl;
            if (this.elementProvider.Element?.InstanceMetatype == Repo.Metatype.Edge)
            {
                if (this.previosVertex == null)
                {
                    this.editorManager.CreateVirtualEdge(this.currentVertex, this.currentVertex.GetPosition());
                    this.previosVertex = this.currentVertex;
                }
                else
                {
                    if (((VertexControlWithVCP)currentVertex).VCPTargetRoot == null)
                    {
                        this.editorManager.DestroyVirtualEdge();
                        return;
                    }
                    var command = new Commands.CreateEdgeCommand(
                        this.model,
                        this.elementProvider.Element,
                        (this.previosVertex?.Vertex as NodeViewModel)?.Node,
                        (this.currentVertex?.Vertex as NodeViewModel)?.Node);
                    this.controller.Execute(command);
                    this.ElementManipulationDone?.Invoke(this, EventArgs.Empty);
                }

                return;
            }

            this.NodeSelected?.Invoke(
                this,
                new NodeSelectedEventArgs {
                Node = this.currentVertex.GetDataVertex <NodeViewModel>()
            });

            this.graphArea.GetAllVertexControls().ToList().ForEach(x => x.GetDataVertex <NodeViewModel>().
                                                                   Color = Brushes.Green);

            this.currentVertex.GetDataVertex <NodeViewModel>().Color = Brushes.LightBlue;
            if (this.previosVertex != null)
            {
                this.previosVertex.GetDataVertex <NodeViewModel>().Color = Brushes.Yellow;
            }

            if (args.MouseArgs.RightButton == MouseButtonState.Pressed)
            {
                args.VertexControl.ContextMenu = new ContextMenu();
                var mi = new MenuItem {
                    Header = "Delete item", Tag = args.VertexControl
                };
                mi.Click += this.MenuItemClickedOnVertex;
                args.VertexControl.ContextMenu.Items.Add(mi);
                args.VertexControl.ContextMenu.IsOpen = true;
            }
        }
Пример #32
0
        private void FindSelectedVertex(string vertex_id, bool found, VertexControl vc)
        {
            if (!found)
            {
                Console.WriteLine("No vertex found");
            }

            DataVertex dv = mainWindow.GlobalVertices[vertex_id];

            (this.DataContext as GraphViewModel).ShowVertexDetails(dv, vc);
        }
Пример #33
0
        private void AddNewVertexControl(NodeViewModel vertex)
        {
            var vc = new VertexControl(vertex);

            if (this.model.ModelName == "GreenhouseTestModel")
            {
                vc = new VertexControlWithVCP(vertex);
            }
            vc.SetPosition(this.position);
            this.graphArea.AddVertex(vertex, vc);
        }
Пример #34
0
 void clearEdgeDrawing()
 {
     _edGeo = null;
     if (_edFakeDV != null)
     {
         dg_Area.Graph.RemoveVertex(_edFakeDV);
     }
     _edFakeDV = null;
     _edVertex = null;
     _edEdge   = null;
 }
Пример #35
0
 public void AnimateVertex(VertexControl target)
 {
     //get scale transform or create new one
     var transform = CustomHelper.GetScaleTransform(target);
     if (transform == null)
     {
         target.RenderTransform = new ScaleTransform();
         transform = target.RenderTransform as ScaleTransform;
         if (Centered)
             target.RenderTransformOrigin = new Point(.5, .5);
         else
             target.RenderTransformOrigin = new Point(0, 0);
     }
     //create and run animation
     var scaleAnimation =
         new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(Duration)));
     scaleAnimation.Completed += (sender, e) => { OnCompleted(target as IGraphControl); };
     transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
     transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
 }
Пример #36
0
        public void AnimateVertexBackward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                if (CenterScale)
                    target.RenderTransformOrigin = new Point(.5, .5);
                else
                    target.RenderTransformOrigin = new Point(0, 0);
                return; //no need to back cause default already
            }

            if (transform.ScaleX <= 1 || transform.ScaleY <= 1) return;

            DoubleAnimation scaleAnimation =
                new DoubleAnimation(transform.ScaleX, 1, new Duration(TimeSpan.FromSeconds(Duration)));

            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
        }
Пример #37
0
        public void AnimateVertex(VertexControl target)
        {
            //get scale transform or create new one
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                target.RenderTransformOrigin = Centered ? new Point(.5, .5) : new Point(0, 0);
            }
            //create and run animation
#if WPF
            var scaleAnimation = new DoubleAnimation(1, 0, new Duration(TimeSpan.FromSeconds(Duration)));
            scaleAnimation.Completed += (sender, e) =>  OnCompleted(target);
            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);            
#elif METRO
            var sb = new Storyboard();
            //create and run animation
            var scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = 0  };
            //scaleAnimation.Completed += (sender, e) => OnCompleted(target as IGraphControl);
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);

            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = 0 };
            scaleAnimation.Completed += (sender, e) => OnCompleted(target as IGraphControl);
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);
            sb.Begin();

#else
            throw new NotImplementedException();
#endif
        }
Пример #38
0
 private VertexControl CreateVertexControl(Point position)
 {
     var data = new DataVertex("Vertex " + (graphArea.VertexList.Count + 1)) { ImageId = ShowcaseHelper.Rand.Next(0, ThemedDataStorage.EditorImages.Count) };
     graphArea.LogicCore.Graph.AddVertex(data);
     var vc = new VertexControl(data);
     graphArea.AddVertex(data, vc);
     GraphAreaBase.SetX(vc, position.X, true);
     GraphAreaBase.SetY(vc, position.Y, true);
     return vc;
 }
Пример #39
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();
        }
Пример #40
0
        public void AnimateVertexForward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                if (CenterScale)
                    target.RenderTransformOrigin = new Point(.5, .5);
                else
                    target.RenderTransformOrigin = new Point(0, 0);
            }

            DoubleAnimation scaleAnimation =
                new DoubleAnimation(1, ScaleTo, new Duration(TimeSpan.FromSeconds(Duration)));

            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
        }
Пример #41
0
 private void SafeRemoveVertex(VertexControl vc, bool removeFromSelected = false)
 {
     //remove all adjacent edges
     foreach (var ec in graphArea.GetRelatedControls(vc, GraphControlType.Edge, EdgesType.All).OfType<EdgeControl>())
     {
         graphArea.LogicCore.Graph.RemoveEdge(ec.Edge as DataEdge);
         graphArea.RemoveEdge(ec.Edge as DataEdge);
     }
     graphArea.LogicCore.Graph.RemoveVertex(vc.Vertex as DataVertex);
     graphArea.RemoveVertex(vc.Vertex as DataVertex);
     if (removeFromSelected && _selectedVertices.Contains(vc))
         _selectedVertices.Remove(vc);
 }
Пример #42
0
 internal virtual void OnVertexDoubleClick(VertexControl vc)
 {
     if (VertexDoubleClick != null)
         VertexDoubleClick(this, new VertexSelectedEventArgs(vc, null, Keyboard.Modifiers));
 }
Пример #43
0
 private void SafeRemoveVertex(VertexControl vc, bool removeFromSelected = false)
 {
     //remove all adjacent edges
     foreach (var item in dg_Area.GetRelatedControls(vc, GraphControlType.Edge, EdgesType.All))
     {
         var ec = item as EdgeControl;
         dg_Area.LogicCore.Graph.RemoveEdge(ec.Edge as DataEdge);
         dg_Area.RemoveEdge(ec.Edge as DataEdge);
     }
     dg_Area.LogicCore.Graph.RemoveVertex(vc.Vertex as DataVertex);
     dg_Area.RemoveVertex(vc.Vertex as DataVertex);
     if (removeFromSelected && DG_SelectedVertices.Contains(vc))
         DG_SelectedVertices.Remove(vc);
     dg_zoomctrl.ZoomToFill();
 }
Пример #44
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();
                }
            }
        }
Пример #45
0
 public VertexMovedEventArgs(VertexControl vc, Point offset )
     : base()
 {
     Offset = offset;
     VertexControl = vc;
 }
Пример #46
0
 /// <summary>
 /// Compute new edge routes for all edges of the vertex
 /// </summary>
 /// <param name="vc">Vertex visual control</param>
 /// <param name="vertexDataNeedUpdate">If vertex data inside edge routing algorthm needs to be updated</param>
 internal virtual void ComputeEdgeRoutesByVertex(VertexControl vc, bool vertexDataNeedUpdate = true) { }
Пример #47
0
 internal virtual void OnVertexMouseLeave(VertexControl vc)
 {
     if (VertexMouseLeave != null)
         VertexMouseLeave(this, new VertexSelectedEventArgs(vc, null, Keyboard.Modifiers));
     if (MouseOverAnimation != null)
         MouseOverAnimation.AnimateVertexBackward(vc);
 }
Пример #48
0
 internal virtual void OnVertexMouseMove(VertexControl vc)
 {
     if (VertexMouseMove != null)
         VertexMouseMove(this, new VertexMovedEventArgs(vc, new Point()));
 }
Пример #49
0
 internal virtual void OnVertexMouseUp(VertexControl vc, MouseButtonEventArgs e, ModifierKeys keys)
 {
     if (VertexMouseUp != null)
         VertexMouseUp(this, new VertexSelectedEventArgs(vc, e, keys));
 }
Пример #50
0
 public void AnimateVertex(VertexControl target)
 {
     RunAnimation(target);
 }
Пример #51
0
 private Dictionary<DataVertex, Point> GenerateRandomVertices(GraphExample graph, int index, int count, int minX, int maxX, int minY, int maxY)
 {
     var list = graph.Vertices.ToList();
     var vertexPositions = new Dictionary<DataVertex, Point>();
     for (var i = index; i < index + count; i++)
     {
         var vertex = list[i];
         var vc = new VertexControl(vertex);
         erg_Area.AddVertex(vertex, vc);
         vertexPositions[vertex] = new Point(ShowcaseHelper.Rand.Next(minX, maxX), ShowcaseHelper.Rand.Next(minY, maxY));
         vc.SetPosition(vertexPositions[vertex]);
     }
     return vertexPositions;
 }
Пример #52
0
 /// <summary>
 /// Generates and displays edges for specified vertex
 /// </summary>
 /// <param name="vc">Vertex control</param>
 /// <param name="edgeType">Type of edges to display</param>
 /// <param name="defaultVisibility">Default edge visibility on layout</param>
 public abstract void GenerateEdgesForVertex(VertexControl vc, EdgesType edgeType, Visibility defaultVisibility = Visibility.Visible);
Пример #53
0
 public EdgeBlueprint(VertexControl source, Point targetPos, Brush brush)
 {
     EdgePath = new Path() { Stroke = brush, Data = new LineGeometry() };
     Source = source;
     Source.PositionChanged += Source_PositionChanged;
 }
Пример #54
0
        void dg_Area_Drop(object sender, System.Windows.DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(object)))
            {
                //how to get dragged data by its type
                var myobject = e.Data.GetData(typeof(object)) as object;

                var pos = dg_zoomctrl.TranslatePoint(e.GetPosition(dg_zoomctrl), dg_Area);
                var data = new DataVertex();
                dg_Area.LogicCore.Graph.AddVertex(data);
                var vc = new VertexControl(data);
                dg_Area.AddVertex(data, vc);
                //dg_Area.RelayoutGraph(true);
                GraphAreaBase.SetX(vc, pos.X, true);
                GraphAreaBase.SetY(vc, pos.Y, true);
                if (dg_Area.VertexList.Count() == 1)
                {
                    var of = System.Windows.Media.VisualTreeHelper.GetOffset(vc);
                    int offset = 400;
                    dg_zoomctrl.ZoomTo(new Rect(of.X - offset, of.Y - offset, vc.ActualWidth + offset * 2, vc.ActualHeight + offset * 2));

                    /* //FOR ZoomControl
                    zoomctrl.Mode = GraphX.Controls.ZoomControlModes.Original;
                    */
                }else dg_zoomctrl.ZoomToFill();
            }
        }
Пример #55
0
 public void CreateVirtualEdge(VertexControl source, Point mousePos)        
 {
     _edgeBp = new EdgeBlueprint(source, mousePos, (LinearGradientBrush)_rd["EdgeBrush"]);
     _graphArea.InsertCustomChildControl(0, _edgeBp.EdgePath);
 }
 public VertexPositionEventArgs(Point offset, Point pos, VertexControl vc)
 {
     OffsetPosition = offset;
     VertexControl = vc;
     Position = pos;
 }
Пример #57
0
 private void SelectVertex(VertexControl vc)
 {
     if (DG_SelectedVertices.Contains(vc))
     {
         DG_SelectedVertices.Remove(vc);
         HighlightBehaviour.SetHighlighted(vc, false);
         DragBehaviour.SetIsTagged(vc, false);
     }
     else
     {
         DG_SelectedVertices.Add(vc);
         HighlightBehaviour.SetHighlighted(vc, true);
         DragBehaviour.SetIsTagged(vc, true);
     }
 }
Пример #58
0
 public VertexSelectedEventArgs(VertexControl vc, PointerRoutedEventArgs e)
 {
     VertexControl = vc;
     Args = e;
 }
Пример #59
0
 public void Reset()
 {
     Edge = null;
     RoutePoints = null;
     Source = null;
     Target = null;
 }
Пример #60
-1
        public void AnimateVertexForward(VertexControl target)
        {
            var transform = CustomHelper.GetScaleTransform(target);
            if (transform == null)
            {
                target.RenderTransform = new ScaleTransform();
                transform = target.RenderTransform as ScaleTransform;
                target.RenderTransformOrigin = CenterScale ? new Point(.5, .5) : new Point(0, 0);
            }

#if WPF
            var scaleAnimation =new DoubleAnimation(1, ScaleTo, new Duration(TimeSpan.FromSeconds(Duration)));
            transform.BeginAnimation(ScaleTransform.ScaleXProperty, scaleAnimation);
            transform.BeginAnimation(ScaleTransform.ScaleYProperty, scaleAnimation);
#elif METRO
            var sb = new Storyboard();
            var scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleX)");
            sb.Children.Add(scaleAnimation);
            scaleAnimation = new DoubleAnimation { Duration = new Duration(TimeSpan.FromSeconds(Duration)), From = 1, To = ScaleTo };
            Storyboard.SetTarget(scaleAnimation, target);
            Storyboard.SetTargetProperty(scaleAnimation, "(UIElement.RenderTransform).(CompositeTransform.ScaleY)");
            sb.Children.Add(scaleAnimation);
            sb.Begin();
#else
            throw new NotImplementedException();
#endif

        }