fixed some bugs
This commit is contained in:
1 parent
203fbb4541
commit
f261f3199f
11 files changed
+147
-19
No files matched your search
@@ -23,13 +23,46 @@ namespace HandyControl.Controls
|
||||
|
||||
private int _blockHeight;
|
||||
|
||||
private bool _isDisposed;
|
||||
|
||||
public ImageBlock()
|
||||
{
|
||||
_dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render)
|
||||
{
|
||||
Interval = Interval
|
||||
};
|
||||
_dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
|
||||
IsVisibleChanged += ImageBlock_IsVisibleChanged;
|
||||
}
|
||||
|
||||
~ImageBlock() => Dispose();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed) return;
|
||||
|
||||
IsVisibleChanged -= ImageBlock_IsVisibleChanged;
|
||||
_dispatcherTimer.Stop();
|
||||
_isDisposed = true;
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void ImageBlock_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if(IsVisible)
|
||||
{
|
||||
_dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
if (IsPlaying)
|
||||
{
|
||||
_dispatcherTimer.Start();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_dispatcherTimer.Stop();
|
||||
_dispatcherTimer.Tick -= DispatcherTimer_Tick;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateDatas()
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace HandyControl.Controls
|
||||
[ContentProperty("Items")]
|
||||
[TemplatePart(Name = ElementPanelPage, Type = typeof(Panel))]
|
||||
[TemplatePart(Name = ElementItemsControl, Type = typeof(ItemsPresenter))]
|
||||
public class Carousel : ListBox
|
||||
public class Carousel : ListBox, IDisposable
|
||||
{
|
||||
#region Constants
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace HandyControl.Controls
|
||||
|
||||
#region Data
|
||||
|
||||
private bool _isDisposed;
|
||||
|
||||
private Panel _panelPage;
|
||||
|
||||
private bool _appliedTemplate;
|
||||
@@ -119,6 +121,36 @@ namespace HandyControl.Controls
|
||||
CommandBindings.Add(new CommandBinding(ControlCommands.Selected, ButtonPages_OnClick));
|
||||
|
||||
Loaded += (s, e) => UpdatePageButtons();
|
||||
IsVisibleChanged += Carousel_IsVisibleChanged;
|
||||
}
|
||||
|
||||
~Carousel() => Dispose();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed) return;
|
||||
|
||||
IsVisibleChanged -= Carousel_IsVisibleChanged;
|
||||
_updateTimer.Stop();
|
||||
_isDisposed = true;
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void Carousel_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (_updateTimer == null) return;
|
||||
|
||||
if (IsVisible)
|
||||
{
|
||||
_updateTimer.Tick += UpdateTimer_Tick;
|
||||
_updateTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_updateTimer.Stop();
|
||||
_updateTimer.Tick -= UpdateTimer_Tick;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
|
||||
|
||||
@@ -93,10 +93,7 @@ namespace HandyControl.Controls
|
||||
if (Application.Current != null) Application.Current.Exit += (s, e) => Dispose();
|
||||
}
|
||||
|
||||
~NotifyIcon()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
~NotifyIcon() => Dispose(false);
|
||||
|
||||
public void Init()
|
||||
{
|
||||
|
||||
@@ -8,6 +8,10 @@ namespace HandyControl.Controls
|
||||
{
|
||||
public class FlipClock : Control
|
||||
{
|
||||
private readonly DispatcherTimer _dispatcherTimer;
|
||||
|
||||
private bool _isDisposed;
|
||||
|
||||
public static readonly DependencyProperty NumberListProperty = DependencyProperty.Register(
|
||||
"NumberList", typeof(List<int>), typeof(FlipClock), new PropertyMetadata(new List<int> {0, 0, 0, 0, 0, 0}));
|
||||
|
||||
@@ -44,12 +48,39 @@ namespace HandyControl.Controls
|
||||
|
||||
public FlipClock()
|
||||
{
|
||||
var dispatcherTimer = new DispatcherTimer
|
||||
_dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render)
|
||||
{
|
||||
Interval = TimeSpan.FromMilliseconds(200)
|
||||
};
|
||||
dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
dispatcherTimer.Start();
|
||||
|
||||
IsVisibleChanged += FlipClock_IsVisibleChanged;
|
||||
}
|
||||
|
||||
~FlipClock() => Dispose();
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_isDisposed) return;
|
||||
|
||||
IsVisibleChanged -= FlipClock_IsVisibleChanged;
|
||||
_dispatcherTimer.Stop();
|
||||
_isDisposed = true;
|
||||
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
private void FlipClock_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (IsVisible)
|
||||
{
|
||||
_dispatcherTimer.Tick += DispatcherTimer_Tick;
|
||||
_dispatcherTimer.Start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_dispatcherTimer.Stop();
|
||||
_dispatcherTimer.Tick -= DispatcherTimer_Tick;
|
||||
}
|
||||
}
|
||||
|
||||
private void DispatcherTimer_Tick(object sender, EventArgs e) => DisplayTime = DateTime.Now;
|
||||
|
||||
Reference in new issue
Block a user