Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Examples/Avalonia/AvaloniaExamples/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void Main(string[] args)
AppBuilder.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.LogToDebug()
.LogToTrace()
#endif
.StartWithClassicDesktopLifetime(args);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="11.0.0" />
<ProjectReference Include="..\..\..\OxyPlot.Avalonia\OxyPlot.Avalonia.csproj" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-rc1" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-rc1" />
</ItemGroup>
</Project>
3 changes: 1 addition & 2 deletions Source/Examples/Avalonia/AvaloniaExamples/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ private void ListBoxMouseDoubleClick(object sender, RoutedEventArgs e)
{
var window = example.Create();
window.Icon = this.Icon;
window.Show();

window.Show(this);
}
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Examples/Avalonia/ExampleBrowser/ExampleBrowser.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</AvaloniaResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-rc1" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-rc1" />
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
<PackageReference Include="OxyPlot.ExampleLibrary" Version="2.0.0" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Source/Examples/Avalonia/ExampleBrowser/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ public static void Main(string[] args) => BuildAvaloniaApp()
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToDebug();
.LogToTrace();
}
}
2 changes: 1 addition & 1 deletion Source/Examples/Avalonia/MemoryTest/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static void Main(string[] args)
AppBuilder.Configure<App>()
.UsePlatformDetect()
#if DEBUG
.LogToDebug()
.LogToTrace()
#endif
.StartWithClassicDesktopLifetime(args);
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Examples/Avalonia/MemoryTest/MemoryTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="JetBrains.Annotations" Version="11.0.0" />
<ProjectReference Include="..\..\..\OxyPlot.Avalonia\OxyPlot.Avalonia.csproj" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-rc1" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-rc1" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Source/Examples/Avalonia/SimpleDemo/SimpleDemo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<PackageReference Include="JetBrains.Annotations" Version="11.0.0" />
<ProjectReference Include="..\..\..\OxyPlot.Avalonia\OxyPlot.Avalonia.csproj" />
<PackageReference Include="Serilog.Sinks.Trace" Version="2.1.0" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.0-rc1" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.0-rc1" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="**\*.xaml;Assets\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
<PackageReference Include="Avalonia" Version="0.10.0-preview1" />
<PackageReference Include="Avalonia" Version="0.10.0-rc1" />
<PackageReference Include="OxyPlot.Core" Version="2.0.0" />
</ItemGroup>
</Project>
4 changes: 2 additions & 2 deletions Source/OxyPlot.Avalonia/PlotBase.Events.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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));

Expand Down
26 changes: 25 additions & 1 deletion Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public static OxyKey Convert(this Key k)
/// </summary>
/// <param name="button">The button to convert.</param>
/// <returns>The converted mouse button.</returns>
[Obsolete]
public static OxyMouseButton Convert(this MouseButton button)
{
switch (button)
Expand All @@ -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;
Expand Down Expand Up @@ -422,10 +442,14 @@ public static OxyMouseWheelEventArgs ToMouseWheelEventArgs(this PointerWheelEven
/// <returns>A <see cref="OxyMouseEventArgs" /> containing the converted event arguments.</returns>
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,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ClickCount is obsolete, but there is no 1to1 replacement. Although it can be replaced with DoubleTapped event.

#pragma warning restore CS0618 // Type or member is obsolete
Position = e.GetPosition(relativeTo).ToScreenPoint(),
ModifierKeys = e.KeyModifiers.ToModifierKeys()
};
Expand Down