diff --git a/Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs b/Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs index 7bf1dd7..82d23f0 100644 --- a/Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs +++ b/Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs @@ -34,7 +34,7 @@ static void Main(string[] args) AppBuilder.Configure() .UsePlatformDetect() #if DEBUG - .LogToDebug() + .LogToTrace() #endif .StartWithClassicDesktopLifetime(args); } diff --git a/Source/Examples/Avalonia/AvaloniaExamples/AvaloniaExamples.csproj b/Source/Examples/Avalonia/AvaloniaExamples/AvaloniaExamples.csproj index ffcb57e..afc95e4 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/AvaloniaExamples/MainWindow.xaml.cs b/Source/Examples/Avalonia/AvaloniaExamples/MainWindow.xaml.cs index 5d7b3e9..23b354f 100644 --- a/Source/Examples/Avalonia/AvaloniaExamples/MainWindow.xaml.cs +++ b/Source/Examples/Avalonia/AvaloniaExamples/MainWindow.xaml.cs @@ -67,8 +67,7 @@ private void ListBoxMouseDoubleClick(object sender, RoutedEventArgs e) { var window = example.Create(); window.Icon = this.Icon; - window.Show(); - + window.Show(this); } } diff --git a/Source/Examples/Avalonia/ExampleBrowser/ExampleBrowser.csproj b/Source/Examples/Avalonia/ExampleBrowser/ExampleBrowser.csproj index 555a942..9d31feb 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 6af0029..5f71d4b 100644 --- a/Source/Examples/Avalonia/ExampleBrowser/Program.cs +++ b/Source/Examples/Avalonia/ExampleBrowser/Program.cs @@ -14,6 +14,6 @@ public static void Main(string[] args) => BuildAvaloniaApp() public static AppBuilder BuildAvaloniaApp() => AppBuilder.Configure() .UsePlatformDetect() - .LogToDebug(); + .LogToTrace(); } } diff --git a/Source/Examples/Avalonia/MemoryTest/App.xaml.cs b/Source/Examples/Avalonia/MemoryTest/App.xaml.cs index a792320..361180d 100644 --- a/Source/Examples/Avalonia/MemoryTest/App.xaml.cs +++ b/Source/Examples/Avalonia/MemoryTest/App.xaml.cs @@ -34,7 +34,7 @@ static void Main(string[] args) AppBuilder.Configure() .UsePlatformDetect() #if DEBUG - .LogToDebug() + .LogToTrace() #endif .StartWithClassicDesktopLifetime(args); } diff --git a/Source/Examples/Avalonia/MemoryTest/MemoryTest.csproj b/Source/Examples/Avalonia/MemoryTest/MemoryTest.csproj index ffcb57e..afc95e4 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/SimpleDemo.csproj b/Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj index 66627de..609c6c0 100644 --- a/Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj +++ b/Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj @@ -13,7 +13,7 @@ - - + + \ No newline at end of file diff --git a/Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj b/Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj index 328d5d5..80fe5d6 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 e308438..e7a24bc 100644 --- a/Source/OxyPlot.Avalonia/PlotBase.Events.cs +++ b/Source/OxyPlot.Avalonia/PlotBase.Events.cs @@ -110,7 +110,7 @@ protected override void OnPointerPressed(PointerPressedEventArgs e) } Focus(); - ((TopLevel)this.VisualRoot).PlatformImpl.MouseDevice.Capture(this); + e.Pointer.Capture(this); // store the mouse down point, check it when mouse button is released to determine if the context menu should be shown mouseDownPoint = e.GetPosition(this).ToScreenPoint(); @@ -147,7 +147,7 @@ protected override void OnPointerReleased(PointerReleasedEventArgs e) var releasedArgs = (PointerReleasedEventArgs)e; - ((TopLevel)this.VisualRoot).PlatformImpl.MouseDevice.Capture(null); + e.Pointer.Capture(null); e.Handled = ActualController.HandleMouseUp(this, releasedArgs.ToMouseReleasedEventArgs(this)); diff --git a/Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs b/Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs index 42acc68..30755f4 100644 --- a/Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs +++ b/Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs @@ -357,6 +357,7 @@ public static OxyKey Convert(this Key k) /// /// The button to convert. /// The converted mouse button. + [Obsolete] public static OxyMouseButton Convert(this MouseButton button) { switch (button) @@ -372,6 +373,25 @@ public static OxyMouseButton Convert(this MouseButton button) } } + public static OxyMouseButton Convert(this PointerUpdateKind pointerUpdateKind) + { + switch (pointerUpdateKind) + { + case PointerUpdateKind.LeftButtonPressed: + return OxyMouseButton.Left; + case PointerUpdateKind.MiddleButtonPressed: + return OxyMouseButton.Middle; + case PointerUpdateKind.RightButtonPressed: + return OxyMouseButton.Right; + case PointerUpdateKind.XButton1Pressed: + return OxyMouseButton.XButton1; + case PointerUpdateKind.XButton2Pressed: + return OxyMouseButton.XButton2; + default: + return OxyMouseButton.None; + } + } + public static OxyModifierKeys ToModifierKeys(this KeyModifiers modifiers) { var modifierKeys = OxyModifierKeys.None; @@ -422,10 +442,14 @@ public static OxyMouseWheelEventArgs ToMouseWheelEventArgs(this PointerWheelEven /// A containing the converted event arguments. public static OxyMouseDownEventArgs ToMouseDownEventArgs(this PointerPressedEventArgs e, IInputElement relativeTo) { + var point = e.GetCurrentPoint(relativeTo); + return new OxyMouseDownEventArgs { - ChangedButton = e.MouseButton.Convert(), + ChangedButton = point.Properties.PointerUpdateKind.Convert(), +#pragma warning disable CS0618 // Type or member is obsolete ClickCount = e.ClickCount, +#pragma warning restore CS0618 // Type or member is obsolete Position = e.GetPosition(relativeTo).ToScreenPoint(), ModifierKeys = e.KeyModifiers.ToModifierKeys() };