feat: respect presenter size change.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
mc:Ignorable="d">
|
mc:Ignorable="d">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<u:Form>
|
<u:Form>
|
||||||
|
<TextBox Width="300" Name="content" u:FormItem.Label="Content" Text="Hello Avalonia"></TextBox>
|
||||||
<u:EnumSelector
|
<u:EnumSelector
|
||||||
u:FormItem.Label="Direction"
|
u:FormItem.Label="Direction"
|
||||||
Name="direction"
|
Name="direction"
|
||||||
@@ -45,8 +46,9 @@
|
|||||||
Speed="{Binding #speed.Value}"
|
Speed="{Binding #speed.Value}"
|
||||||
Background="{DynamicResource SemiBlue1}"
|
Background="{DynamicResource SemiBlue1}"
|
||||||
Direction="{Binding #direction.Value}"
|
Direction="{Binding #direction.Value}"
|
||||||
|
Content="{Binding #content.Text}"
|
||||||
IsRunning="{Binding #running.IsChecked}">
|
IsRunning="{Binding #running.IsChecked}">
|
||||||
<TextBlock VerticalAlignment="Center" Text="Hello World" />
|
|
||||||
</u:Marquee>
|
</u:Marquee>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.Primitives;
|
||||||
using Avalonia.Layout;
|
using Avalonia.Layout;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
using Irihi.Avalonia.Shared.Helpers;
|
using Irihi.Avalonia.Shared.Helpers;
|
||||||
@@ -75,6 +76,10 @@ public class Marquee : ContentControl
|
|||||||
_timer.Elapsed -= TimerOnTick;
|
_timer.Elapsed -= TimerOnTick;
|
||||||
_timer.Stop();
|
_timer.Stop();
|
||||||
_timer.Dispose();
|
_timer.Dispose();
|
||||||
|
if (Presenter is not null)
|
||||||
|
{
|
||||||
|
Presenter.SizeChanged -= OnPresenterSizeChanged;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -104,6 +109,22 @@ public class Marquee : ContentControl
|
|||||||
set => SetValue(SpeedProperty, value);
|
set => SetValue(SpeedProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnApplyTemplate(e);
|
||||||
|
if (Presenter is not null)
|
||||||
|
{
|
||||||
|
Presenter.SizeChanged+= OnPresenterSizeChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPresenterSizeChanged(object sender, SizeChangedEventArgs e)
|
||||||
|
{
|
||||||
|
InvalidatePresenterPosition();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void TimerOnTick(object sender, System.EventArgs e)
|
private void TimerOnTick(object sender, System.EventArgs e)
|
||||||
{
|
{
|
||||||
var layoutValues = Dispatcher.UIThread.Invoke(GetLayoutValues);
|
var layoutValues = Dispatcher.UIThread.Invoke(GetLayoutValues);
|
||||||
|
|||||||
Reference in New Issue
Block a user