зеркало из https://github.com/stride3d/GraphX.git
+ Made EdgeControlBase::UpdateEdge() method public. It can be used now to fully update edge visual on custom edge-related modifications [WPF, METRO]
+ Some code for lib debug & test improvement + VCP tweaks
This commit is contained in:
Родитель
6db1d624c8
Коммит
cefd02bb2e
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"version": "0.1.0",
|
||||
// List of configurations. Add new configurations or edit existing ones.
|
||||
// ONLY "node" and "mono" are supported, change "type" to switch.
|
||||
"configurations": [
|
||||
{
|
||||
// Name of configuration; appears in the launch configuration drop down menu.
|
||||
"name": "Launch app.js",
|
||||
// Type of configuration. Possible values: "node", "mono".
|
||||
"type": "node",
|
||||
// Workspace relative or absolute path to the program.
|
||||
"program": "app.js",
|
||||
// Automatically stop program after launch.
|
||||
"stopOnEntry": true,
|
||||
// Command line arguments passed to the program.
|
||||
"args": [],
|
||||
// Workspace relative or absolute path to the working directory of the program being debugged. Default is the current workspace.
|
||||
"cwd": ".",
|
||||
// Workspace relative or absolute path to the runtime executable to be used. Default is the runtime executable on the PATH.
|
||||
"runtimeExecutable": null,
|
||||
// Environment variables passed to the program.
|
||||
"env": { }
|
||||
},
|
||||
{
|
||||
"name": "Attach",
|
||||
"type": "node",
|
||||
// TCP/IP address. Default is "localhost".
|
||||
"address": "localhost",
|
||||
// Port to attach to.
|
||||
"port": 5858
|
||||
}
|
||||
]
|
||||
}
|
|
@ -46,6 +46,7 @@ DETAILED CHANGELOG:
|
|||
+ Fixed ZoomControl zoom sometimes not firing from code call after control is loaded [WPF]
|
||||
+ Fixed VB sample project dependencies and refactored code a bit
|
||||
+ Fixed Fade Move animation logic to report OnCompleted event correctly [WPF]
|
||||
+ Made EdgeControlBase::UpdateEdge() method public. It can be used now to fully update edge visual on custom edge-related modifications [WPF, METRO]
|
||||
+ Improved main layout calculation logic to gain performance improvements [WPF, METRO]
|
||||
+ Reorganized Example apps namespaces and code for greater good :)
|
||||
+ Merged EdgePointerImage and EdgePointerPath into one universal DefaultEdgePointer class [WPF, METRO]
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
TODO
|
||||
1. CUT source ep edge also
|
||||
2. Move SLE settings from LogicCore to an edge? Its visual not math!
|
||||
3. Detect bidirectional edge and correctly display it w/o parallelization
|
||||
4. CHek printing
|
||||
4. CHeck printing
|
||||
|
||||
Add edge labels - labels on path
|
||||
http://www.codeproject.com/Articles/30090/Text-On-A-Path-in-WPF
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
Required by Visual Studio project and item templates
|
||||
-->
|
||||
<ResourceDictionary Source="Common/StandardStyles.xaml"/>
|
||||
<ResourceDictionary Source="Common/templates.xaml"/>
|
||||
<ResourceDictionary Source="Common/templates2.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
|
||||
</ResourceDictionary>
|
||||
|
|
|
@ -54,7 +54,7 @@ namespace METRO.SimpleGraph
|
|||
// When the navigation stack isn't restored navigate to the first page,
|
||||
// configuring the new page by passing required information as a navigation
|
||||
// parameter
|
||||
if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
|
||||
if (!rootFrame.Navigate(typeof(MainPageDebug), args.Arguments))
|
||||
{
|
||||
throw new Exception("Failed to create initial page");
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls1="using:GraphX.Controls">
|
||||
|
||||
|
||||
<Style TargetType="controls1:VertexControl">
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
|
||||
|
@ -172,5 +172,4 @@
|
|||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
|
|
|
@ -3,6 +3,18 @@
|
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls1="using:GraphX.Controls">
|
||||
|
||||
|
||||
<Style x:Key="CirclePath" TargetType="controls1:StaticVertexConnectionPoint">
|
||||
<Setter Property="Shape" Value="Circle"/>
|
||||
|
||||
<Setter Property="Content">
|
||||
<Setter.Value>
|
||||
<Path Stroke="White" Data="M 38,0.791664C 58.5496,0.791664 75.2083,17.4504 75.2083,38C 75.2083,58.5496 58.5496,75.2083 38,75.2083C 17.4504,75.2083 0.791662,58.5496 0.791662,38C 0.791662,17.4504 17.4504,0.791664 38,0.791664 Z M 38,5.54166C 20.0738,5.54166 5.54167,20.0738 5.54167,38C 5.54167,55.9262 20.0738,70.4583 38,70.4583C 55.9262,70.4583 70.4583,55.9262 70.4583,38C 70.4583,20.0738 55.9262,5.54166 38,5.54166 Z "
|
||||
Width="10" Height="10" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- REGION ZoomControl -->
|
||||
|
||||
<SolidColorBrush x:Key="SelectionBrush" Color="LightBlue" Opacity="0.5"/>
|
||||
|
@ -119,18 +131,19 @@
|
|||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls1:VertexControl">
|
||||
<Border Background="{TemplateBinding Background}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
CornerRadius="10,10,10,10"
|
||||
Padding="{TemplateBinding Padding}">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentPresenter Content="{TemplateBinding Vertex}" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition/>
|
||||
<RowDefinition Height="40"/>
|
||||
</Grid.RowDefinitions>
|
||||
<ContentPresenter Content="{TemplateBinding Vertex}" />
|
||||
<Border BorderBrush="Blue" BorderThickness="1" Grid.Row="1">
|
||||
<controls1:StaticVertexConnectionPoint Id="1" Visibility="Visible">
|
||||
<Path Stroke="White" Data="M 38,0.791664C 58.5496,0.791664 75.2083,17.4504 75.2083,38C 75.2083,58.5496 58.5496,75.2083 38,75.2083C 17.4504,75.2083 0.791662,58.5496 0.791662,38C 0.791662,17.4504 17.4504,0.791664 38,0.791664 Z M 38,5.54166C 20.0738,5.54166 5.54167,20.0738 5.54167,38C 5.54167,55.9262 20.0738,70.4583 38,70.4583C 55.9262,70.4583 70.4583,55.9262 70.4583,38C 70.4583,20.0738 55.9262,5.54166 38,5.54166 Z "
|
||||
Width="10" Height="10" Stretch="Uniform" StrokeThickness="1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</controls1:StaticVertexConnectionPoint>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
|
@ -17,6 +17,8 @@
|
|||
<MinimumVisualStudioVersion>12</MinimumVisualStudioVersion>
|
||||
<TargetFrameworkVersion />
|
||||
<PackageCertificateThumbprint>233455ED976F85333F728FB66BE46FA1D70834F7</PackageCertificateThumbprint>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
|
@ -133,6 +135,7 @@
|
|||
<Compile Include="Models\CurvedErParameters.cs" />
|
||||
<Compile Include="Models\DataEdge.cs" />
|
||||
<Compile Include="Models\DataVertex.cs" />
|
||||
<Compile Include="Models\DebugItems.cs" />
|
||||
<Compile Include="Models\GraphAreaExample.cs" />
|
||||
<Compile Include="Models\GraphExample.cs" />
|
||||
<Compile Include="Models\GXLogicCoreExample.cs" />
|
||||
|
@ -166,7 +169,7 @@
|
|||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Common\debug_template.xaml">
|
||||
<Page Include="Common\templates2.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
@ -202,6 +205,13 @@
|
|||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
|
||||
</PropertyGroup>
|
||||
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
|
||||
</Target>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
|
|
@ -12,6 +12,9 @@ using GraphX.Controls.Models;
|
|||
using GraphX.PCL.Common.Enums;
|
||||
using GraphX.PCL.Logic.Algorithms.LayoutAlgorithms;
|
||||
using GraphX.PCL.Logic.Algorithms.OverlapRemoval;
|
||||
using METRO.SimpleGraph.Models;
|
||||
using QuickGraph.Graphviz.Dot;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
namespace METRO.SimpleGraph
|
||||
|
@ -54,15 +57,6 @@ namespace METRO.SimpleGraph
|
|||
private async void butGenerate_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
GraphAreaExample_Setup();
|
||||
|
||||
try
|
||||
{
|
||||
await graph.GenerateGraphAsync(true);
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
// User may have canceled
|
||||
}
|
||||
}
|
||||
|
||||
async void butRelayout_Click(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -45,17 +45,10 @@
|
|||
<Image Stretch="Uniform" Source="Assets/refresh.png" />
|
||||
</Button>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="Layout algorithm:" />
|
||||
<ComboBox x:Name="cboxLayout" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="Overlap algorithm:" />
|
||||
<ComboBox x:Name="cboxOverlap" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<TextBlock Text="Edge routing algorithm:" />
|
||||
<ComboBox x:Name="cboxEdgeRouting" />
|
||||
<TextBlock Text="Debug mode:" />
|
||||
<ComboBox x:Name="cboxDebug" Width="350" />
|
||||
</StackPanel>
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -6,11 +6,13 @@ using Windows.UI.Xaml;
|
|||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using GraphX.Controls;
|
||||
using GraphX.Controls.Animations;
|
||||
using GraphX.Controls.Models;
|
||||
using GraphX.PCL.Common.Enums;
|
||||
using GraphX.PCL.Logic.Algorithms.LayoutAlgorithms;
|
||||
using GraphX.PCL.Logic.Algorithms.OverlapRemoval;
|
||||
using METRO.SimpleGraph.Models;
|
||||
|
||||
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
|
||||
|
||||
|
@ -25,32 +27,112 @@ namespace METRO.SimpleGraph
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
cboxLayout.ItemsSource = Enum.GetValues(typeof(LayoutAlgorithmTypeEnum)).Cast<LayoutAlgorithmTypeEnum>();//.Where(a=> a != LayoutAlgorithmTypeEnum.FR && a != LayoutAlgorithmTypeEnum.BoundedFR).ToArray();
|
||||
cboxOverlap.ItemsSource = Enum.GetValues(typeof(OverlapRemovalAlgorithmTypeEnum)).Cast<OverlapRemovalAlgorithmTypeEnum>();
|
||||
cboxEdgeRouting.ItemsSource = Enum.GetValues(typeof(EdgeRoutingAlgorithmTypeEnum)).Cast<EdgeRoutingAlgorithmTypeEnum>();
|
||||
|
||||
cboxLayout.SelectedItem = LayoutAlgorithmTypeEnum.LinLog;
|
||||
cboxOverlap.SelectedItem = OverlapRemovalAlgorithmTypeEnum.FSA;
|
||||
cboxEdgeRouting.SelectedItem = EdgeRoutingAlgorithmTypeEnum.None;
|
||||
|
||||
cboxLayout.SelectionChanged += cboxLayout_SelectionChanged;
|
||||
cboxOverlap.SelectionChanged += cboxOverlap_SelectionChanged;
|
||||
cboxEdgeRouting.SelectionChanged += cboxEdgeRouting_SelectionChanged;
|
||||
|
||||
butRelayout.Click += butRelayout_Click;
|
||||
butGenerate.Click += butGenerate_Click;
|
||||
graph.GenerateGraphFinished += OnFinishedLayout;
|
||||
graph.RelayoutFinished += OnFinishedLayout;
|
||||
graph.AlignAllEdgesLabels();
|
||||
Loaded += MainPage_Loaded;
|
||||
cboxDebug.ItemsSource = Enum.GetValues(typeof(DebugItems)).Cast<DebugItems>();
|
||||
cboxDebug.SelectionChanged += cboxDebug_SelectionChanged;
|
||||
}
|
||||
|
||||
#region Debug implementation
|
||||
void cboxDebug_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
//graph.VertexList.Values.ForEach(a => a.VertexConnectionPointsList.ForEach(b => b.Hide()));
|
||||
graph.ClearLayout();
|
||||
graph.LogicCore.Graph.Clear();
|
||||
graph.LogicCore.EnableParallelEdges = false;
|
||||
graph.LogicCore.ParallelEdgeDistance = 25;
|
||||
graph.LogicCore.EdgeCurvingEnabled = false;
|
||||
|
||||
graph.SetVerticesDrag(true, true);
|
||||
graph.SetVerticesMathShape(VertexShape.Circle);
|
||||
graph.ShowAllVerticesLabels(false);
|
||||
graph.ShowAllEdgesLabels(false);
|
||||
graph.AlignAllEdgesLabels(false);
|
||||
|
||||
switch ((DebugItems)cboxDebug.SelectedItem)
|
||||
{
|
||||
case DebugItems.General:
|
||||
DebugGeneral();
|
||||
break;
|
||||
case DebugItems.EdgeLabels:
|
||||
DebugEdgeLabels();
|
||||
break;
|
||||
case DebugItems.VCP:
|
||||
DebugVCP();
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DebugVCP()
|
||||
{
|
||||
graph.LogicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK;
|
||||
|
||||
var dataVertex = new DataVertex("MyVertex 1") { VisualDiameter = 20 };
|
||||
graph.LogicCore.Graph.AddVertex(dataVertex);
|
||||
dataVertex = new DataVertex("MyVertex 2") { VisualDiameter = 20 };
|
||||
graph.LogicCore.Graph.AddVertex(dataVertex);
|
||||
|
||||
var vlist = graph.LogicCore.Graph.Vertices.ToList();
|
||||
AddEdge((GraphExample)graph.LogicCore.Graph, 0, 1, vlist);
|
||||
graph.LogicCore.Graph.Edges.Last().SourceConnectionPointId = 1;
|
||||
graph.LogicCore.Graph.Edges.Last().TargetConnectionPointId = 1;
|
||||
|
||||
graph.GenerateGraphAsync();
|
||||
}
|
||||
|
||||
private void DebugGeneral()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void DebugEdgeLabels()
|
||||
{
|
||||
graph.LogicCore.DefaultLayoutAlgorithm = LayoutAlgorithmTypeEnum.KK;
|
||||
graph.ShowAllEdgesLabels();
|
||||
graph.AlignAllEdgesLabels();
|
||||
graph.UpdateEdgeLabelPosition(true);
|
||||
|
||||
DebugCreateVertex("MyVertex 1");
|
||||
DebugCreateVertex("MyVertex 2");
|
||||
|
||||
var vlist = graph.LogicCore.Graph.Vertices.ToList();
|
||||
AddEdge((GraphExample)graph.LogicCore.Graph, 0, 1, vlist);
|
||||
|
||||
graph.GenerateGraphAsync();
|
||||
}
|
||||
|
||||
private void DebugOnFinished()
|
||||
{
|
||||
switch ((DebugItems)cboxDebug.SelectedItem)
|
||||
{
|
||||
case DebugItems.General:
|
||||
break;
|
||||
case DebugItems.EdgeLabels:
|
||||
break;
|
||||
case DebugItems.VCP:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private DataVertex DebugCreateVertex(string name)
|
||||
{
|
||||
var x = new DataVertex(name) { VisualDiameter = 20 };
|
||||
graph.LogicCore.Graph.AddVertex(x);
|
||||
return x;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
void OnFinishedLayout(object sender, EventArgs e)
|
||||
{
|
||||
zc.ZoomToFill();
|
||||
|
||||
//var count = 0;
|
||||
|
||||
DebugOnFinished();
|
||||
}
|
||||
|
||||
private async void butGenerate_Click(object sender, RoutedEventArgs e)
|
||||
|
@ -81,31 +163,6 @@ namespace METRO.SimpleGraph
|
|||
}
|
||||
}
|
||||
|
||||
void cboxEdgeRouting_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (graph.LogicCore == null) return;
|
||||
graph.LogicCore.DefaultEdgeRoutingAlgorithm = (EdgeRoutingAlgorithmTypeEnum)cboxEdgeRouting.SelectedItem;
|
||||
}
|
||||
|
||||
void cboxOverlap_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (graph.LogicCore == null) return;
|
||||
graph.LogicCore.DefaultOverlapRemovalAlgorithm = (OverlapRemovalAlgorithmTypeEnum)cboxOverlap.SelectedItem;
|
||||
}
|
||||
|
||||
void cboxLayout_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if(graph.LogicCore == null) return;
|
||||
var late = (LayoutAlgorithmTypeEnum) cboxLayout.SelectedItem;
|
||||
graph.LogicCore.DefaultLayoutAlgorithm = late;
|
||||
if (late == LayoutAlgorithmTypeEnum.BoundedFR)
|
||||
graph.LogicCore.DefaultLayoutAlgorithmParams
|
||||
= graph.LogicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.BoundedFR);
|
||||
if (late == LayoutAlgorithmTypeEnum.FR)
|
||||
graph.LogicCore.DefaultLayoutAlgorithmParams
|
||||
= graph.LogicCore.AlgorithmFactory.CreateLayoutParameters(LayoutAlgorithmTypeEnum.FR);
|
||||
}
|
||||
|
||||
async void MainPage_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
InitialSetup();
|
||||
|
@ -132,11 +189,6 @@ namespace METRO.SimpleGraph
|
|||
{
|
||||
// User may have canceled
|
||||
}
|
||||
|
||||
//graph.RelayoutGraph(true);
|
||||
//zc.ZoomToFill();
|
||||
//graph.VertexList.Values.ToList()[0].SetPosition(new Point(0, 0));
|
||||
//graph.VertexList.Values.ToList()[1].SetPosition(new Point(100, 0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -173,100 +225,6 @@ namespace METRO.SimpleGraph
|
|||
var vlist = dataGraph.Vertices.ToList();
|
||||
AddEdge(dataGraph, 0, 1, vlist);
|
||||
return dataGraph;
|
||||
|
||||
|
||||
|
||||
switch ((LayoutAlgorithmTypeEnum)cboxLayout.SelectedItem)
|
||||
{
|
||||
case LayoutAlgorithmTypeEnum.EfficientSugiyama:
|
||||
case LayoutAlgorithmTypeEnum.Sugiyama:
|
||||
case LayoutAlgorithmTypeEnum.BoundedFR:
|
||||
case LayoutAlgorithmTypeEnum.FR:
|
||||
case LayoutAlgorithmTypeEnum.Tree:
|
||||
for (int i = 1; i < 14; i++)
|
||||
{
|
||||
var dataVertex = new DataVertex("MyVertex " + i) { ID = i, VisualDiameter = _rnd.Next(25, 50), VisualInnerDiameter = _rnd.Next(10, 22) };
|
||||
dataGraph.AddVertex(dataVertex);
|
||||
}
|
||||
vlist = dataGraph.Vertices.ToList();
|
||||
AddEdge(dataGraph, 0, 1, vlist);
|
||||
AddEdge(dataGraph, 0, 2, vlist);
|
||||
AddEdge(dataGraph, 1, 3, vlist);
|
||||
AddEdge(dataGraph, 1, 4, vlist);
|
||||
AddEdge(dataGraph, 2, 5, vlist);
|
||||
AddEdge(dataGraph, 2, 6, vlist);
|
||||
AddEdge(dataGraph, 2, 7, vlist);
|
||||
|
||||
AddEdge(dataGraph, 8, 9, vlist);
|
||||
AddEdge(dataGraph, 9, 10, vlist);
|
||||
AddEdge(dataGraph, 10, 7, vlist);
|
||||
AddEdge(dataGraph, 10, 11, vlist);
|
||||
AddEdge(dataGraph, 10, 12, vlist);
|
||||
|
||||
break;
|
||||
default:
|
||||
for (var i = 1; i < 11; i++)
|
||||
{
|
||||
var dataVertex = new DataVertex("MyVertex " + i) { ID = i, VisualDiameter = _rnd.Next(50, 100), VisualInnerDiameter = _rnd.Next(20, 45) };
|
||||
if (i == 2)
|
||||
dataVertex.LabelText += "\nMultiline!";
|
||||
dataGraph.AddVertex(dataVertex);
|
||||
}
|
||||
vlist = dataGraph.Vertices.ToList();
|
||||
AddEdge(dataGraph, 0, 1, vlist);
|
||||
|
||||
AddEdge(dataGraph, 1, 2, vlist);
|
||||
AddEdge(dataGraph, 1, 3, vlist);
|
||||
AddEdge(dataGraph, 1, 4, vlist);
|
||||
|
||||
AddEdge(dataGraph, 4, 5, vlist);
|
||||
AddEdge(dataGraph, 4, 6, vlist);
|
||||
|
||||
AddEdge(dataGraph, 2, 7, vlist);
|
||||
AddEdge(dataGraph, 2, 8, vlist);
|
||||
|
||||
AddEdge(dataGraph, 8, 9, vlist);
|
||||
|
||||
//add some cross references
|
||||
AddEdge(dataGraph, 4, 2, vlist);
|
||||
AddEdge(dataGraph, 4, 8, vlist);
|
||||
AddEdge(dataGraph, 9, 2, vlist);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* foreach (var item in graph.EdgesList)
|
||||
{
|
||||
//item.Value.LabelVerticalOffset = -40;
|
||||
item.Value.LabelAngle = 45;
|
||||
}*/
|
||||
|
||||
|
||||
return dataGraph;
|
||||
|
||||
/*ManipulationDelta += MainPage_ManipulationDelta;
|
||||
ManipulationMode = ManipulationModes.Scale;
|
||||
|
||||
for (int i = 1; i < 10; i++)
|
||||
{
|
||||
var dataVertex = new DataVertex("MyVertex " + i) { ID = i };
|
||||
dataGraph.AddVertex(dataVertex);
|
||||
}
|
||||
|
||||
var vlist = dataGraph.Vertices.ToList();
|
||||
//var dataEdge = new DataEdge(vlist[0], vlist[1]) { Text = string.Format("{0} -> {1}", vlist[0], vlist[1]) };
|
||||
//dataGraph.AddEdge(dataEdge);
|
||||
var dataEdge = new DataEdge(vlist[2], vlist[3]) { Text = "23" };
|
||||
dataGraph.AddEdge(dataEdge);
|
||||
dataEdge = new DataEdge(vlist[3], vlist[2]) { Text = "32" };
|
||||
dataGraph.AddEdge(dataEdge);
|
||||
|
||||
return dataGraph;*/
|
||||
}
|
||||
|
||||
void MainPage_ManipulationDelta(object sender, ManipulationDeltaRoutedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void InitialSetup()
|
||||
|
@ -293,43 +251,6 @@ namespace METRO.SimpleGraph
|
|||
var dataGraph = GraphExample_Setup();
|
||||
logicCore.Graph = dataGraph;
|
||||
|
||||
|
||||
/*LogicCore.DefaultLayoutAlgorithmParams = LogicCore.AlgorithmFactory.CreateLayoutParameters(GraphX.LayoutAlgorithmTypeEnum.KK);
|
||||
((KKLayoutParameters)LogicCore.DefaultLayoutAlgorithmParams).MaxIterations = 100;
|
||||
cboxOverlap.SelectedItem = OverlapRemovalAlgorithmTypeEnum.FSA;
|
||||
|
||||
cboxEdgeRouting.SelectedItem = EdgeRoutingAlgorithmTypeEnum.SimpleER;
|
||||
LogicCore.AsyncAlgorithmCompute = false;
|
||||
|
||||
graph.SetVerticesHighlight(true, GraphControlType.VertexAndEdge, EdgesType.All);
|
||||
graph.SetEdgesHighlight(true, GraphControlType.VertexAndEdge);
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
switch ((LayoutAlgorithmTypeEnum) cboxLayout.SelectedItem)
|
||||
{
|
||||
case LayoutAlgorithmTypeEnum.EfficientSugiyama:
|
||||
logicCore.DefaultLayoutAlgorithmParams = new EfficientSugiyamaLayoutParameters { VertexDistance = 50 };
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
switch ((LayoutAlgorithmTypeEnum)cboxLayout.SelectedItem)
|
||||
{
|
||||
case LayoutAlgorithmTypeEnum.EfficientSugiyama:
|
||||
case LayoutAlgorithmTypeEnum.Sugiyama:
|
||||
case LayoutAlgorithmTypeEnum.BoundedFR:
|
||||
case LayoutAlgorithmTypeEnum.FR:
|
||||
case LayoutAlgorithmTypeEnum.Tree:
|
||||
cboxEdgeRouting.SelectedItem = EdgeRoutingAlgorithmTypeEnum.SimpleER;
|
||||
break;
|
||||
default:
|
||||
cboxEdgeRouting.SelectedItem = EdgeRoutingAlgorithmTypeEnum.SimpleER;
|
||||
break;
|
||||
}
|
||||
|
||||
logicCore.EnableParallelEdges = true;
|
||||
logicCore.ParallelEdgeDistance = 25;
|
||||
logicCore.EdgeCurvingEnabled = true;
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
namespace METRO.SimpleGraph.Models
|
||||
{
|
||||
public enum DebugItems
|
||||
{
|
||||
General = 0,
|
||||
EdgeLabels = 1,
|
||||
VCP = 2,
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ using System.ComponentModel;
|
|||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using GraphX.Controls;
|
||||
using GraphX.Controls.Animations;
|
||||
using GraphX.Controls.Models;
|
||||
using GraphX.PCL.Common.Enums;
|
||||
|
@ -91,6 +92,15 @@ namespace ShowcaseApp.WPF.Pages
|
|||
dg_Area.LogicCore.DefaultEdgeRoutingAlgorithm = EdgeRoutingAlgorithmTypeEnum.None;
|
||||
|
||||
dg_Area.GenerateGraph(true);
|
||||
|
||||
var vertex = dg_Area.VertexList[edge.Target];
|
||||
var vcp = vertex.VertexConnectionPointsList.First();
|
||||
var newVcp = new StaticVertexConnectionPoint() {Id = 5};
|
||||
((StackPanel)((Border) vcp.GetParent()).Parent).Children.Add(newVcp);
|
||||
edge.TargetConnectionPointId = 5;
|
||||
vertex.VertexConnectionPointsList.Add(newVcp);
|
||||
dg_Area.EdgesList[edge].UpdateEdge();
|
||||
//dg_Area.UpdateAllEdges(true);
|
||||
}
|
||||
|
||||
void butRelayout_Click(object sender, RoutedEventArgs e)
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<Setter Property="Background" Value="LightGray"/>
|
||||
</Style>-->
|
||||
|
||||
<Style x:Key="CirclePath" TargetType="controls:StaticVertexConnectionPoint" x:Shared="False">
|
||||
<Style TargetType="controls:StaticVertexConnectionPoint" x:Shared="False">
|
||||
<Setter Property="Shape" Value="Circle"/>
|
||||
|
||||
<Setter Property="Content">
|
||||
|
@ -32,18 +32,18 @@
|
|||
<ContentPresenter Content="{TemplateBinding Vertex}" Grid.Column="1"/>
|
||||
<StackPanel Orientation="Vertical" Grid.Column="0">
|
||||
<Border Padding="0" Margin="2,2,0,2">
|
||||
<controls:StaticVertexConnectionPoint Id="1" Style="{StaticResource CirclePath}"/>
|
||||
<controls:StaticVertexConnectionPoint Id="1" />
|
||||
</Border>
|
||||
<Border Padding="0" Margin="2,2,0,2">
|
||||
<controls:StaticVertexConnectionPoint Id="2" Style="{StaticResource CirclePath}"/>
|
||||
<controls:StaticVertexConnectionPoint Id="2" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" Grid.Column="2">
|
||||
<Border Padding="0" Margin="0,2,2,2">
|
||||
<controls:StaticVertexConnectionPoint Id="3" Style="{StaticResource CirclePath}"/>
|
||||
<controls:StaticVertexConnectionPoint Id="3" />
|
||||
</Border>
|
||||
<Border Padding="0" Margin="0,2,2,2">
|
||||
<controls:StaticVertexConnectionPoint Id="4" Style="{StaticResource CirclePath}"/>
|
||||
<controls:StaticVertexConnectionPoint Id="4" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
|
|
@ -76,7 +76,7 @@ namespace GraphX.Controls
|
|||
typeof(EdgeControlBase),
|
||||
new PropertyMetadata(5d));
|
||||
/// <summary>
|
||||
/// Radius of a self-loop edge, which is drawn as a circle. Default is 20.
|
||||
/// Radius of the default self-loop indicator, which is drawn as a circle (when custom template isn't provided). Default is 20.
|
||||
/// </summary>
|
||||
public double SelfLoopIndicatorRadius {
|
||||
get { return (double)GetValue(SelfLoopIndicatorRadiusProperty); }
|
||||
|
@ -88,7 +88,7 @@ namespace GraphX.Controls
|
|||
typeof(EdgeControlBase),
|
||||
new PropertyMetadata(new Point()));
|
||||
/// <summary>
|
||||
/// Offset from the corner of the vertex. Useful for custom vertex shapes. Default is 10,10.
|
||||
/// Offset from the left-top corner of the vertex. Useful for custom vertex shapes. Default is 10,10.
|
||||
/// </summary>
|
||||
public Point SelfLoopIndicatorOffset
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ namespace GraphX.Controls
|
|||
typeof(EdgeControlBase),
|
||||
new PropertyMetadata(true));
|
||||
/// <summary>
|
||||
/// Show self looped edges on vertices. Default value is true.
|
||||
/// Show self looped edge indicator on the vertex top-left corner. Default value is true.
|
||||
/// </summary>
|
||||
public bool ShowSelfLoopIndicator
|
||||
{
|
||||
|
@ -482,27 +482,15 @@ namespace GraphX.Controls
|
|||
#region public PrepareEdgePath()
|
||||
|
||||
/// <summary>
|
||||
/// Internal. Complete edge update pass
|
||||
/// Complete edge update pass. Don't needed to be run manualy until some edge related modifications are done requiring full edge update.
|
||||
/// </summary>
|
||||
/// <param name="updateLabel">Update label data</param>
|
||||
internal virtual void UpdateEdge(bool updateLabel = true)
|
||||
public virtual void UpdateEdge(bool updateLabel = true)
|
||||
{
|
||||
if (Visibility == Visibility.Visible || IsHiddenEdgesUpdated)
|
||||
{
|
||||
UpdateEdgeRendering(updateLabel);
|
||||
|
||||
/* if (_edgePointerForSource != null)
|
||||
{
|
||||
if (ShowArrows && !IsSelfLooped) _edgePointerForSource.Show();
|
||||
else _edgePointerForSource.Hide();
|
||||
}
|
||||
|
||||
if (_edgePointerForTarget != null)
|
||||
{
|
||||
if (ShowArrows && !IsSelfLooped) _edgePointerForTarget.Show();
|
||||
else _edgePointerForTarget.Hide();
|
||||
}*/
|
||||
|
||||
if (_edgeLabelControl != null)
|
||||
if (ShowLabel) _edgeLabelControl.Show(); else _edgeLabelControl.Hide();
|
||||
}
|
||||
|
|
|
@ -26,5 +26,6 @@ namespace GraphX.Controls
|
|||
Rect RectangularSize { get; }
|
||||
|
||||
void Update();
|
||||
DependencyObject GetParent();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ namespace GraphX.Controls
|
|||
_vertexControl = null;
|
||||
}
|
||||
#if WPF
|
||||
DependencyObject GetParent()
|
||||
public DependencyObject GetParent()
|
||||
{
|
||||
return VisualParent;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace GraphX.Controls
|
|||
RectangularSize = new Rect(position, DesiredSize);
|
||||
}
|
||||
#elif METRO
|
||||
DependencyObject GetParent()
|
||||
public DependencyObject GetParent()
|
||||
{
|
||||
return Parent;
|
||||
}
|
||||
|
|
|
@ -119,5 +119,11 @@ namespace GraphX.Controls
|
|||
{
|
||||
return new Point(rect.X + rect.Width * .5, rect.Y + rect.Height * .5);
|
||||
}
|
||||
|
||||
public static void ForEach<T>(this IEnumerable<T> list, Action<T> func)
|
||||
{
|
||||
foreach (var item in list)
|
||||
func(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче