From 11789357f63e0d68f97034dc544103bc91e15a60 Mon Sep 17 00:00:00 2001 From: Yannis Guedel Date: Tue, 18 Aug 2015 22:45:59 +0200 Subject: [PATCH] added color highlighting --- src/OcadDiff.WPF/MainWindow.xaml.cs | 34 ++++++++++++++++++++- src/OcadDiff.WPF/Properties/AssemblyInfo.cs | 4 +-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/OcadDiff.WPF/MainWindow.xaml.cs b/src/OcadDiff.WPF/MainWindow.xaml.cs index c249f0f..36242d6 100644 --- a/src/OcadDiff.WPF/MainWindow.xaml.cs +++ b/src/OcadDiff.WPF/MainWindow.xaml.cs @@ -18,6 +18,8 @@ using System.Windows.Shapes; using OcadDiff.Logic; using OcadParser.Renderer; +using Svg; +using Svg.Transforms; using Color = System.Drawing.Color; namespace OcadDiff.WPF @@ -30,7 +32,7 @@ public partial class MainWindow : Window public MainWindow() { InitializeComponent(); - DataContext = new DiffViewModel() {ShowMaxWarning = Visibility.Hidden}; + DataContext = new DiffViewModel {ShowMaxWarning = Visibility.Hidden}; } private void BrowseSourceFile_OnClick(object sender, RoutedEventArgs e) @@ -68,6 +70,8 @@ private void UpdateDiff() var diff = diffGenerator.GetDiff(); var sourceRenderer = new OcadRenderer(diff.Source); var targetRenderer = new OcadRenderer(diff.Target); + sourceRenderer.EnsureSvg(); + targetRenderer.EnsureSvg(); var viewModel = new DiffViewModel(); @@ -79,6 +83,17 @@ private void UpdateDiff() var minY = -obj.Poly.Max(p => p.Y.Coordinate) - 1000; var maxX = obj.Poly.Max(p => p.X.Coordinate) + 1000; var maxY = -obj.Poly.Min(p => p.Y.Coordinate) + 1000; + var addedElements = new List(); + foreach (var element in sourceRenderer.ObjectElementMapping[obj]) + { + var highlightElement = element.DeepCopy(); + highlightElement.StrokeWidth = highlightElement.StrokeWidth + 100; + highlightElement.Stroke = new SvgColourServer(Color.Red); + highlightElement.StrokeOpacity= (float)0.5; + var index = sourceRenderer.Svg.Children.IndexOf(element); + sourceRenderer.Svg.Children.Insert(index, highlightElement); + addedElements.Add(highlightElement); + } viewModel.Diffs.Add(new DiffViewModelItems() { @@ -86,6 +101,8 @@ private void UpdateDiff() RightBitmap = targetRenderer.GetBitmap(minX, minY, maxX, maxY, 300), Status = "Removed" }); + + addedElements.ForEach(_ => sourceRenderer.Svg.Children.Remove(_)); } foreach (var obj in diff.AddedObjects.Take(limit - diff.DeletedObjects.Count)) @@ -95,12 +112,27 @@ private void UpdateDiff() var maxX = obj.Poly.Max(p => p.X.Coordinate) + 1000; var maxY = -obj.Poly.Min(p => p.Y.Coordinate) + 1000; + + var addedElements = new List(); + foreach (var element in targetRenderer.ObjectElementMapping[obj]) + { + var highlightElement = element.DeepCopy(); + highlightElement.StrokeWidth = highlightElement.StrokeWidth + 100; + highlightElement.Stroke = new SvgColourServer(Color.Green); + highlightElement.StrokeOpacity = (float)0.5; + highlightElement.Fill = SvgPaintServer.None; + var index = targetRenderer.Svg.Children.IndexOf(element); + targetRenderer.Svg.Children.Insert(index, highlightElement); + addedElements.Add(highlightElement); + } viewModel.Diffs.Add(new DiffViewModelItems() { LeftBitmap = sourceRenderer.GetBitmap(minX, minY, maxX, maxY, 300), RightBitmap = targetRenderer.GetBitmap(minX, minY, maxX, maxY, 300), Status = "Added" }); + + addedElements.ForEach(_ => targetRenderer.Svg.Children.Remove(_)); } viewModel.ShowMaxWarning = diff --git a/src/OcadDiff.WPF/Properties/AssemblyInfo.cs b/src/OcadDiff.WPF/Properties/AssemblyInfo.cs index 12b366a..04c1650 100644 --- a/src/OcadDiff.WPF/Properties/AssemblyInfo.cs +++ b/src/OcadDiff.WPF/Properties/AssemblyInfo.cs @@ -51,5 +51,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("0.1.0.0")] -[assembly: AssemblyFileVersion("0.1.0.0")] +[assembly: AssemblyVersion("0.2.0.0")] +[assembly: AssemblyFileVersion("0.2.0.0")]