Ejemplo n.º 1
0
 internal virtual void OnVertexMouseMove(VertexControl vc, PointerRoutedEventArgs e)
 {
     if (VertexMouseMove != null)
     {
         VertexMouseMove(this, new VertexMovedEventArgs(vc, e));
     }
 }
Ejemplo n.º 2
0
 internal virtual void OnVertexSelected(VertexControl vc, PointerRoutedEventArgs e)
 {
     if (VertexSelected != null)
     {
         VertexSelected(this, new VertexSelectedEventArgs(vc, e));
     }
 }
Ejemplo n.º 3
0
 internal virtual void OnVertexMouseLeave(VertexControl vc, PointerRoutedEventArgs e)
 {
     if (VertexMouseLeave != null)
     {
         VertexMouseLeave(this, new VertexSelectedEventArgs(vc, e));
     }
     if (MouseOverAnimation != null)
     {
         MouseOverAnimation.AnimateVertexBackward(vc);
     }
 }
Ejemplo n.º 4
0
 internal virtual void OnVertexMouseEnter(VertexControl vc, PointerRoutedEventArgs e)
 {
     //TODO keyModifiers
     if (VertexMouseEnter != null)
     {
         VertexMouseEnter(this, new VertexSelectedEventArgs(vc, e));
     }
     if (MouseOverAnimation != null)
     {
         MouseOverAnimation.AnimateVertexForward(vc);
     }
 }
Ejemplo n.º 5
0
        //internal int TargetOffset;

        /// <summary>
        /// Gets the offset point for edge parallelization
        /// </summary>
        /// <param name="source">Source vertex</param>
        /// <param name="target">Target vertex</param>
        /// <param name="sideDistance">Distance between edges</param>
        internal virtual Point GetParallelOffset(VertexControl source, VertexControl target, int sideDistance)
        {
            var sourcepos = source.GetPosition();
            var targetpos = target.GetPosition();

            var mainVector = new Vector(targetpos.X - sourcepos.X, targetpos.Y - sourcepos.Y);
            //get new point coordinate
            var joint = new Point(
                sourcepos.X + source.DesiredSize.Width * .5 + sideDistance * (mainVector.Y / mainVector.Length),
                sourcepos.Y + source.DesiredSize.Height * .5 - sideDistance * (mainVector.X / mainVector.Length));

            return(joint);
        }
Ejemplo n.º 6
0
        private static void OnEdgeDragFinished(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            EdgeControl edgeControl = sender as EdgeControl;

            if (edgeControl == null)
            {
                return;
            }

            GraphAreaBase graphAreaBase = edgeControl.RootArea;

            VertexControl vertexControl = graphAreaBase.GetVertexControlAt(e.GetPosition(graphAreaBase));

            if (vertexControl != null)
            {
                edgeControl.Target = vertexControl;

                if (vertexControl.VertexConnectionPointsList.Count > 0)
                {
                    IVertexConnectionPoint vertexConnectionPoint = vertexControl.GetConnectionPointAt(e.GetPosition(graphAreaBase));

                    var edge = edgeControl.Edge as IGraphXCommonEdge;

                    if (vertexConnectionPoint != null)
                    {
                        edge.TargetConnectionPointId = vertexConnectionPoint.Id;
                    }
                    else
                    {
                        edge.TargetConnectionPointId = null;
                    }
                }

                edgeControl.UpdateEdge();

                var obj = (DependencyObject)sender;
                SetIsDragging(obj, false);
                //obj.ClearValue(OriginalMouseXProperty);
                //obj.ClearValue(OriginalMouseYProperty);
                //obj.ClearValue(OriginalXProperty);
                //obj.ClearValue(OriginalYProperty);

                var element = sender as IInputElement;
                if (element != null)
                {
                    element.MouseMove -= OnVertexDragging;
                    element.ReleaseMouseCapture();
                }
            }
        }
Ejemplo n.º 7
0
 private void TargetChanged(object sender, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
 {
     if (_oldTarget != null)
     {
         _oldTarget.PositionChanged -= source_PositionChanged;
     }
     _oldTarget = Target;
     if (Target != null)
     {
         Target.PositionChanged += source_PositionChanged;
     }
     IsSelfLooped = IsSelfLoopedInternal;
     UpdateSelfLoopedEdgeData();
 }
Ejemplo n.º 8
0
        private void SourceChanged(object sender, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
        {
            if (_oldSource != null)
            {
                _oldSource.PositionChanged -= source_PositionChanged;
            }
            _oldSource = Source;

            if (Source != null)
            {
                Source.PositionChanged += source_PositionChanged;
            }
            IsSelfLooped = IsSelfLoopedInternal;
            UpdateSelfLoopedEdgeData();
        }
        private static void UpdateVertexEdges(VertexControl vc)
        {
            if (vc != null && vc.Vertex != null)
            {
                var ra = vc.RootArea;
                if (ra == null)
                {
                    throw new GX_InvalidDataException("OnDragFinished() - IGraphControl object must always have RootArea property set!");
                }
                if (ra.IsEdgeRoutingEnabled)
                {
                    ra.ComputeEdgeRoutesByVertex(vc);
#if WPF
                    vc.InvalidateVisual();
#elif METRO
                    vc.InvalidateArrange();
#endif
                }
            }
        }
Ejemplo n.º 10
0
        public EdgeControl(VertexControl source, VertexControl target, object edge, bool showLabels = false, bool showArrows = true)
        {
            DefaultStyleKey      = typeof(EdgeControl);
            DataContext          = edge;
            Source               = source; Target = target;
            Edge                 = edge; DataContext = edge;
            ShowArrows           = showArrows;
            ShowLabel            = showLabels;
            IsHiddenEdgesUpdated = true;

            EventOptions = new EdgeEventOptions(this);
            foreach (var item in Enum.GetValues(typeof(EventType)).Cast <EventType>())
            {
                UpdateEventhandling(item);
            }

            TargetChanged(null, null);
            SourceChanged(null, null);
            _sourceWatcher = this.WatchProperty("Source", SourceChanged);
            _targetWatcher = this.WatchProperty("Target", TargetChanged);
        }
 public void Dispose()
 {
     _vertexControl = null;
 }
Ejemplo n.º 12
0
        public EdgeControl(VertexControl source, VertexControl target, object edge, bool showLabels = false, bool showArrows = true)
        {
            DefaultStyleKey = typeof(EdgeControl);
            DataContext = edge;
            Source = source; Target = target;
            Edge = edge; DataContext = edge;
            ShowArrows = showArrows;
            ShowLabel = showLabels;
            IsHiddenEdgesUpdated = true;

            EventOptions = new EdgeEventOptions(this);
            foreach (var item in Enum.GetValues(typeof(EventType)).Cast<EventType>())
                UpdateEventhandling(item);

            TargetChanged(null, null);
            SourceChanged(null, null);
            _sourceWatcher = this.WatchProperty("Source", SourceChanged);
            _targetWatcher = this.WatchProperty("Target", TargetChanged);
        }
Ejemplo n.º 13
0
        private static void UpdateVertexEdges(VertexControl vc)
        {
            if (vc != null && vc.Vertex != null)
            {
                var ra = vc.RootArea;
                if (ra == null) throw new GX_InvalidDataException("OnDragFinished() - IGraphControl object must always have RootArea property set!");
                if (ra.IsEdgeRoutingEnabled)
                {
                    ra.ComputeEdgeRoutesByVertex(vc);
#if WPF
                    vc.InvalidateVisual();
#elif METRO
                    vc.InvalidateArrange();
#endif
                }
            }
        }
Ejemplo n.º 14
0
 public void Dispose()
 {
     _vertexControl = null;
 }
Ejemplo n.º 15
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);
Ejemplo n.º 16
0
        //internal int TargetOffset;

        /// <summary>
        /// Gets the offset point for edge parallelization
        /// </summary>
        /// <param name="source">Source vertex</param>
        /// <param name="target">Target vertex</param>
        /// <param name="sideDistance">Distance between edges</param>
        internal virtual Point GetParallelOffset(VertexControl source, VertexControl target, int sideDistance)
        {
            var sourcepos = source.GetPosition();
            var targetpos = target.GetPosition();

            var mainVector = new Vector(targetpos.X - sourcepos.X, targetpos.Y - sourcepos.Y);
            //get new point coordinate
            var joint = new Point(
                 sourcepos.X + source.DesiredSize.Width * .5 + sideDistance * (mainVector.Y / mainVector.Length),
                 sourcepos.Y + source.DesiredSize.Height * .5 - sideDistance * (mainVector.X / mainVector.Length));
            return joint;
        }
Ejemplo n.º 17
0
        private void SelectVertex(VertexControl vertexControl)
        {
            var vertex = vertexControl.Vertex as WordVertex;
            if (vertex != null)
            {
                eventAggregator.GetEvent<ChangeAttributesEditorViewModel>()
                    .Publish(
                        new ElementAttributeEditorViewModel(eventAggregator, viewModel.ViewId)
                            {
                                Attributes =
                                    vertex
                                    .WordWrapper
                                    .Attributes
                            });
            }

            ClearAllSelectedVertices();

            if (DragBehaviour.GetIsTagged(vertexControl))
            {
                HighlightBehaviour.SetHighlighted(vertexControl, false);
                DragBehaviour.SetIsTagged(vertexControl, false);
            }
            else
            {
                HighlightBehaviour.SetHighlighted(vertexControl, true);
                DragBehaviour.SetIsTagged(vertexControl, true);
            }
        }
Ejemplo n.º 18
0
        private void SafeRemoveVertex(VertexControl vc)
        {
            var wordToRemove = vc.Vertex as WordVertex;

            if (wordToRemove != null)
            {
                GgArea.RemoveVertexAndEdges(wordToRemove);
                viewModel.Sentence.Words.Remove(wordToRemove.WordWrapper);

                foreach (var word in viewModel.Sentence.Words)
                {
                    if (word.GetAttributeByName(CurrentConfiguration.Edge.SourceVertexAttributeName)
                        == wordToRemove.WordWrapper.GetAttributeByName(
                            CurrentConfiguration.Edge.TargetVertexAttributeName))
                    {
                        word.SetAttributeByName(
                            CurrentConfiguration.Edge.SourceVertexAttributeName,
                            wordToRemove.WordWrapper.GetAttributeByName(CurrentConfiguration.Edge.SourceVertexAttributeName));
                    }
                }

                viewModel.CreateSentenceGraph();
                viewModel.SetLayoutAlgorithm(viewModel.SentenceGraphLogicCore);
                GgArea.LogicCore = viewModel.SentenceGraphLogicCore;
                viewModel.PopulateWords();
                DisplayGraph();
                ZoomToFill();
            }
        }
Ejemplo n.º 19
0
        private void OnAddWordVertexControl(WordWrapper word)
        {
            var vertexControl = AddWordVertexControl(word);
            var headWordId = word.GetAttributeByName(CurrentConfiguration.Edge.SourceVertexAttributeName);
            var headWordVertexControl =
                GgArea.VertexList.Where(
                    p =>
                    p.Key.WordWrapper.GetAttributeByName(CurrentConfiguration.Edge.TargetVertexAttributeName)
                        .Equals(headWordId)).Select(p => p.Value).SingleOrDefault();

            if (headWordVertexControl != null)
            {
                sourceVertexControl = headWordVertexControl;
                CreateEdgeControl(vertexControl);
            }

            DisplayGraph();
            ZoomToFill();
        }
Ejemplo n.º 20
0
 public void CreateVirtualEdge(VertexControl source, Point mousePos)
 {
     edgeBlueprint = new EdgeBlueprint(source, mousePos, (LinearGradientBrush) resourceDictionary["EdgeBrush"]);
     graphArea.InsertCustomChildControl(0, edgeBlueprint.EdgePath);
 }
Ejemplo n.º 21
0
        private void ClearEditMode()
        {
            if (sourceVertexControl != null)
            {
                HighlightBehaviour.SetHighlighted(sourceVertexControl, false);
            }

            editorManager.DestroyVirtualEdge();
            sourceVertexControl = null;
        }
Ejemplo n.º 22
0
 private VertexControl AddWordVertexControl(WordWrapper wordWrapper)
 {
     var vertex = new WordVertex(wordWrapper, CurrentConfiguration.Vertex.LabelAttributeName);
     var vertexControl = new VertexControl(vertex);
     GgArea.AddVertexAndData(vertex, vertexControl, true);
     return vertexControl;
 }
Ejemplo n.º 23
0
        public EdgeControl(VertexControl source, VertexControl target, object edge, bool showLabels = false, bool showArrows = true)
        {
            DataContext = edge;
            Source = source; Target = target;
            Edge = edge; DataContext = edge;
            SetCurrentValue(ShowArrowsProperty, showArrows);
            ShowLabel = showLabels;
            IsHiddenEdgesUpdated = true;

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                EventOptions = new EdgeEventOptions(this);
                foreach (var item in Enum.GetValues(typeof (EventType)).Cast<EventType>())
                    UpdateEventhandling(item);

                ActivateSourceListener();
                ActivateTargetListener();

            }
            /*var dpd = DependencyPropertyDescriptor.FromProperty(SourceProperty, typeof(EdgeControl));
            if (dpd != null) dpd.AddValueChanged(this, SourceChanged);
            dpd = DependencyPropertyDescriptor.FromProperty(TargetProperty, typeof(EdgeControl));
            if (dpd != null) dpd.AddValueChanged(this, TargetChanged);*/

            IsSelfLooped = _isSelfLooped;
        }
Ejemplo n.º 24
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)
 {
 }
Ejemplo n.º 25
0
        private void CreateEdgeControl(VertexControl targetVertexControl)
        {
            if (sourceVertexControl == null)
            {
                editorManager.CreateVirtualEdge(targetVertexControl, targetVertexControl.GetPosition());
                sourceVertexControl = targetVertexControl;
                HighlightBehaviour.SetHighlighted(sourceVertexControl, true);
                return;
            }

            if (Equals(sourceVertexControl, targetVertexControl))
            {
                return;
            }

            var wordPrototype = viewModel.DataStructure.Elements.OfType<Word>().Single();

            var addEdgeDialog =
                new AddEdgeWindow(
                    new AddEdgeViewModel(
                        wordPrototype.Attributes.Single(
                            a => a.Name.Equals(CurrentConfiguration.Edge.LabelAttributeName))));

            if (addEdgeDialog.ShowDialog().GetValueOrDefault())
            {
                var edgeLabelText = string.Empty;
                var dataContext = addEdgeDialog.DataContext as AddEdgeViewModel;
                if (dataContext != null)
                {
                    edgeLabelText = dataContext.Attributes.First().Value;
                }

                var sourceWordVertex = sourceVertexControl.Vertex as WordVertex;
                var targetWordVertex = targetVertexControl.Vertex as WordVertex;

                if ((sourceWordVertex == null) || (targetWordVertex == null))
                {
                    return;
                }

                targetWordVertex.WordWrapper.SetAttributeByName(
                    CurrentConfiguration.Edge.SourceVertexAttributeName,
                    sourceWordVertex.WordWrapper.GetAttributeByName(CurrentConfiguration.Edge.TargetVertexAttributeName));
                targetWordVertex.WordWrapper.SetAttributeByName(
                    CurrentConfiguration.Edge.LabelAttributeName,
                    edgeLabelText);

                var data = new WordEdge((WordVertex)sourceVertexControl.Vertex, targetWordVertex)
                               {
                                   Text = edgeLabelText
                               };

                var ec = new EdgeControl(sourceVertexControl, targetVertexControl, data);
                GgArea.InsertEdgeAndData(data, ec, 0, true);

                HighlightBehaviour.SetHighlighted(sourceVertexControl, false);
                sourceVertexControl = null;
                editorManager.DestroyVirtualEdge();
            }

            viewModel.InvalidateCommands();
        }
Ejemplo n.º 26
0
 public EdgeBlueprint(VertexControl source, Point targetPos, Brush brush)
 {
     EdgePath = new Path {Stroke = brush, Data = new LineGeometry()};
     Source = source;
     Source.PositionChanged += Source_PositionChanged;
 }