From 1a444ca640b98cbade42b581c5fbdd0d0047ce70 Mon Sep 17 00:00:00 2001 From: panthernet Date: Sun, 28 Jun 2015 12:49:36 +0300 Subject: [PATCH] + Fixed parallel edge calculation to better accomodate with edge labels + Added mini showcase: parallel edges --- .../Controls/SpecialWindowControl.xaml.cs | 7 ++- .../ShowcaseApp.WPF/Models/ShowcaseHelper.cs | 2 +- .../Pages/Mini/EdgesParallel.xaml.cs | 8 ++-- .../Properties/Resources.Designer.cs | 47 ++++++++++++++++++- .../ShowcaseApp.WPF/Properties/Resources.resx | 11 +++++ .../Templates/Mini/CommonMiniTemplate.xaml | 6 +-- GraphX.Controls/Controls/GraphArea.cs | 4 +- 7 files changed, 71 insertions(+), 14 deletions(-) diff --git a/Examples/ShowcaseApp.WPF/Controls/SpecialWindowControl.xaml.cs b/Examples/ShowcaseApp.WPF/Controls/SpecialWindowControl.xaml.cs index 9049b48e..01cd8a4b 100644 --- a/Examples/ShowcaseApp.WPF/Controls/SpecialWindowControl.xaml.cs +++ b/Examples/ShowcaseApp.WPF/Controls/SpecialWindowControl.xaml.cs @@ -54,7 +54,12 @@ protected virtual object LoadContent(Uri uri) spContent2.XamlText = Properties.Resources.ResourceManager.GetString(OpType.ToString()); var spContent3 = result as ISpecialWindowContentXamlTemplate; if (spContent3 != null) - spContent3.XamlText = Properties.Resources.ResourceManager.GetString(OpType+"Template"); + { + var xamlTemplate = Properties.Resources.ResourceManager.GetString(OpType + "Template"); + if(string.IsNullOrEmpty(xamlTemplate)) + xamlTemplate = Properties.Resources.ResourceManager.GetString("CommonMiniTemplate"); + spContent3.XamlText = xamlTemplate; + } return result; } diff --git a/Examples/ShowcaseApp.WPF/Models/ShowcaseHelper.cs b/Examples/ShowcaseApp.WPF/Models/ShowcaseHelper.cs index cd4557d7..e634e3aa 100644 --- a/Examples/ShowcaseApp.WPF/Models/ShowcaseHelper.cs +++ b/Examples/ShowcaseApp.WPF/Models/ShowcaseHelper.cs @@ -38,7 +38,7 @@ public static void AddEdge(BidirectionalGraph graph, DataV Text = string.Empty, SourceConnectionPointId = sourcePoint, TargetConnectionPointId = targetPoint, - ToolTipText = "Default label "+ source.ID + ToolTipText = "Label "+ source.ID }; graph.AddEdge(edge); diff --git a/Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs b/Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs index dce2a356..a960e91a 100644 --- a/Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs +++ b/Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs @@ -58,8 +58,8 @@ private void GenerateGraph() var vList = logicCore.Graph.Vertices.ToList(); //add edges - ShowcaseHelper.AddEdge(logicCore.Graph, vList[0], vList[1]); ShowcaseHelper.AddEdge(logicCore.Graph, vList[1], vList[0]); + ShowcaseHelper.AddEdge(logicCore.Graph, vList[0], vList[1]); ShowcaseHelper.AddEdge(logicCore.Graph, vList[2], vList[3]); graphArea.LogicCore = logicCore; @@ -81,9 +81,9 @@ private void GenerateGraph() graphArea.PreloadGraph(posList); //behaviors var eList = graphArea.EdgesList.Values.ToList(); - eList[0].LabelVerticalOffset = 22; - eList[1].LabelVerticalOffset = 22; - eList[2].LabelVerticalOffset = 22; + eList[0].LabelVerticalOffset = 12; + eList[1].LabelVerticalOffset = 12; + eList[2].LabelVerticalOffset = 12; graphArea.SetVerticesDrag(true, true); graphArea.ShowAllEdgesLabels(); diff --git a/Examples/ShowcaseApp.WPF/Properties/Resources.Designer.cs b/Examples/ShowcaseApp.WPF/Properties/Resources.Designer.cs index 1e312f77..3759ccd5 100644 --- a/Examples/ShowcaseApp.WPF/Properties/Resources.Designer.cs +++ b/Examples/ShowcaseApp.WPF/Properties/Resources.Designer.cs @@ -60,6 +60,51 @@ internal Resources() { } } + /// + /// Looks up a localized string similar to <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + /// xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + /// xmlns:controls="http://schemas.panthernet.ru/graphx/" + /// > + /// + /// <Style TargetType="{x:Type controls:VertexControl}"> + /// <Setter Property="Foreground" Value="{DynamicResource ButtonText}"/> + /// <Setter Property="Template"> + /// <Setter.Value> + /// <ControlTemplate TargetType [rest of string was truncated]";. + /// + internal static string CommonMiniTemplate { + get { + return ResourceManager.GetString("CommonMiniTemplate", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to <UserControl x:Class="ShowcaseApp.WPF.Pages.Mini.EdgesParallel" + /// xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + /// xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + /// xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + /// xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + /// xmlns:wpf="clr-namespace:ShowcaseApp.WPF" + /// xmlns:controls="http://schemas.panthernet.ru/graphx/" + /// [rest of string was truncated]";. + /// + internal static string EdgesParallel { + get { + return ResourceManager.GetString("EdgesParallel", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to In this example you can see how parallel edges can be handled and customized by GraphX. Edge labels also has special logic for parallel edges to be easily readable. + /// + ///Point mouse over the different settings to see tooltips.. + /// + internal static string EdgesParallelText { + get { + return ResourceManager.GetString("EdgesParallelText", resourceCulture); + } + } + /// /// Looks up a localized string similar to <UserControl x:Class="ShowcaseApp.WPF.Pages.Mini.LayoutVCP" /// xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" @@ -87,7 +132,7 @@ internal static string LayoutVCP { /// /// <Setter Property="Content"> /// <Setter.Value> - /// <Path Stroke="Bl [rest of string was truncated]";. + /// <Path Stroke="{D [rest of string was truncated]";. /// internal static string LayoutVCPTemplate { get { diff --git a/Examples/ShowcaseApp.WPF/Properties/Resources.resx b/Examples/ShowcaseApp.WPF/Properties/Resources.resx index 451e9cc3..b4cd3d63 100644 --- a/Examples/ShowcaseApp.WPF/Properties/Resources.resx +++ b/Examples/ShowcaseApp.WPF/Properties/Resources.resx @@ -118,6 +118,17 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Templates\Mini\CommonMiniTemplate.xaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + + ..\Pages\Mini\EdgesParallel.xaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + + In this example you can see how parallel edges can be handled and customized by GraphX. Edge labels also has special logic for parallel edges to be easily readable. + +Point mouse over the different settings to see tooltips. + ..\Pages\Mini\LayoutVCP.xaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 diff --git a/Examples/ShowcaseApp.WPF/Templates/Mini/CommonMiniTemplate.xaml b/Examples/ShowcaseApp.WPF/Templates/Mini/CommonMiniTemplate.xaml index 9ce4a06f..fcb796cb 100644 --- a/Examples/ShowcaseApp.WPF/Templates/Mini/CommonMiniTemplate.xaml +++ b/Examples/ShowcaseApp.WPF/Templates/Mini/CommonMiniTemplate.xaml @@ -55,11 +55,7 @@ - - - - - + diff --git a/GraphX.Controls/Controls/GraphArea.cs b/GraphX.Controls/Controls/GraphArea.cs index efe69be2..2c556c12 100644 --- a/GraphX.Controls/Controls/GraphArea.cs +++ b/GraphX.Controls/Controls/GraphArea.cs @@ -1158,12 +1158,12 @@ 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].SourceOffset = (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].TargetOffset = (viceversa ? -distance : distance) * (1 + ((even ? i : i - 1) / 2)); list[i].SourceOffset = -list[i].TargetOffset; } //change trigger to opposite