diff --git a/Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs b/Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs index a960e91a..e7ce92b3 100644 --- a/Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs +++ b/Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs @@ -53,23 +53,25 @@ private void GenerateGraph() { var logicCore = new LogicCoreExample() { - Graph = ShowcaseHelper.GenerateDataGraph(4, false) + Graph = ShowcaseHelper.GenerateDataGraph(3, false) }; var vList = logicCore.Graph.Vertices.ToList(); //add edges - ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[0]); ShowcaseHelper.AddEdge(logicCore.Graph, vList[0], vList[1]); - ShowcaseHelper.AddEdge(logicCore.Graph, vList[2], vList[3]); + ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[0]); + + ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[2]); + ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[2]); + ShowcaseHelper.AddEdge(logicCore.Graph, vList[2], vList[1]); graphArea.LogicCore = logicCore; //set positions var posList = new Dictionary() { - {vList[0], new Point(0, 0)}, + {vList[0], new Point(0, -150)}, {vList[1], new Point(300, 0)}, - {vList[2], new Point(0, 300)}, - {vList[3], new Point(300, 300)}, + {vList[2], new Point(600, -150)}, }; //settings @@ -80,15 +82,20 @@ private void GenerateGraph() //preload graph graphArea.PreloadGraph(posList); //behaviors + graphArea.SetVerticesDrag(true, true); + graphArea.ShowAllEdgesLabels(); + graphArea.AlignAllEdgesLabels(); + zoomControl.MaxZoom = 50; + //manual edge corrections var eList = graphArea.EdgesList.Values.ToList(); eList[0].LabelVerticalOffset = 12; eList[1].LabelVerticalOffset = 12; - eList[2].LabelVerticalOffset = 12; - graphArea.SetVerticesDrag(true, true); - graphArea.ShowAllEdgesLabels(); - graphArea.AlignAllEdgesLabels(); + eList[2].ShowLabel = false; + eList[3].LabelVerticalOffset = 12; + eList[4].LabelVerticalOffset = 12; + //PS: to see how parallel edges logic works go to GraphArea::UpdateParallelEdgesData() method zoomControl.ZoomToFill(); } diff --git a/GraphX.Controls/Controls/EdgeControlBase.cs b/GraphX.Controls/Controls/EdgeControlBase.cs index fc462c34..aa473775 100644 --- a/GraphX.Controls/Controls/EdgeControlBase.cs +++ b/GraphX.Controls/Controls/EdgeControlBase.cs @@ -516,8 +516,8 @@ internal virtual void UpdateEdgeRendering(bool updateLabel = true) } - internal int SourceOffset; - internal int TargetOffset; + internal int ParallelEdgeOffset; + //internal int TargetOffset; /// /// Gets the offset point for edge parallelization @@ -685,10 +685,10 @@ public virtual void PrepareEdgePath(bool useCurrentCoords = false, Measure.Point var hasRouteInfo = routeInformation != null && routeInformation.Length > 1; //calculate source and target edge attach points - if (RootArea != null && !hasRouteInfo && RootArea.EnableParallelEdges) + if (RootArea != null && !hasRouteInfo && RootArea.EnableParallelEdges && ParallelEdgeOffset != 0) { - if (SourceOffset != 0) sourcePos = GetParallelOffset(Source, Target, SourceOffset); - if (TargetOffset != 0) targetPos = GetParallelOffset(Target, Source, TargetOffset); + sourcePos = GetParallelOffset(Source, Target, ParallelEdgeOffset); + targetPos = GetParallelOffset(Target, Source, -ParallelEdgeOffset); } /* Rectangular shapes implementation by bleibold */ diff --git a/GraphX.Controls/Controls/GraphArea.cs b/GraphX.Controls/Controls/GraphArea.cs index 2c556c12..f8e0b30b 100644 --- a/GraphX.Controls/Controls/GraphArea.cs +++ b/GraphX.Controls/Controls/GraphArea.cs @@ -1152,19 +1152,16 @@ public void UpdateParallelEdgesData() //leave first edge intact if we have not even edges count for (int i = even ? 0 : 1; i < list.Count; i++) { - //var dist = ParallelEdgeDistance; - //if (chet && i < 2) dist = distance; - //if (cList[i] && ((!chet && !prevc) || list.Count == 2)) viceversa = !viceversa; //if source to target edge if (!cList[i]) { - list[i].SourceOffset = (viceversa ? -distance : distance) * (1 + ((even ? i : i - 1) / 2)); - list[i].TargetOffset = -list[i].SourceOffset; + list[i].ParallelEdgeOffset = (viceversa ? -distance : distance) * (1 + ((even ? i : i - 1) / 2)); + //list[i].TargetOffset = -list[i].ParallelEdgeOffset; } else //if target to source edge - just switch offsets { - list[i].TargetOffset = (viceversa ? -distance : distance) * (1 + ((even ? i : i - 1) / 2)); - list[i].SourceOffset = -list[i].TargetOffset; + list[i].ParallelEdgeOffset = -((viceversa ? -distance : distance) * (1 + ((even ? i : i - 1) / 2))); + //list[i].ParallelEdgeOffset = -list[i].TargetOffset; } //change trigger to opposite viceversa = !viceversa; diff --git a/GraphX.METRO.Controls/Controls/GraphArea.cs b/GraphX.METRO.Controls/Controls/GraphArea.cs index 72a1c551..3dac3a73 100644 --- a/GraphX.METRO.Controls/Controls/GraphArea.cs +++ b/GraphX.METRO.Controls/Controls/GraphArea.cs @@ -1061,13 +1061,13 @@ public void UpdateParallelEdgesData() //if source to target edge if (!cList[i]) { - list[i].SourceOffset = (viceversa ? distance : -distance) * (1 + ((even ? i : i - 1) / 2)); - list[i].TargetOffset = -list[i].SourceOffset; + list[i].ParallelEdgeOffset = (viceversa ? distance : -distance) * (1 + ((even ? i : i - 1) / 2)); + // list[i].TargetOffset = -list[i].SourceOffset; } else //if target to source edge - just switch offsets { - list[i].TargetOffset = (viceversa ? distance : -distance) * (1 + ((even ? i : i - 1) / 2)); - list[i].SourceOffset = -list[i].TargetOffset; + list[i].ParallelEdgeOffset = -((viceversa ? distance : -distance) * (1 + ((even ? i : i - 1) / 2))); + //list[i].SourceOffset = -list[i].TargetOffset; } //change trigger to opposite viceversa = !viceversa;