fixed some bugs

This commit is contained in:
NaBian committed 2020-02-03 15:45:57 +08:00
1 parent 203fbb4541
commit f261f3199f
11 files changed
+147 -19

No files matched your search

@@ -483,6 +483,11 @@
<LastGenOutput>Lang.Designer.cs</LastGenOutput> <LastGenOutput>Lang.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\..\Shared\HandyControlDemo_Shared\Properties\App.config">
<Link>Properties\App.config</Link>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="..\..\Shared\HandyControlDemo_Shared\Data\MessageToken.tt"> <Content Include="..\..\Shared\HandyControlDemo_Shared\Data\MessageToken.tt">
<Link>Data\MessageToken.tt</Link> <Link>Data\MessageToken.tt</Link>
@@ -419,6 +419,11 @@
<LastGenOutput>Lang.Designer.cs</LastGenOutput> <LastGenOutput>Lang.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\..\Shared\HandyControlDemo_Shared\Properties\App.config">
<Link>Properties\App.config</Link>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\fabric-icons.ttf"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\fabric-icons.ttf">
<Link>Resources\fabric-icons.ttf</Link> <Link>Resources\fabric-icons.ttf</Link>
@@ -488,6 +488,11 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\..\Shared\HandyControlDemo_Shared\Properties\App.config">
<Link>Properties\App.config</Link>
</None>
</ItemGroup>
<ItemGroup> <ItemGroup>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\RepeatButton_16x.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\RepeatButton_16x.png">
<Link>Resources\Img\LeftMainContent\RepeatButton_16x.png</Link> <Link>Resources\Img\LeftMainContent\RepeatButton_16x.png</Link>
@@ -3,6 +3,7 @@ using System.Diagnostics;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Net; using System.Net;
using System.Runtime;
using System.Security.Authentication; using System.Security.Authentication;
using System.Threading; using System.Threading;
using System.Windows; using System.Windows;
@@ -21,6 +22,19 @@ namespace HandyControlDemo
private static Mutex AppMutex; private static Mutex AppMutex;
#pragma warning restore IDE0052 #pragma warning restore IDE0052
public App()
{
#if !netle40
var cachePath = $"{AppDomain.CurrentDomain.BaseDirectory}Cache";
if (!Directory.Exists(cachePath))
{
Directory.CreateDirectory(cachePath);
}
ProfileOptimization.SetProfileRoot(cachePath);
ProfileOptimization.StartProfile("Profile");
#endif
}
protected override void OnStartup(StartupEventArgs e) protected override void OnStartup(StartupEventArgs e)
{ {
AppMutex = new Mutex(true, "HandyControlDemo", out var createdNew); AppMutex = new Mutex(true, "HandyControlDemo", out var createdNew);
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
</configuration>
@@ -6,7 +6,7 @@
<ResourceDictionary Source="Geometries.xaml"/> <ResourceDictionary Source="Geometries.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
<DrawingBrush o:Freeze="True" x:Key="MainContentForegroundDrawingBrush" RenderOptions.CachingHint="Cache" Viewport="0,0,16,16" ViewportUnits="Absolute" Stretch="None" TileMode="Tile"> <DrawingBrush o:Freeze="True" x:Key="MainContentForegroundDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,16,16" ViewportUnits="Absolute" Stretch="None" TileMode="Tile">
<DrawingBrush.Drawing> <DrawingBrush.Drawing>
<DrawingGroup o:Freeze="True"> <DrawingGroup o:Freeze="True">
<GeometryDrawing o:Freeze="True" Brush="{DynamicResource MainContentForegroundBrush}"> <GeometryDrawing o:Freeze="True" Brush="{DynamicResource MainContentForegroundBrush}">
@@ -21,7 +21,7 @@
</DrawingBrush.Drawing> </DrawingBrush.Drawing>
</DrawingBrush> </DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="GitHubDrawingBrush" RenderOptions.CachingHint="Cache" Viewport="0,0,200,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile"> <DrawingBrush o:Freeze="True" x:Key="GitHubDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,200,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform> <DrawingBrush.Transform>
<TransformGroup o:Freeze="True"> <TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/> <RotateTransform o:Freeze="True" Angle="20"/>
@@ -34,7 +34,7 @@
</DrawingBrush.Drawing> </DrawingBrush.Drawing>
</DrawingBrush> </DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="QqDrawingBrush" RenderOptions.CachingHint="Cache" Viewport="0,0,100,200" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile"> <DrawingBrush o:Freeze="True" x:Key="QqDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,100,200" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform> <DrawingBrush.Transform>
<TransformGroup o:Freeze="True"> <TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/> <RotateTransform o:Freeze="True" Angle="20"/>
@@ -47,7 +47,7 @@
</DrawingBrush.Drawing> </DrawingBrush.Drawing>
</DrawingBrush> </DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="BlogDrawingBrush" RenderOptions.CachingHint="Cache" Viewport="0,0,160,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile"> <DrawingBrush o:Freeze="True" x:Key="BlogDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,160,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform> <DrawingBrush.Transform>
<TransformGroup o:Freeze="True"> <TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/> <RotateTransform o:Freeze="True" Angle="20"/>
@@ -59,7 +59,7 @@
<RectangleGeometry o:Freeze="True" Rect="0,0,160,100"></RectangleGeometry> <RectangleGeometry o:Freeze="True" Rect="0,0,160,100"></RectangleGeometry>
</GeometryDrawing.Geometry> </GeometryDrawing.Geometry>
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<VisualBrush o:Freeze="True"> <VisualBrush o:Freeze="True" RenderOptions.CachingHint="Cache" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" >
<VisualBrush.Visual> <VisualBrush.Visual>
<StackPanel> <StackPanel>
<TextBlock Text="Blog" Foreground="{DynamicResource DarkMaskBrush}"/> <TextBlock Text="Blog" Foreground="{DynamicResource DarkMaskBrush}"/>
@@ -71,7 +71,7 @@
</DrawingBrush.Drawing> </DrawingBrush.Drawing>
</DrawingBrush> </DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="WebsiteDrawingBrush" RenderOptions.CachingHint="Cache" Viewport="0,0,320,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile"> <DrawingBrush o:Freeze="True" x:Key="WebsiteDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,320,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform> <DrawingBrush.Transform>
<TransformGroup o:Freeze="True"> <TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/> <RotateTransform o:Freeze="True" Angle="20"/>
@@ -83,7 +83,7 @@
<RectangleGeometry o:Freeze="True" Rect="0,0,320,100"></RectangleGeometry> <RectangleGeometry o:Freeze="True" Rect="0,0,320,100"></RectangleGeometry>
</GeometryDrawing.Geometry> </GeometryDrawing.Geometry>
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<VisualBrush o:Freeze="True"> <VisualBrush o:Freeze="True" RenderOptions.CachingHint="Cache" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0">
<VisualBrush.Visual> <VisualBrush.Visual>
<StackPanel> <StackPanel>
<TextBlock Text="Website" Foreground="{DynamicResource DarkMaskBrush}"/> <TextBlock Text="Website" Foreground="{DynamicResource DarkMaskBrush}"/>
@@ -95,7 +95,7 @@
</DrawingBrush.Drawing> </DrawingBrush.Drawing>
</DrawingBrush> </DrawingBrush>
<DrawingBrush o:Freeze="True" x:Key="ProjectDrawingBrush" RenderOptions.CachingHint="Cache" Viewport="0,0,240,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile"> <DrawingBrush o:Freeze="True" x:Key="ProjectDrawingBrush" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" RenderOptions.CachingHint="Cache" Viewport="0,0,240,100" ViewportUnits="Absolute" Stretch="Uniform" TileMode="Tile">
<DrawingBrush.Transform> <DrawingBrush.Transform>
<TransformGroup o:Freeze="True"> <TransformGroup o:Freeze="True">
<RotateTransform o:Freeze="True" Angle="20"/> <RotateTransform o:Freeze="True" Angle="20"/>
@@ -107,7 +107,7 @@
<RectangleGeometry o:Freeze="True" Rect="0,0,240,100"></RectangleGeometry> <RectangleGeometry o:Freeze="True" Rect="0,0,240,100"></RectangleGeometry>
</GeometryDrawing.Geometry> </GeometryDrawing.Geometry>
<GeometryDrawing.Brush> <GeometryDrawing.Brush>
<VisualBrush o:Freeze="True"> <VisualBrush o:Freeze="True" RenderOptions.CachingHint="Cache" RenderOptions.CacheInvalidationThresholdMinimum="0.5" RenderOptions.CacheInvalidationThresholdMaximum="2.0" >
<VisualBrush.Visual> <VisualBrush.Visual>
<StackPanel> <StackPanel>
<TextBlock Text="Project" Foreground="{DynamicResource DarkMaskBrush}"/> <TextBlock Text="Project" Foreground="{DynamicResource DarkMaskBrush}"/>
@@ -27,7 +27,10 @@
</UserControl.Resources> </UserControl.Resources>
<UserControl.Triggers> <UserControl.Triggers>
<EventTrigger RoutedEvent="FrameworkElement.Loaded"> <EventTrigger RoutedEvent="FrameworkElement.Loaded">
<BeginStoryboard Storyboard="{StaticResource StoryboardOnLoaded}"/> <BeginStoryboard Name="BeginStoryboard" Storyboard="{StaticResource StoryboardOnLoaded}"/>
</EventTrigger>
<EventTrigger RoutedEvent="FrameworkElement.Unloaded">
<StopStoryboard BeginStoryboardName="BeginStoryboard"/>
</EventTrigger> </EventTrigger>
</UserControl.Triggers> </UserControl.Triggers>
<hc:TransitioningContentControl> <hc:TransitioningContentControl>
@@ -23,13 +23,46 @@ namespace HandyControl.Controls
private int _blockHeight; private int _blockHeight;
private bool _isDisposed;
public ImageBlock() public ImageBlock()
{ {
_dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render) _dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render)
{ {
Interval = Interval 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() private void UpdateDatas()
@@ -22,7 +22,7 @@ namespace HandyControl.Controls
[ContentProperty("Items")] [ContentProperty("Items")]
[TemplatePart(Name = ElementPanelPage, Type = typeof(Panel))] [TemplatePart(Name = ElementPanelPage, Type = typeof(Panel))]
[TemplatePart(Name = ElementItemsControl, Type = typeof(ItemsPresenter))] [TemplatePart(Name = ElementItemsControl, Type = typeof(ItemsPresenter))]
public class Carousel : ListBox public class Carousel : ListBox, IDisposable
{ {
#region Constants #region Constants
@@ -33,6 +33,8 @@ namespace HandyControl.Controls
#region Data #region Data
private bool _isDisposed;
private Panel _panelPage; private Panel _panelPage;
private bool _appliedTemplate; private bool _appliedTemplate;
@@ -119,6 +121,36 @@ namespace HandyControl.Controls
CommandBindings.Add(new CommandBinding(ControlCommands.Selected, ButtonPages_OnClick)); CommandBindings.Add(new CommandBinding(ControlCommands.Selected, ButtonPages_OnClick));
Loaded += (s, e) => UpdatePageButtons(); 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) protected override void OnItemsChanged(NotifyCollectionChangedEventArgs e)
@@ -93,10 +93,7 @@ namespace HandyControl.Controls
if (Application.Current != null) Application.Current.Exit += (s, e) => Dispose(); if (Application.Current != null) Application.Current.Exit += (s, e) => Dispose();
} }
~NotifyIcon() ~NotifyIcon() => Dispose(false);
{
Dispose(false);
}
public void Init() public void Init()
{ {
@@ -8,6 +8,10 @@ namespace HandyControl.Controls
{ {
public class FlipClock : Control public class FlipClock : Control
{ {
private readonly DispatcherTimer _dispatcherTimer;
private bool _isDisposed;
public static readonly DependencyProperty NumberListProperty = DependencyProperty.Register( public static readonly DependencyProperty NumberListProperty = DependencyProperty.Register(
"NumberList", typeof(List<int>), typeof(FlipClock), new PropertyMetadata(new List<int> {0, 0, 0, 0, 0, 0})); "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() public FlipClock()
{ {
var dispatcherTimer = new DispatcherTimer _dispatcherTimer = new DispatcherTimer(DispatcherPriority.Render)
{ {
Interval = TimeSpan.FromMilliseconds(200) 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; private void DispatcherTimer_Tick(object sender, EventArgs e) => DisplayTime = DateTime.Now;