From 51456bc9b2e9d6c3cea94bdbbc416a7cd954298f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Thu, 16 Jul 2020 21:49:25 +0100 Subject: [PATCH] Updated Avalonia to 0.10.0-preview1. --- .../Avalonia/AvaloniaExamples/App.xaml.cs | 16 +++------------- .../AvaloniaExamples/AvaloniaExamples.csproj | 4 ++-- .../ExampleBrowser/ExampleBrowser.csproj | 4 ++-- .../Examples/Avalonia/ExampleBrowser/Program.cs | 5 +---- Source/Examples/Avalonia/MemoryTest/App.xaml.cs | 16 +++------------- .../Avalonia/MemoryTest/MemoryTest.csproj | 4 ++-- .../Avalonia/SimpleDemo/MainWindow.xaml.cs | 2 +- .../Avalonia/SimpleDemo/SimpleDemo.csproj | 3 ++- Source/OxyPlot.Avalonia/Axes/Axis.cs | 2 +- Source/OxyPlot.Avalonia/Axes/LinearColorAxis.cs | 14 +++----------- Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj | 2 +- Source/OxyPlot.Avalonia/PlotBase.Events.cs | 2 +- Source/OxyPlot.Avalonia/PlotBase.cs | 4 ++-- Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs | 10 +--------- .../OxyPlot.Avalonia/Tracker/TrackerControl.cs | 4 ++-- .../Utilities/ConverterExtensions.cs | 16 ++++++++-------- 16 files changed, 35 insertions(+), 73 deletions(-) diff --git a/Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs b/Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs index d30869e..7bf1dd7 100644 --- a/Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs +++ b/Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs @@ -2,9 +2,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; -using Serilog; using OxyPlot.Avalonia; namespace AvaloniaExamples @@ -33,9 +31,11 @@ public override void OnFrameworkInitializationCompleted() static void Main(string[] args) { OxyPlotModule.EnsureLoaded(); - InitializeLogging(); AppBuilder.Configure() .UsePlatformDetect() +#if DEBUG + .LogToDebug() +#endif .StartWithClassicDesktopLifetime(args); } @@ -45,15 +45,5 @@ public static void AttachDevTools(Window window) DevToolsExtensions.AttachDevTools(window); #endif } - - private static void InitializeLogging() - { -#if DEBUG - SerilogLogger.Initialize(new LoggerConfiguration() - .MinimumLevel.Warning() - .WriteTo.Trace(outputTemplate: "{Area}: {Message}") - .CreateLogger()); -#endif - } } } diff --git a/Source/Examples/Avalonia/AvaloniaExamples/AvaloniaExamples.csproj b/Source/Examples/Avalonia/AvaloniaExamples/AvaloniaExamples.csproj index d03cd6c..ffcb57e 100644 --- a/Source/Examples/Avalonia/AvaloniaExamples/AvaloniaExamples.csproj +++ b/Source/Examples/Avalonia/AvaloniaExamples/AvaloniaExamples.csproj @@ -12,7 +12,7 @@ - - + + \ No newline at end of file diff --git a/Source/Examples/Avalonia/ExampleBrowser/ExampleBrowser.csproj b/Source/Examples/Avalonia/ExampleBrowser/ExampleBrowser.csproj index bd7229b..555a942 100644 --- a/Source/Examples/Avalonia/ExampleBrowser/ExampleBrowser.csproj +++ b/Source/Examples/Avalonia/ExampleBrowser/ExampleBrowser.csproj @@ -12,8 +12,8 @@ - - + + diff --git a/Source/Examples/Avalonia/ExampleBrowser/Program.cs b/Source/Examples/Avalonia/ExampleBrowser/Program.cs index 1165146..6af0029 100644 --- a/Source/Examples/Avalonia/ExampleBrowser/Program.cs +++ b/Source/Examples/Avalonia/ExampleBrowser/Program.cs @@ -1,7 +1,4 @@ -using System; -using Avalonia; -using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Logging.Serilog; +using Avalonia; namespace ExampleBrowser { diff --git a/Source/Examples/Avalonia/MemoryTest/App.xaml.cs b/Source/Examples/Avalonia/MemoryTest/App.xaml.cs index 67ff987..a792320 100644 --- a/Source/Examples/Avalonia/MemoryTest/App.xaml.cs +++ b/Source/Examples/Avalonia/MemoryTest/App.xaml.cs @@ -2,9 +2,7 @@ using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; -using Avalonia.Logging.Serilog; using Avalonia.Markup.Xaml; -using Serilog; using OxyPlot.Avalonia; namespace MemoryTest @@ -33,9 +31,11 @@ public override void OnFrameworkInitializationCompleted() static void Main(string[] args) { OxyPlotModule.EnsureLoaded(); - InitializeLogging(); AppBuilder.Configure() .UsePlatformDetect() +#if DEBUG + .LogToDebug() +#endif .StartWithClassicDesktopLifetime(args); } @@ -43,16 +43,6 @@ public static void AttachDevTools(Window window) { #if DEBUG DevToolsExtensions.AttachDevTools(window); -#endif - } - - private static void InitializeLogging() - { -#if DEBUG - SerilogLogger.Initialize(new LoggerConfiguration() - .MinimumLevel.Warning() - .WriteTo.Trace(outputTemplate: "{Area}: {Message}") - .CreateLogger()); #endif } } diff --git a/Source/Examples/Avalonia/MemoryTest/MemoryTest.csproj b/Source/Examples/Avalonia/MemoryTest/MemoryTest.csproj index d03cd6c..ffcb57e 100644 --- a/Source/Examples/Avalonia/MemoryTest/MemoryTest.csproj +++ b/Source/Examples/Avalonia/MemoryTest/MemoryTest.csproj @@ -12,7 +12,7 @@ - - + + \ No newline at end of file diff --git a/Source/Examples/Avalonia/SimpleDemo/MainWindow.xaml.cs b/Source/Examples/Avalonia/SimpleDemo/MainWindow.xaml.cs index 7103478..c91d622 100644 --- a/Source/Examples/Avalonia/SimpleDemo/MainWindow.xaml.cs +++ b/Source/Examples/Avalonia/SimpleDemo/MainWindow.xaml.cs @@ -25,7 +25,7 @@ public class MainWindow : Window public MainWindow() { InitializeComponent(); - DevToolsExtensions.AttachDevTools(this); + this.AttachDevTools(); } private void InitializeComponent() diff --git a/Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj b/Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj index d03cd6c..66627de 100644 --- a/Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj +++ b/Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj @@ -13,6 +13,7 @@ - + + \ No newline at end of file diff --git a/Source/OxyPlot.Avalonia/Axes/Axis.cs b/Source/OxyPlot.Avalonia/Axes/Axis.cs index d366dd9..460feb1 100644 --- a/Source/OxyPlot.Avalonia/Axes/Axis.cs +++ b/Source/OxyPlot.Avalonia/Axes/Axis.cs @@ -1380,7 +1380,7 @@ protected void OnDataChanged() /// The on property changed handler. /// /// The event args. - protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e) + protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (e.Property.OwnerType == GetType()) diff --git a/Source/OxyPlot.Avalonia/Axes/LinearColorAxis.cs b/Source/OxyPlot.Avalonia/Axes/LinearColorAxis.cs index 62e2565..aa1987a 100644 --- a/Source/OxyPlot.Avalonia/Axes/LinearColorAxis.cs +++ b/Source/OxyPlot.Avalonia/Axes/LinearColorAxis.cs @@ -41,15 +41,7 @@ public class LinearColorAxis : Axis /// /// Identifies the dependency property. /// - public static readonly StyledProperty PaletteSizeProperty = AvaloniaProperty.Register(nameof(PaletteSize), 20, validate: (obj, val) => - { - if (!ValidatePaletteSize(val)) - { - throw new System.ArgumentException(); - } - - return val; - }); + public static readonly StyledProperty PaletteSizeProperty = AvaloniaProperty.Register(nameof(PaletteSize), 20, validate: ValidatePaletteSize); /// /// Initializes a new instance of the class. @@ -209,9 +201,9 @@ private static OxyPalette Interpolate(List stops, int paletteSize) /// /// The validation result. /// - private static bool ValidatePaletteSize(object value) + private static bool ValidatePaletteSize(int value) { - return (int)value >= 1; + return value >= 1; } static LinearColorAxis() diff --git a/Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj b/Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj index 4db7665..328d5d5 100644 --- a/Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj +++ b/Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj @@ -15,7 +15,7 @@ - + diff --git a/Source/OxyPlot.Avalonia/PlotBase.Events.cs b/Source/OxyPlot.Avalonia/PlotBase.Events.cs index 37cd1d9..e308438 100644 --- a/Source/OxyPlot.Avalonia/PlotBase.Events.cs +++ b/Source/OxyPlot.Avalonia/PlotBase.Events.cs @@ -31,7 +31,7 @@ protected override void OnKeyDown(KeyEventArgs e) return; } - var args = new OxyKeyEventArgs { ModifierKeys = e.Modifiers.ToModifierKeys(), Key = e.Key.Convert() }; + var args = new OxyKeyEventArgs { ModifierKeys = e.KeyModifiers.ToModifierKeys(), Key = e.Key.Convert() }; e.Handled = ActualController.HandleKeyDown(this, args); } diff --git a/Source/OxyPlot.Avalonia/PlotBase.cs b/Source/OxyPlot.Avalonia/PlotBase.cs index b1cc8fa..dc407d7 100644 --- a/Source/OxyPlot.Avalonia/PlotBase.cs +++ b/Source/OxyPlot.Avalonia/PlotBase.cs @@ -259,9 +259,9 @@ public void InvalidatePlot(bool updateData = true) /// just before a UI element displays in an application. For more information, see Remarks. /// /// Event data for applying the template. - protected override void OnTemplateApplied(TemplateAppliedEventArgs e) + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { - base.OnTemplateApplied(e); + base.OnApplyTemplate(e); panel = e.NameScope.Find(PartPanel) as Panel; if (panel == null) { diff --git a/Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs b/Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs index 6a748f0..cfe653f 100644 --- a/Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs +++ b/Source/OxyPlot.Avalonia/Series/HeatMapSeries.cs @@ -21,15 +21,7 @@ public class HeatMapSeries : XYAxisSeries /// /// Identifies this dependency property. /// - public static readonly StyledProperty DataProperty = AvaloniaProperty.Register(nameof(Data), new double[0, 0], validate: (obj, val) => - { - if (val == null) - { - throw new System.ArgumentException(); - } - - return val; - }); + public static readonly StyledProperty DataProperty = AvaloniaProperty.Register(nameof(Data), new double[0, 0], validate: val => val != null); /// /// Identifies this dependency property. diff --git a/Source/OxyPlot.Avalonia/Tracker/TrackerControl.cs b/Source/OxyPlot.Avalonia/Tracker/TrackerControl.cs index cf448d6..7571249 100644 --- a/Source/OxyPlot.Avalonia/Tracker/TrackerControl.cs +++ b/Source/OxyPlot.Avalonia/Tracker/TrackerControl.cs @@ -316,9 +316,9 @@ public ScreenPoint Position } } - protected override void OnTemplateApplied(TemplateAppliedEventArgs e) + protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { - base.OnTemplateApplied(e); + base.OnApplyTemplate(e); path = e.NameScope.Get(PartPath); content = e.NameScope.Get(PartContent); contentContainer = e.NameScope.Get(PartContentContainer); diff --git a/Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs b/Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs index 538bec7..42acc68 100644 --- a/Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs +++ b/Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs @@ -372,25 +372,25 @@ public static OxyMouseButton Convert(this MouseButton button) } } - public static OxyModifierKeys ToModifierKeys(this InputModifiers modifiers) + public static OxyModifierKeys ToModifierKeys(this KeyModifiers modifiers) { var modifierKeys = OxyModifierKeys.None; - if ((modifiers & InputModifiers.Shift) != 0) + if ((modifiers & KeyModifiers.Shift) != 0) { modifierKeys |= OxyModifierKeys.Shift; } - if ((modifiers & InputModifiers.Control) != 0) + if ((modifiers & KeyModifiers.Control) != 0) { modifierKeys |= OxyModifierKeys.Control; } - if ((modifiers & InputModifiers.Alt) != 0) + if ((modifiers & KeyModifiers.Alt) != 0) { modifierKeys |= OxyModifierKeys.Alt; } - if ((modifiers & InputModifiers.Windows) != 0) + if ((modifiers & KeyModifiers.Meta) != 0) { modifierKeys |= OxyModifierKeys.Windows; } @@ -427,7 +427,7 @@ public static OxyMouseDownEventArgs ToMouseDownEventArgs(this PointerPressedEven ChangedButton = e.MouseButton.Convert(), ClickCount = e.ClickCount, Position = e.GetPosition(relativeTo).ToScreenPoint(), - ModifierKeys = e.InputModifiers.ToModifierKeys() + ModifierKeys = e.KeyModifiers.ToModifierKeys() }; } @@ -442,7 +442,7 @@ public static OxyMouseEventArgs ToMouseReleasedEventArgs(this PointerReleasedEve return new OxyMouseEventArgs { Position = e.GetPosition(relativeTo).ToScreenPoint(), - ModifierKeys = e.InputModifiers.ToModifierKeys() + ModifierKeys = e.KeyModifiers.ToModifierKeys() }; } @@ -457,7 +457,7 @@ public static OxyMouseEventArgs ToMouseEventArgs(this PointerEventArgs e, IInput return new OxyMouseEventArgs { Position = e.GetPosition(relativeTo).ToScreenPoint(), - ModifierKeys = e.InputModifiers.ToModifierKeys() + ModifierKeys = e.KeyModifiers.ToModifierKeys() }; }