diff --git a/HandyControl/Controls/Button/ProgressButton.cs b/HandyControl/Controls/Button/ProgressButton.cs new file mode 100644 index 00000000..87038921 --- /dev/null +++ b/HandyControl/Controls/Button/ProgressButton.cs @@ -0,0 +1,27 @@ +using System.Windows; +using System.Windows.Controls.Primitives; +using HandyControl.Data; + +namespace HandyControl.Controls +{ + public class ProgressButton : ToggleButton + { + public static readonly DependencyProperty ProgressStyleProperty = DependencyProperty.Register( + "ProgressStyle", typeof(Style), typeof(ProgressButton), new PropertyMetadata(default(Style))); + + public Style ProgressStyle + { + get => (Style) GetValue(ProgressStyleProperty); + set => SetValue(ProgressStyleProperty, value); + } + + public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register( + "Progress", typeof(double), typeof(ProgressButton), new PropertyMetadata(ValueBoxes.Double0Box)); + + public double Progress + { + get => (double) GetValue(ProgressProperty); + set => SetValue(ProgressProperty, value); + } + } +} \ No newline at end of file diff --git a/HandyControl/Controls/CoverFlow/CoverFlow.cs b/HandyControl/Controls/Cover/CoverFlow/CoverFlow.cs similarity index 100% rename from HandyControl/Controls/CoverFlow/CoverFlow.cs rename to HandyControl/Controls/Cover/CoverFlow/CoverFlow.cs diff --git a/HandyControl/Controls/CoverFlow/CoverFlowItem.cs b/HandyControl/Controls/Cover/CoverFlow/CoverFlowItem.cs similarity index 100% rename from HandyControl/Controls/CoverFlow/CoverFlowItem.cs rename to HandyControl/Controls/Cover/CoverFlow/CoverFlowItem.cs diff --git a/HandyControl/Controls/CoverView/CoverView.cs b/HandyControl/Controls/Cover/CoverView/CoverView.cs similarity index 100% rename from HandyControl/Controls/CoverView/CoverView.cs rename to HandyControl/Controls/Cover/CoverView/CoverView.cs diff --git a/HandyControl/Controls/CoverView/CoverViewContent.cs b/HandyControl/Controls/Cover/CoverView/CoverViewContent.cs similarity index 100% rename from HandyControl/Controls/CoverView/CoverViewContent.cs rename to HandyControl/Controls/Cover/CoverView/CoverViewContent.cs diff --git a/HandyControl/Controls/CoverView/CoverViewItem.cs b/HandyControl/Controls/Cover/CoverView/CoverViewItem.cs similarity index 100% rename from HandyControl/Controls/CoverView/CoverViewItem.cs rename to HandyControl/Controls/Cover/CoverView/CoverViewItem.cs diff --git a/HandyControl/HandyControl.csproj b/HandyControl/HandyControl.csproj index 282d82e9..26582c8b 100644 --- a/HandyControl/HandyControl.csproj +++ b/HandyControl/HandyControl.csproj @@ -90,10 +90,11 @@ - - - - + + + + + @@ -108,7 +109,7 @@ - + @@ -370,6 +371,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -610,6 +615,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/HandyControl/Themes/Styles/Base/ProgressBarBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ProgressBarBaseStyle.xaml index 1ac7de1f..df26dbfe 100644 --- a/HandyControl/Themes/Styles/Base/ProgressBarBaseStyle.xaml +++ b/HandyControl/Themes/Styles/Base/ProgressBarBaseStyle.xaml @@ -76,7 +76,7 @@ - + diff --git a/HandyControl/Themes/Styles/Base/ProgressButtonBaseStyle.xaml b/HandyControl/Themes/Styles/Base/ProgressButtonBaseStyle.xaml new file mode 100644 index 00000000..33ffb71f --- /dev/null +++ b/HandyControl/Themes/Styles/Base/ProgressButtonBaseStyle.xaml @@ -0,0 +1,67 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/ProgressButton.xaml b/HandyControl/Themes/Styles/ProgressButton.xaml new file mode 100644 index 00000000..c3d7257d --- /dev/null +++ b/HandyControl/Themes/Styles/ProgressButton.xaml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/HandyControl/Themes/Styles/Style.xaml b/HandyControl/Themes/Styles/Style.xaml index 8ec2be6a..52a4665c 100644 --- a/HandyControl/Themes/Styles/Style.xaml +++ b/HandyControl/Themes/Styles/Style.xaml @@ -54,6 +54,7 @@ + \ No newline at end of file diff --git a/HandyControlDemo/Data/MessageToken.cs b/HandyControlDemo/Data/MessageToken.cs index 739b20bb..85d7e771 100644 --- a/HandyControlDemo/Data/MessageToken.cs +++ b/HandyControlDemo/Data/MessageToken.cs @@ -76,6 +76,8 @@ public static readonly string CoverFlowDemoCtl = nameof(CoverFlowDemoCtl); + public static readonly string ProgressButtonDemoCtl = nameof(ProgressButtonDemoCtl); + public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl); public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl); diff --git a/HandyControlDemo/Data/MessageToken.tt b/HandyControlDemo/Data/MessageToken.tt index 4962b589..7fbce7b4 100644 --- a/HandyControlDemo/Data/MessageToken.tt +++ b/HandyControlDemo/Data/MessageToken.tt @@ -40,7 +40,8 @@ var controlList = new List "ShieldDemoCtl", "WaterfallPanelDemoCtl", "CoverViewDemoCtl", - "CoverFlowDemoCtl" + "CoverFlowDemoCtl", + "ProgressButtonDemoCtl" }; var styleList = new List { diff --git a/HandyControlDemo/HandyControlDemo.csproj b/HandyControlDemo/HandyControlDemo.csproj index 7f0efea6..a64a550e 100644 --- a/HandyControlDemo/HandyControlDemo.csproj +++ b/HandyControlDemo/HandyControlDemo.csproj @@ -189,6 +189,9 @@ PreviewSliderDemoCtl.xaml + + ProgressButtonDemoCtl.xaml + RateDemoCtl.xaml @@ -490,6 +493,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile @@ -704,6 +711,7 @@ TextTemplatingFileGenerator MessageToken.cs + diff --git a/HandyControlDemo/Properties/Langs/Lang.Designer.cs b/HandyControlDemo/Properties/Langs/Lang.Designer.cs index a19f2900..67ae02e4 100644 --- a/HandyControlDemo/Properties/Langs/Lang.Designer.cs +++ b/HandyControlDemo/Properties/Langs/Lang.Designer.cs @@ -789,6 +789,15 @@ namespace HandyControlDemo.Properties.Langs { } } + /// + /// 查找类似 进度按钮 的本地化字符串。 + /// + public static string ProgressButton { + get { + return ResourceManager.GetString("ProgressButton", resourceCulture); + } + } + /// /// 查找类似 QQ群 的本地化字符串。 /// @@ -1104,6 +1113,15 @@ namespace HandyControlDemo.Properties.Langs { } } + /// + /// 查找类似 上传;上传中 的本地化字符串。 + /// + public static string UploadStr { + get { + return ResourceManager.GetString("UploadStr", resourceCulture); + } + } + /// /// 查找类似 警告 的本地化字符串。 /// diff --git a/HandyControlDemo/Properties/Langs/Lang.en.resx b/HandyControlDemo/Properties/Langs/Lang.en.resx index 3db23d8b..04e9e197 100644 --- a/HandyControlDemo/Properties/Langs/Lang.en.resx +++ b/HandyControlDemo/Properties/Langs/Lang.en.resx @@ -474,4 +474,10 @@ MessageBox - + + ProgressButton + + + Upload;Uploading + + \ No newline at end of file diff --git a/HandyControlDemo/Properties/Langs/Lang.resx b/HandyControlDemo/Properties/Langs/Lang.resx index 37ee53dc..ce90e40f 100644 --- a/HandyControlDemo/Properties/Langs/Lang.resx +++ b/HandyControlDemo/Properties/Langs/Lang.resx @@ -474,4 +474,10 @@ 消息框 - + + 进度按钮 + + + 上传;上传中 + + \ No newline at end of file diff --git a/HandyControlDemo/Resources/Img/LeftMainContent/ProgressButton_16x.png b/HandyControlDemo/Resources/Img/LeftMainContent/ProgressButton_16x.png new file mode 100644 index 00000000..ad7026ac Binary files /dev/null and b/HandyControlDemo/Resources/Img/LeftMainContent/ProgressButton_16x.png differ diff --git a/HandyControlDemo/UserControl/Controls/ProgressButtonDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/ProgressButtonDemoCtl.xaml new file mode 100644 index 00000000..4b78b122 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/ProgressButtonDemoCtl.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + + diff --git a/HandyControlDemo/UserControl/Controls/ProgressButtonDemoCtl.xaml.cs b/HandyControlDemo/UserControl/Controls/ProgressButtonDemoCtl.xaml.cs new file mode 100644 index 00000000..f44f7110 --- /dev/null +++ b/HandyControlDemo/UserControl/Controls/ProgressButtonDemoCtl.xaml.cs @@ -0,0 +1,65 @@ +using System; +using System.Windows; +using System.Windows.Threading; + +namespace HandyControlDemo.UserControl +{ + public partial class ProgressButtonDemoCtl + { + public static readonly DependencyProperty ProgressProperty = DependencyProperty.Register( + "Progress", typeof(int), typeof(ProgressButtonDemoCtl), new PropertyMetadata(default(int))); + + public int Progress + { + get => (int) GetValue(ProgressProperty); + set => SetValue(ProgressProperty, value); + } + + public static readonly DependencyProperty IsUploadingProperty = DependencyProperty.Register( + "IsUploading", typeof(bool), typeof(ProgressButtonDemoCtl), new PropertyMetadata(default(bool))); + + public bool IsUploading + { + get => (bool) GetValue(IsUploadingProperty); + set => SetValue(IsUploadingProperty, value); + } + + private readonly DispatcherTimer _timer; + + public ProgressButtonDemoCtl() + { + InitializeComponent(); + + DataContext = this; + + _timer = new DispatcherTimer + { + Interval = TimeSpan.FromMilliseconds(200) + }; + _timer.Tick += Timer_Tick; + } + + private void Timer_Tick(object sender, EventArgs e) + { + Progress++; + if (Progress == 100) + { + Progress = 0; + _timer.Stop(); + IsUploading = false; + } + } + + private void ButtonProgress_OnClick(object sender, RoutedEventArgs e) + { + if (_timer.IsEnabled) + { + _timer.Stop(); + } + else + { + _timer.Start(); + } + } + } +} diff --git a/HandyControlDemo/UserControl/Controls/WaterfallPanelDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/WaterfallPanelDemoCtl.xaml index 9a631afa..7ba4b060 100644 --- a/HandyControlDemo/UserControl/Controls/WaterfallPanelDemoCtl.xaml +++ b/HandyControlDemo/UserControl/Controls/WaterfallPanelDemoCtl.xaml @@ -5,7 +5,7 @@ xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs" xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl" Background="{DynamicResource RegionBrush}"> - + @@ -53,5 +53,5 @@ - + diff --git a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml index 7f1b2552..b4b12e0d 100644 --- a/HandyControlDemo/UserControl/Main/LeftMainContent.xaml +++ b/HandyControlDemo/UserControl/Main/LeftMainContent.xaml @@ -182,6 +182,11 @@ + + + + + @@ -232,7 +237,7 @@ - + diff --git a/README.md b/README.md index e5279bc9..9ece5e4d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,10 @@ ## Latest examples +### ProgressButton + +![ProgressButton](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ProgressButton.png) + ### CoverFlow ![CoverFlow](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/CoverFlow.gif) @@ -22,6 +26,8 @@ ![WaterfallPanel](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/WaterfallPanel.png) +## History publication + ### Rate ![Rate](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Rate.png) @@ -30,8 +36,6 @@ ![BlurWindow](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/BlurWindow.png) -## History publication - ### FlipClock ![FlipClock](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/FlipClock.gif) diff --git a/Resources/ProgressButton.png b/Resources/ProgressButton.png new file mode 100644 index 00000000..9af0542d Binary files /dev/null and b/Resources/ProgressButton.png differ