add ProgressButton

This commit is contained in:
NaBian committed 2019-01-22 20:02:40 +08:00
1 parent 840fcca2c0
commit 58dc24b51c
24 files changed
+293 -14

No files matched your search

@@ -0,0 +1,17 @@
<UserControl x:Class="HandyControlDemo.UserControl.ProgressButtonDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
Background="{DynamicResource RegionBrush}">
<controls:TransitioningContentControl>
<StackPanel Margin="32" Width="300" Button.Click="ButtonProgress_OnClick" VerticalAlignment="Center">
<controls:ProgressButton IsChecked="{Binding IsUploading,Mode=TwoWay}" Progress="{Binding Progress}" Content="{Binding IsChecked,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2StrConverter},ConverterParameter={x:Static langs:Lang.UploadStr}}" Width="180" Margin="5"/>
<controls:ProgressButton Style="{StaticResource ProgressButtonPrimary}" IsChecked="{Binding IsUploading,Mode=TwoWay}" Progress="{Binding Progress}" Content="{Binding IsChecked,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2StrConverter},ConverterParameter={x:Static langs:Lang.UploadStr}}" Width="180" Margin="5"/>
<controls:ProgressButton Style="{StaticResource ProgressButtonSuccess}" IsChecked="{Binding IsUploading,Mode=TwoWay}" Progress="{Binding Progress}" Content="{Binding IsChecked,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2StrConverter},ConverterParameter={x:Static langs:Lang.UploadStr}}" Width="180" Margin="5"/>
<controls:ProgressButton Style="{StaticResource ProgressButtonInfo}" IsChecked="{Binding IsUploading,Mode=TwoWay}" Progress="{Binding Progress}" Content="{Binding IsChecked,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2StrConverter},ConverterParameter={x:Static langs:Lang.UploadStr}}" Width="180" Margin="5"/>
<controls:ProgressButton Style="{StaticResource ProgressButtonWarning}" IsChecked="{Binding IsUploading,Mode=TwoWay}" Progress="{Binding Progress}" Content="{Binding IsChecked,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2StrConverter},ConverterParameter={x:Static langs:Lang.UploadStr}}" Width="180" Margin="5"/>
<controls:ProgressButton Style="{StaticResource ProgressButtonDanger}" IsChecked="{Binding IsUploading,Mode=TwoWay}" Progress="{Binding Progress}" Content="{Binding IsChecked,RelativeSource={RelativeSource Self},Converter={StaticResource Boolean2StrConverter},ConverterParameter={x:Static langs:Lang.UploadStr}}" Width="180" Margin="5"/>
</StackPanel>
</controls:TransitioningContentControl>
</UserControl>
@@ -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();
}
}
}
}
@@ -5,7 +5,7 @@
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity;assembly=HandyControl"
Background="{DynamicResource RegionBrush}">
<ContentControl>
<controls:TransitioningContentControl>
<Grid Margin="32">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
@@ -53,5 +53,5 @@
</controls:ScrollViewer>
</StackPanel>
</Grid>
</ContentControl>
</controls:TransitioningContentControl>
</UserControl>
@@ -182,6 +182,11 @@
</controls:StatusSwitchElement.CheckedElement>
</ToggleButton>
<ListBox Name="listControl" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.ProgressButtonDemoCtl}" Content="{x:Static langs:Lang.ProgressButton}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/ProgressButton_16x.png"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Tag="{x:Static data:MessageToken.NumericUpDownDemoCtl}" Content="{x:Static langs:Lang.NumericUpDown}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/NumericListBox_16x.png"/>
@@ -232,7 +237,7 @@
<Image Source="../../Resources/Img/LeftMainContent/FlipVertical_16x.png"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.RateDemoCtl}" Content="{x:Static langs:Lang.Rate}">
<ListBoxItem Tag="{x:Static data:MessageToken.RateDemoCtl}" Content="{x:Static langs:Lang.Rate}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/Star.png"/>
</controls:EdgeElement.LeftContent>