Skip to content

Commit

Permalink
Update to Avalonia11 Preview5
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualMelon committed Feb 3, 2023
1 parent eb195a4 commit 567f076
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<AvaloniaVersion>11.0.0-preview4</AvaloniaVersion>
<AvaloniaVersion>11.0.0-preview5</AvaloniaVersion>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion Source/Examples/Avalonia/ExampleBrowser/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<Expander.Header>
<TextBlock Text="{Binding Key}" DockPanel.Dock="Top" Margin="0" />
</Expander.Header>
<ListBox Items="{Binding Examples}" SelectedItem="{Binding $parent[Grid].DataContext.Example}" VirtualizationMode="None" Margin="0" Padding="0">
<ListBox Items="{Binding Examples}" SelectedItem="{Binding $parent[Grid].DataContext.Example}" Margin="0" Padding="0">
<ListBox.DataTemplates>
<DataTemplate DataType="exampleLibrary:ExampleInfo">
<TextBlock Text="{Binding Title}" />
Expand Down
2 changes: 1 addition & 1 deletion Source/OxyPlot.Avalonia/Axes/LinearColorAxis.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected override void SynchronizeProperties()
{
base.SynchronizeProperties();
var axis = InternalAxis as Axes.LinearColorAxis;
Contract.Requires<InvalidOperationException>(axis != null);
//Contract.Requires<InvalidOperationException>(axis != null);
if (GradientStops != null)
{
axis.Palette = GradientStops.Count > 2
Expand Down
1 change: 1 addition & 0 deletions Source/OxyPlot.Avalonia/OxyPlot.Avalonia.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,6 @@
<EmbeddedResource Include="**\*.xaml;Assets\*" Exclude="bin\**;obj\**;**\*.xproj;packages\**;@(EmbeddedResource)" />
<PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="OxyPlot.Core" Version="2.1.0" />
<PackageReference Include="System.Reactive" Version="5.0.0" />
</ItemGroup>
</Project>
5 changes: 3 additions & 2 deletions Source/OxyPlot.Avalonia/Plot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace OxyPlot.Avalonia
{
using global::Avalonia;
using global::Avalonia.Controls;
using global::Avalonia.LogicalTree;
using global::Avalonia.VisualTree;
Expand Down Expand Up @@ -182,7 +183,7 @@ private void SyncLogicalTree(NotifyCollectionChangedEventArgs e)
item.SetParent(this);
}
LogicalChildren.AddRange(e.NewItems.OfType<ILogical>());
VisualChildren.AddRange(e.NewItems.OfType<IVisual>());
VisualChildren.AddRange(e.NewItems.OfType<Visual>());
}

if (e.OldItems != null)
Expand All @@ -195,7 +196,7 @@ private void SyncLogicalTree(NotifyCollectionChangedEventArgs e)
foreach (var item in e.OldItems)
{
LogicalChildren.Remove((ILogical)item);
VisualChildren.Remove((IVisual)item);
VisualChildren.Remove((Visual)item);
}
}

Expand Down
10 changes: 5 additions & 5 deletions Source/OxyPlot.Avalonia/PlotBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public abstract partial class PlotBase : TemplatedControl, IPlotView
/// <summary>
/// The current tracker.
/// </summary>
private IControl currentTracker;
private Control currentTracker;

/// <summary>
/// The grid.
Expand Down Expand Up @@ -101,7 +101,7 @@ protected PlotBase()
{
DisconnectCanvasWhileUpdating = true;
trackerDefinitions = new ObservableCollection<TrackerDefinition>();
this.GetObservable(TransformedBoundsProperty).Subscribe(bounds => OnSizeChanged(this, bounds?.Bounds.Size ?? new Size()));
this.GetObservable(BoundsProperty).Subscribe(bounds => OnSizeChanged(this, bounds.Size));
}

/// <summary>
Expand Down Expand Up @@ -134,7 +134,7 @@ Model IView.ActualModel
/// Gets the actual controller.
/// </summary>
/// <value>
/// The actual <see cref="IController" />.
/// The actual <see cref="Controller" />.
/// </value>
IController IView.ActualController
{
Expand Down Expand Up @@ -458,10 +458,10 @@ private void OnSizeChanged(object sender, Size size)
/// <typeparam name="T">Type of the relevant parent</typeparam>
/// <param name="obj">The object.</param>
/// <returns>The relevant parent.</returns>
private Control GetRelevantParent<T>(IVisual obj)
private Control GetRelevantParent<T>(Visual obj)
where T : Control
{
var container = obj.VisualParent;
var container = obj.GetVisualParent();

if (container is ContentPresenter contentPresenter)
{
Expand Down
27 changes: 19 additions & 8 deletions Source/OxyPlot.Avalonia/Series/Series.cs
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,28 @@ protected void OnDataChanged()
(this.Parent as IPlot)?.ElementDataChanged(this);
}

/// <summary>
/// The on items source changed.
/// </summary>
/// <param name="e">Event args</param>
protected override void ItemsChanged(AvaloniaPropertyChangedEventArgs e)
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e)
{
base.ItemsChanged(e);
SubscribeToCollectionChanged(e.OldValue as IEnumerable, e.NewValue as IEnumerable);
OnDataChanged();
base.OnPropertyChanged(e);

if (e.Property == ItemsControl.ItemsProperty)
{
SubscribeToCollectionChanged(e.OldValue as IEnumerable, e.NewValue as IEnumerable);
OnDataChanged();
}
}

///// <summary>
///// The on items source changed.
///// </summary>
///// <param name="e">Event args</param>
//protected override void ItemsCollectionChanged(AvaloniaPropertyChangedEventArgs e)
//{
// base.ItemsChanged(e);
// SubscribeToCollectionChanged(e.OldValue as IEnumerable, e.NewValue as IEnumerable);
// OnDataChanged();
//}

protected override void OnAttachedToLogicalTree(global::Avalonia.LogicalTree.LogicalTreeAttachmentEventArgs e)
{
base.OnAttachedToLogicalTree(e);
Expand Down
10 changes: 5 additions & 5 deletions Source/OxyPlot.Avalonia/Utilities/ConverterExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ public static OxyMouseWheelEventArgs ToMouseWheelEventArgs(this PointerWheelEven
{
return new OxyMouseWheelEventArgs
{
Position = e.GetPosition(relativeTo).ToScreenPoint(),
Position = e.GetPosition(relativeTo as Visual).ToScreenPoint(),
ModifierKeys = Keyboard.Instance.GetModifierKeys(),
Delta = (int)(e.Delta.Y + e.Delta.X) * 120
};
Expand All @@ -448,15 +448,15 @@ 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);
var point = e.GetCurrentPoint(relativeTo as Visual);

return new OxyMouseDownEventArgs
{
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(),
Position = e.GetPosition(relativeTo as Visual).ToScreenPoint(),
ModifierKeys = e.KeyModifiers.ToModifierKeys()
};
}
Expand All @@ -471,7 +471,7 @@ public static OxyMouseEventArgs ToMouseReleasedEventArgs(this PointerReleasedEve
{
return new OxyMouseEventArgs
{
Position = e.GetPosition(relativeTo).ToScreenPoint(),
Position = e.GetPosition(relativeTo as Visual).ToScreenPoint(),
ModifierKeys = e.KeyModifiers.ToModifierKeys()
};
}
Expand All @@ -486,7 +486,7 @@ public static OxyMouseEventArgs ToMouseEventArgs(this PointerEventArgs e, IInput
{
return new OxyMouseEventArgs
{
Position = e.GetPosition(relativeTo).ToScreenPoint(),
Position = e.GetPosition(relativeTo as Visual).ToScreenPoint(),
ModifierKeys = e.KeyModifiers.ToModifierKeys()
};
}
Expand Down

0 comments on commit 567f076

Please sign in to comment.