+ Solved file operations problem
+ Some tweaks implemented
+ Rebuilt all strong name files
+ Fixed incorrect references
This commit is contained in:
panthernet 2014-05-16 17:54:59 +04:00
Родитель a3b2dcb8dd
Коммит 997a1f3302
20 изменённых файлов: 128 добавлений и 80 удалений

Просмотреть файл

@ -1,8 +1,13 @@
RELEASE 2.1.0 WIP
RELEASE 2.1.1 WIP
+ Redesigned libraries for PCL implementation
This shouldn't lead to major problems but some breaks will definetly occur:
- All routines in Logic library now operates with custom System.Windows types (platform-specific libraries operates (externaly) with System.Windows types). This includes any custom algorithms.
- GraphX.Controls assembly was renamed to GraphX.WPF.Controls assembly
- DataSaveModel class renamed to GraphSerializationData
- Althought file operations such as Save/load layout remains the same for the end user the background logic of this features has been changed:
- Implemented IFileServiceProvider interface and corresponding property in GXLogicCore class
- When you assign GraphArea::LogicCore property the new default (platform-specific) FileServiceProvider is created and assigned to LogicCore automaticaly (if corresponding property is null)
- You can create custom FileServiceProviders to work with 3rd party serialization libraries or code your own file operations logic
+ Improvement: GXLogicCore expected concrete class as TGraph (thanks to stefanpe)
+ Removed redundant dependencies (reworked some dependencies)

Просмотреть файл

@ -1,4 +1,5 @@
using System.Drawing;
using GraphX.Controls;
using GraphX.Controls.Models;
using GraphX.GraphSharp.Algorithms.EdgeRouting;
using GraphX.GraphSharp.Algorithms.Layout;
@ -30,7 +31,14 @@ namespace GraphX
#region My properties
public static readonly DependencyProperty LogicCoreProperty =
DependencyProperty.Register("LogicCore", typeof(IGXLogicCore<TVertex, TEdge, TGraph>), typeof(GraphArea<TVertex, TEdge, TGraph>), new UIPropertyMetadata(null));
DependencyProperty.Register("LogicCore", typeof(IGXLogicCore<TVertex, TEdge, TGraph>), typeof(GraphArea<TVertex, TEdge, TGraph>), new UIPropertyMetadata(null, logic_core_changed));
private static void logic_core_changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//automaticaly assign default file service provider
if(e.NewValue != null && ((IGXLogicCore<TVertex, TEdge, TGraph>)e.NewValue).FileServiceProvider == null)
((IGXLogicCore<TVertex, TEdge, TGraph>)e.NewValue).FileServiceProvider = new FileServiceProviderWpf();
}
/// <summary>
/// Gets or sets GraphX logic core object that will drive this visual
@ -163,7 +171,7 @@ namespace GraphX
{
ControlFactory = new GraphControlFactory();
ControlFactory.FactoryRootArea = this;
StateStorage = new StateStorage<TVertex, TEdge, TGraph>(this);
StateStorage = new StateStorage<TVertex, TEdge, TGraph>(this);
EnableVisualPropsRecovery = true;
EnableVisualPropsApply = true;
//CacheMode = new BitmapCache(2) { EnableClearType = false, SnapsToDevicePixels = true };
@ -1267,36 +1275,43 @@ namespace GraphX
{
if (LogicCore == null)
throw new GX_InvalidDataException("LogicCore -> Not initialized!");
if (LogicCore.FileServiceProvider == null)
throw new GX_ObjectNotFoundException("LogicCore::FileServiceProvider must be set before using file operation methods!");
if (autoAssignMissingDataId)
{
AutoresolveIds();
}
var dlist = new List<DataSaveModel>();
var dlist = new List<GraphSerializationData>();
foreach (var item in VertexList) //ALWAYS serialize vertices first
{
dlist.Add(new DataSaveModel { Position = item.Value.GetPositionGraphX(), Data = item.Key });
dlist.Add(new GraphSerializationData { Position = item.Value.GetPositionGraphX(), Data = item.Key });
if (item.Key.ID == -1) throw new GX_InvalidDataException("SaveIntoFile() -> All vertex datas must have positive unique ID!");
}
foreach (var item in EdgesList)
{
// item.Key.RoutingPoints = new Point[] { new Point(0, 123), new Point(12, 12), new Point(10, 234.5) };
dlist.Add(new DataSaveModel { Position = new Measure.Point(), Data = item.Key });
dlist.Add(new GraphSerializationData { Position = new Measure.Point(), Data = item.Key });
if (item.Key.ID == -1) throw new GX_InvalidDataException("SaveIntoFile() -> All edge datas must have positive unique ID!");
}
LogicCore.SaveDataToFile(filename, dlist);
LogicCore.FileServiceProvider.SerializeDataToFile(filename, dlist);
}
public void LoadFromFile(string filename)
{
if (LogicCore == null)
throw new GX_InvalidDataException("LogicCore -> Not initialized!");
if (LogicCore.FileServiceProvider == null)
throw new GX_ObjectNotFoundException("LogicCore::FileServiceProvider must be set before using file operation methods!");
RemoveAllEdges();
RemoveAllVertices();
var data = LogicCore.LoadDataFromFile(filename);
var data = LogicCore.FileServiceProvider.DeserializeDataFromFile(filename);
if (LogicCore.Graph == null) LogicCore.Graph = Activator.CreateInstance<TGraph>();
else LogicCore.Graph.Clear();

Просмотреть файл

@ -78,10 +78,6 @@
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="YAXLib, Version=2.12.0.0, Culture=neutral, PublicKeyToken=7cc39f8266ad1835, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\YAXLib.2.12\lib\YAXLib.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\Documents\AIV.cs">
@ -124,6 +120,7 @@
<Compile Include="Models\EdgeEventOptions.cs" />
<Compile Include="Models\EdgeSelectedEventArgs.cs" />
<Compile Include="Models\EdgeSelectedEventHandler.cs" />
<Compile Include="Models\FileServiceProviderWPF.cs" />
<Compile Include="Models\GraphControlFactory.cs" />
<Compile Include="Models\IBidirectionalControlAnimation.cs" />
<Compile Include="Models\IGraphArea.cs" />
@ -176,6 +173,10 @@
<Project>{2c800806-b034-4282-b735-dbe6da633cbb}</Project>
<Name>YAXLib.PCL.Common</Name>
</ProjectReference>
<ProjectReference Include="..\YAXLib\YAXLib\YAXLib.csproj">
<Project>{f1c4d174-c948-4d18-a125-f6855ef55683}</Project>
<Name>YAXLib %28YAXLib\YAXLib%29</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />

Просмотреть файл

@ -0,0 +1,40 @@
using System.Collections.Generic;
using System.IO;
using GraphX.Models;
using YAXLib;
namespace GraphX.Controls
{
/// <summary>
/// WPF implementation of IFileServiceProvider
/// </summary>
public class FileServiceProviderWpf: IFileServiceProvider
{
/// <summary>
/// Serializes data classes list to file
/// </summary>
/// <param name="filename">File name</param>
/// <param name="modelsList">Data classes list</param>
public void SerializeDataToFile(string filename, List<GraphSerializationData> modelsList)
{
var serializer = new YAXSerializer(typeof(List<GraphSerializationData>));
using (var textWriter = new StreamWriter(filename))
{
serializer.Serialize(modelsList, textWriter);
textWriter.Close();
}
}
/// <summary>
/// Deserializes data classes list from file
/// </summary>
/// <param name="filename">File name</param>
public List<GraphSerializationData> DeserializeDataFromFile(string filename)
{
var deserializer = new YAXSerializer(typeof(List<GraphSerializationData>));
using (var textReader = new StreamReader(filename))
{
return (List<GraphSerializationData>)deserializer.Deserialize(textReader);
}
}
}
}

Просмотреть файл

@ -3,14 +3,14 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GraphX"
xmlns:po="http://schemas.microsoft.com/winfx/2006/xaml/presentation/options"
xmlns:Controls="clr-namespace:GraphX.Controls"
xmlns:controls="clr-namespace:GraphX.Controls"
xmlns:conv="clr-namespace:GraphX.Converters"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
>
<conv:DoubleToLog10Converter x:Key="log10Converter" />
<conv:EqualityToBooleanConverter x:Key="equalityConverter" />
<conv:DoubleToLog10Converter x:Key="Log10Converter" />
<conv:EqualityToBooleanConverter x:Key="EqualityConverter" />
<conv:RoundedValueConverter x:Key="RoundedValueConverter" Precision="2" />
<conv:VisibilityToBoolConverter x:Key="TrueIfVisibleConverter"
@ -59,7 +59,7 @@
<Style x:Key="ViewFinderToggleButtonStyle" BasedOn="{StaticResource TransparentButton}" TargetType="{x:Type ToggleButton}">
<Setter Property="Visibility" Value="Visible" />
<Style.Triggers>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:ZoomControl}}, Path=ViewFinderVisibility}" Value="Hidden">
<DataTrigger Binding="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls:ZoomControl}}, Path=ViewFinderVisibility}" Value="Hidden">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
@ -256,10 +256,10 @@
</DrawingImage.Drawing>
</DrawingImage>
<Style TargetType="{x:Type Controls:ZoomControl}">
<Style TargetType="{x:Type controls:ZoomControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ZoomControl}">
<ControlTemplate TargetType="{x:Type controls:ZoomControl}">
<ControlTemplate.Resources>
<SolidColorBrush x:Key="SelectionBrush" Color="LightBlue" Opacity="0.5" po:Freeze="True"/>
<SolidColorBrush x:Key="AreaSelectionBrush" Color="LightGreen" Opacity="0.5" po:Freeze="True"/>
@ -282,7 +282,7 @@
BorderThickness="{TemplateBinding BorderThickness}"
Background="{TemplateBinding Background}"
ClipToBounds="{TemplateBinding ClipToBounds}">
<Controls:ZoomContentPresenter x:Name="PART_Presenter"
<controls:ZoomContentPresenter x:Name="PART_Presenter"
ClipToBounds="False" />
</Border>
@ -301,9 +301,9 @@
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Margin="0,0,0,3">
<Slider Height="10" Width="100"
Minimum="{TemplateBinding MinZoom,Converter={StaticResource log10Converter}}"
Maximum="{TemplateBinding MaxZoom,Converter={StaticResource log10Converter}}"
Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Zoom,Mode=TwoWay,Converter={StaticResource log10Converter}}"
Minimum="{TemplateBinding MinZoom,Converter={StaticResource Log10Converter}}"
Maximum="{TemplateBinding MaxZoom,Converter={StaticResource Log10Converter}}"
Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Zoom,Mode=TwoWay,Converter={StaticResource Log10Converter}}"
HorizontalAlignment="Center"
Ticks="0.1, 0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2"
AutoToolTipPlacement="BottomRight"
@ -315,22 +315,22 @@
Orientation="Horizontal"
IsEnabled="True"
/>
<Button IsEnabled="False" x:Name="FitButton" Command="Controls:ZoomControl.Fit" ToolTip="Fit Content within Bounds" Width="20px" Height="20px" Margin="2,0" Style="{StaticResource TransparentButton}">
<Button IsEnabled="False" x:Name="FitButton" Command="controls:ZoomControl.Fit" ToolTip="Fit Content within Bounds" Width="20px" Height="20px" Margin="2,0" Style="{StaticResource TransparentButton}">
<Image Source="{StaticResource FitContentGlyph}" Margin="2" po:Freeze ="true"/>
</Button>
<Button x:Name="FillButton" Command="Controls:ZoomControl.Fill" ToolTip="Fill Bounds with Content" Width="20px" Height="20px" Margin="2,0" Style="{StaticResource TransparentButton}">
<Button x:Name="FillButton" Command="controls:ZoomControl.Fill" ToolTip="Fill Bounds with Content" Width="20px" Height="20px" Margin="2,0" Style="{StaticResource TransparentButton}">
<Image Source="{StaticResource FillToBoundsGlyph}" Margin="2" po:Freeze ="true"/>
</Button>
<Button x:Name="CenterButton" Command="Controls:ZoomControl.Center" ToolTip="Center Content" Width="20px" Height="20px" Margin="2,0" Style="{StaticResource TransparentButton}">
<Button x:Name="CenterButton" Command="controls:ZoomControl.Center" ToolTip="Center Content" Width="20px" Height="20px" Margin="2,0" Style="{StaticResource TransparentButton}">
<Image Source="{StaticResource CenterGlyph}" Margin="2" po:Freeze ="true"/>
</Button>
</StackPanel>
<ToggleButton x:Name="ToggleViewFinderButton" ToolTip="Hide View Finder" Height="13" Width="13" Margin="0,2,0,0" HorizontalAlignment="Right" VerticalAlignment="Top"
<ToggleButton Grid.Row="0" x:Name="ToggleViewFinderButton" ToolTip="Hide View Finder" Height="13" Width="13" Margin="0,2,0,0" HorizontalAlignment="Right" VerticalAlignment="Top"
Style="{StaticResource TransparentButton}" Foreground="White" IsChecked="{Binding ElementName=ShowViewFinder, Path=IsChecked}" >
<Image Source="{StaticResource CloseXDrawingImage}" Margin="2" po:Freeze ="true"/>
</ToggleButton>
<Border Grid.Row="1" BorderBrush="{StaticResource GlyphBrush}" BorderThickness="2" Background="#80FFFFFF" />
<Controls:ViewFinderDisplay Grid.Row="1" x:Name="ViewFinderDisplay" ClipToBounds="True" Background="#C0FFFFFF" Margin="2" ShadowBrush="#80FFFFFF" ViewportBrush="Transparent" ViewportPen="{StaticResource ViewportPen}" />
<controls:ViewFinderDisplay Grid.Row="1" x:Name="ViewFinderDisplay" ClipToBounds="True" Background="#C0FFFFFF" Margin="2" ShadowBrush="#80FFFFFF" ViewportBrush="Transparent" ViewportPen="{StaticResource ViewportPen}" />
</Grid>
</Border>
<ToggleButton Name="ShowViewFinder" IsTabStop="False" ToolTip="Show View Finder" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5" Height="22" Width="22"

Двоичные данные
GraphX.Controls/signature.snk

Двоичный файл не отображается.

Просмотреть файл

@ -70,6 +70,7 @@
<Compile Include="Interfaces\IExternalEdgeRouting.cs" />
<Compile Include="Interfaces\IExternalLayout.cs" />
<Compile Include="Interfaces\IExternalOverlapRemoval.cs" />
<Compile Include="Interfaces\IFileServiceProvider.cs" />
<Compile Include="Interfaces\IGraphXEdge.cs" />
<Compile Include="Interfaces\IGraphXVertex.cs" />
<Compile Include="Interfaces\IGXLogicCore.cs" />
@ -78,7 +79,7 @@
<Compile Include="Interfaces\IOverlapRemovalAlgorithm.cs" />
<Compile Include="Interfaces\IOverlapRemovalParameters.cs" />
<Compile Include="Interfaces\IWeightedEdge.cs" />
<Compile Include="Models\DataSaveModel.cs" />
<Compile Include="Models\GraphSerializationData.cs" />
<Compile Include="Models\EdgeBase.cs" />
<Compile Include="Models\EdgeRoutingVisualData.cs" />
<Compile Include="Models\GraphState.cs" />

Просмотреть файл

@ -0,0 +1,21 @@
using System.Collections.Generic;
using GraphX.Models;
namespace GraphX
{
public interface IFileServiceProvider
{
/// <summary>
/// Serializes specified list of data classes into file
/// </summary>
/// <param name="filename">File name</param>
/// <param name="modelsList">Data classes list</param>
void SerializeDataToFile(string filename, List<GraphSerializationData> modelsList);
/// <summary>
/// Deserializes specified file data into data classes list
/// </summary>
/// <param name="filename"></param>
/// <returns></returns>
List<GraphSerializationData> DeserializeDataFromFile(string filename);
}
}

Просмотреть файл

@ -30,6 +30,8 @@ namespace GraphX
bool EnableEdgeLabelsOverlapRemoval { get; set; }
bool IsCustomLayout { get; }
IFileServiceProvider FileServiceProvider { get; set; }
LayoutAlgorithmTypeEnum DefaultLayoutAlgorithm { get; set; }
OverlapRemovalAlgorithmTypeEnum DefaultOverlapRemovalAlgorithm { get; set; }
EdgeRoutingAlgorithmTypeEnum DefaultEdgeRoutingAlgorithm { get; set; }
@ -40,8 +42,6 @@ namespace GraphX
void CreateNewAlgorithmFactory();
void CreateNewAlgorithmStorage(IExternalLayout<TVertex> layout, IExternalOverlapRemoval<TVertex> or, IExternalEdgeRouting<TVertex, TEdge> er);
void SaveDataToFile(string filename, List<DataSaveModel> modelsList);
List<DataSaveModel> LoadDataFromFile(string filename);
bool AreVertexSizesNeeded();
bool AreOverlapNeeded();
@ -49,6 +49,5 @@ namespace GraphX
IExternalOverlapRemoval<TVertex> GenerateOverlapRemovalAlgorithm(Dictionary<TVertex, Rect> rectangles = null);
IExternalEdgeRouting<TVertex, TEdge> GenerateEdgeRoutingAlgorithm(Size DesiredSize);
}
}

Просмотреть файл

@ -1,10 +1,8 @@
using GraphX.Measure;
using GraphX.Models.XmlSerializer;
using YAXLib;
namespace GraphX.Models
{
public class DataSaveModel
public class GraphSerializationData
{
public object Data { get; set; }
public Point Position { get; set; }

Двоичные данные
GraphX.PCL.Common/signature.snk

Двоичный файл не отображается.

Просмотреть файл

@ -32,6 +32,14 @@ namespace GraphX.Logic
public IAlgorithmStorage<TVertex, TEdge> AlgorithmStorage { get; set; }
#endregion
/// <summary>
/// Gets or sets file operations provider for GXCore
/// </summary>
public IFileServiceProvider FileServiceProvider { get; set; }
/// <summary>
/// Gets or sets if if edge label overlap removal enabled
/// </summary>
public bool EnableEdgeLabelsOverlapRemoval { get; set; }
/// <summary>
@ -146,37 +154,5 @@ namespace GraphX.Logic
{
AlgorithmStorage = new AlgorithmStorage<TVertex, TEdge>(layout, or, er);
}
/*//!PCL-TODO! public void SaveDataToFile(string filename, List<DataSaveModel> modelsList)
{
var serializer = new YAXSerializer(typeof(List<DataSaveModel>));
using (var textWriter = new StreamWriter(filename))
{
serializer.Serialize(modelsList, textWriter);
textWriter.Close();
}
}
public List<DataSaveModel> LoadDataFromFile(string filename)
{
var deserializer = new YAXSerializer(typeof(List<DataSaveModel>));
using (var textReader = new StreamReader(filename))
{
return (List<DataSaveModel>)deserializer.Deserialize(textReader);
}
}*/
public void SaveDataToFile(string filename, List<DataSaveModel> modelsList)
{
//!TODO-PCL!
throw new NotImplementedException();
}
public List<DataSaveModel> LoadDataFromFile(string filename)
{
//!TODO-PCL!
throw new NotImplementedException();
}
}
}

Двоичные данные
GraphX.PCL.Logic/signature.snk

Двоичный файл не отображается.

Просмотреть файл

@ -1,11 +0,0 @@
The key provided here is to keep the downloaded source code buidable. However binary releases are signed with another key.
Public key is:
0024000004800000940000000602000000240000525341310004000001000100d7f87eefee568e
19ff867da48567811d16853dbc045adcae7a9682012ad27a39dd24c9959db4e87965a589859f8a
2cfc33c2d4997bf969dc4baa159ceefe1a85f45368d76918c764df03763848f50370e660da01bb
4b2614fb67f8d0f7183c0c640b16c61d47628d8e4ba20f86dc6bab11b0528425efd05607c28ac5
76f92ca1
Public key token is:
15c43682c986900f

Двоичные данные
YAXLib/Key/YAXLib.DevKey.snk

Двоичный файл не отображается.

Двоичные данные
YAXLib/YAXLib.PCL.Common/YAXLib.DevKey.snk

Двоичный файл не отображается.

Просмотреть файл

@ -36,11 +36,11 @@
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>YAXLib.DevKey.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>signature.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<!-- A reference to the entire .NET Framework is automatically included -->
<None Include="YAXLib.DevKey.snk" />
<None Include="signature.snk" />
</ItemGroup>
<ItemGroup>
<Compile Include="Enums.cs" />

Двоичные данные
YAXLib/YAXLib.PCL.Common/signature.snk Normal file

Двоичный файл не отображается.

Просмотреть файл

@ -61,7 +61,7 @@
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>../Key/YAXLib.DevKey.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>signature.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
@ -110,6 +110,9 @@
<Name>YAXLib.PCL.Common</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="signature.snk" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- 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.

Двоичные данные
YAXLib/YAXLib/signature.snk Normal file

Двоичный файл не отображается.