Skip to content

Commit

Permalink
+ Fixed parallel edge calculation to better accomodate with edge labels
Browse files Browse the repository at this point in the history
+ Added mini showcase: parallel edges
  • Loading branch information
panthernet committed Jun 28, 2015
1 parent fcfaf9c commit 1a444ca
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion Examples/ShowcaseApp.WPF/Models/ShowcaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static void AddEdge(BidirectionalGraph<DataVertex, DataEdge> graph, DataV
Text = string.Empty,
SourceConnectionPointId = sourcePoint,
TargetConnectionPointId = targetPoint,
ToolTipText = "Default label "+ source.ID
ToolTipText = "Label "+ source.ID
};

graph.AddEdge(edge);
Expand Down
8 changes: 4 additions & 4 deletions Examples/ShowcaseApp.WPF/Pages/Mini/EdgesParallel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
47 changes: 46 additions & 1 deletion Examples/ShowcaseApp.WPF/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions Examples/ShowcaseApp.WPF/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="CommonMiniTemplate" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Templates\Mini\CommonMiniTemplate.xaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="EdgesParallel" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Pages\Mini\EdgesParallel.xaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="EdgesParallelText" xml:space="preserve">
<value>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.</value>
</data>
<data name="LayoutVCP" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Pages\Mini\LayoutVCP.xaml;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type controls:EdgeLabelControl}">
<Grid>
<Border BorderBrush="Black" BorderThickness="1" Background="ForestGreen" CornerRadius="8">
<ContentPresenter Margin="1"/>
</Border>
</Grid>
<TextBlock Text="{TemplateBinding Content}" FontSize="8" FontStyle="Italic" Margin="1" VerticalAlignment="Center"/>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
4 changes: 2 additions & 2 deletions GraphX.Controls/Controls/GraphArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1a444ca

Please sign in to comment.