mirror of
https://gitee.com/handyorg/HandyControl.git
synced 2024-12-04 21:07:49 +08:00
update pr/59
This commit is contained in:
parent
0fb520bf8d
commit
ada85bb59d
@ -1,37 +1,31 @@
|
|||||||
using System.Windows;
|
using System;
|
||||||
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
|
|
||||||
namespace HandyControl.Controls
|
namespace HandyControl.Controls
|
||||||
{
|
{
|
||||||
public enum BadgeStatus { Normal, Dot, Processing }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 标记
|
/// 标记
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Badge : ContentControl
|
public class Badge : ContentControl
|
||||||
{
|
{
|
||||||
public static readonly RoutedEvent BadgeChangedEvent = EventManager.RegisterRoutedEvent(
|
public static readonly RoutedEvent ValueChangedEvent =
|
||||||
"BadgeChanged", RoutingStrategy.Direct, typeof(RoutedEventHandler), typeof(Badge));
|
EventManager.RegisterRoutedEvent("ValueChanged", RoutingStrategy.Bubble,
|
||||||
|
typeof(EventHandler<FunctionEventArgs<int>>), typeof(Badge));
|
||||||
|
|
||||||
public event RoutedEventHandler BadgeChanged
|
public event EventHandler<FunctionEventArgs<int>> ValueChanged
|
||||||
{
|
{
|
||||||
add => AddHandler(BadgeChangedEvent, value);
|
add => AddHandler(ValueChangedEvent, value);
|
||||||
remove => RemoveHandler(BadgeChangedEvent, value);
|
remove => RemoveHandler(ValueChangedEvent, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty TextProperty = DependencyProperty.Register(
|
||||||
"Text", typeof(string), typeof(Badge), new PropertyMetadata(default(string), (o, args) =>
|
"Text", typeof(string), typeof(Badge), new PropertyMetadata(default(string)));
|
||||||
{
|
|
||||||
var ctl = (Badge)o;
|
|
||||||
|
|
||||||
if (ctl.IsInitialized)
|
|
||||||
ctl.RaiseEvent(new RoutedEventArgs(BadgeChangedEvent, ctl));
|
|
||||||
}));
|
|
||||||
|
|
||||||
public string Text
|
public string Text
|
||||||
{
|
{
|
||||||
get => (string)GetValue(TextProperty);
|
get => (string) GetValue(TextProperty);
|
||||||
set => SetValue(TextProperty, value);
|
set => SetValue(TextProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,6 +37,13 @@ namespace HandyControl.Controls
|
|||||||
var ctl = (Badge)d;
|
var ctl = (Badge)d;
|
||||||
var v = (int)e.NewValue;
|
var v = (int)e.NewValue;
|
||||||
ctl.Text = v <= ctl.Maximum ? v.ToString() : $"{ctl.Maximum}+";
|
ctl.Text = v <= ctl.Maximum ? v.ToString() : $"{ctl.Maximum}+";
|
||||||
|
if (ctl.IsInitialized)
|
||||||
|
{
|
||||||
|
ctl.RaiseEvent(new FunctionEventArgs<int>(ValueChangedEvent, ctl)
|
||||||
|
{
|
||||||
|
Info = v
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Value
|
public int Value
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Documents;
|
using System.Windows.Documents;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using HandyControl.Data;
|
||||||
using HandyControl.Interactivity;
|
using HandyControl.Interactivity;
|
||||||
using HandyControl.Tools;
|
using HandyControl.Tools;
|
||||||
|
|
||||||
@ -12,7 +13,7 @@ namespace HandyControl.Controls
|
|||||||
private Adorner _container;
|
private Adorner _container;
|
||||||
|
|
||||||
public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register(
|
public static readonly DependencyProperty IsClosedProperty = DependencyProperty.Register(
|
||||||
"IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(default(bool)));
|
"IsClosed", typeof(bool), typeof(Dialog), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||||
|
|
||||||
public bool IsClosed
|
public bool IsClosed
|
||||||
{
|
{
|
||||||
|
9
HandyControl/Data/Enum/BadgeStatus.cs
Normal file
9
HandyControl/Data/Enum/BadgeStatus.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace HandyControl.Data
|
||||||
|
{
|
||||||
|
public enum BadgeStatus
|
||||||
|
{
|
||||||
|
Text,
|
||||||
|
Dot,
|
||||||
|
Processing
|
||||||
|
}
|
||||||
|
}
|
@ -165,6 +165,7 @@
|
|||||||
<Compile Include="Controls\Window\BlurWindow.cs" />
|
<Compile Include="Controls\Window\BlurWindow.cs" />
|
||||||
<Compile Include="Controls\Window\MessageBox.cs" />
|
<Compile Include="Controls\Window\MessageBox.cs" />
|
||||||
<Compile Include="Data\Args\CancelRoutedEventArgs.cs" />
|
<Compile Include="Data\Args\CancelRoutedEventArgs.cs" />
|
||||||
|
<Compile Include="Data\Enum\BadgeStatus.cs" />
|
||||||
<Compile Include="Data\Enum\ChatMessageType.cs" />
|
<Compile Include="Data\Enum\ChatMessageType.cs" />
|
||||||
<Compile Include="Data\Enum\ChatRoleType.cs" />
|
<Compile Include="Data\Enum\ChatRoleType.cs" />
|
||||||
<Compile Include="Data\Enum\InfoType.cs" />
|
<Compile Include="Data\Enum\InfoType.cs" />
|
||||||
|
@ -13,28 +13,15 @@
|
|||||||
<Border.RenderTransform>
|
<Border.RenderTransform>
|
||||||
<ScaleTransform />
|
<ScaleTransform />
|
||||||
</Border.RenderTransform>
|
</Border.RenderTransform>
|
||||||
|
|
||||||
<ContentPresenter ContentSource="Text" Margin="{TemplateBinding Padding}" />
|
<ContentPresenter ContentSource="Text" Margin="{TemplateBinding Padding}" />
|
||||||
</Border>
|
</Border>
|
||||||
</controls:SimplePanel>
|
</controls:SimplePanel>
|
||||||
<ControlTemplate.Triggers>
|
<ControlTemplate.Triggers>
|
||||||
<EventTrigger RoutedEvent="controls:Badge.BadgeChanged">
|
<EventTrigger RoutedEvent="controls:Badge.ValueChanged">
|
||||||
<BeginStoryboard>
|
<BeginStoryboard>
|
||||||
<Storyboard AutoReverse="True">
|
<Storyboard AutoReverse="True">
|
||||||
<DoubleAnimation Storyboard.TargetName="Border"
|
<DoubleAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)" BeginTime="0" Duration="0:0:.1" From="1" To="1.2" EasingFunction="{StaticResource SineEaseOut}" />
|
||||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"
|
<DoubleAnimation Storyboard.TargetName="Border" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)" BeginTime="0" Duration="0:0:.1" From="1" To="1.2" EasingFunction="{StaticResource SineEaseOut}" />
|
||||||
BeginTime="0"
|
|
||||||
Duration="0:0:.1"
|
|
||||||
From="1"
|
|
||||||
To="1.2"
|
|
||||||
EasingFunction="{StaticResource SineEaseOut}" />
|
|
||||||
<DoubleAnimation Storyboard.TargetName="Border"
|
|
||||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleY)"
|
|
||||||
BeginTime="0"
|
|
||||||
Duration="0:0:.1"
|
|
||||||
From="1"
|
|
||||||
To="1.2"
|
|
||||||
EasingFunction="{StaticResource SineEaseOut}" />
|
|
||||||
</Storyboard>
|
</Storyboard>
|
||||||
</BeginStoryboard>
|
</BeginStoryboard>
|
||||||
</EventTrigger>
|
</EventTrigger>
|
||||||
|
@ -364,7 +364,7 @@
|
|||||||
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
|
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Basic\InteractiveDialogViewModel.cs" />
|
<Compile Include="ViewModel\Basic\InteractiveDialogViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Controls\BadgeDemoCtlViewModel.cs" />
|
<Compile Include="ViewModel\Controls\BadgeDemoViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
|
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" />
|
<Compile Include="ViewModel\Controls\DialogDemoViewModel.cs" />
|
||||||
<Compile Include="ViewModel\Controls\NotifyIconDemoViewModel.cs" />
|
<Compile Include="ViewModel\Controls\NotifyIconDemoViewModel.cs" />
|
||||||
|
338
HandyControlDemo/Properties/Langs/Lang.Designer.cs
generated
338
HandyControlDemo/Properties/Langs/Lang.Designer.cs
generated
File diff suppressed because it is too large
Load Diff
@ -561,7 +561,7 @@
|
|||||||
<data name="PleaseInput" xml:space="preserve">
|
<data name="PleaseInput" xml:space="preserve">
|
||||||
<value>Please input...</value>
|
<value>Please input...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Count" xml:space="preserve">
|
<data name="Click2Count" xml:space="preserve">
|
||||||
<value>Count</value>
|
<value>Click to count</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
@ -561,7 +561,7 @@
|
|||||||
<data name="PleaseInput" xml:space="preserve">
|
<data name="PleaseInput" xml:space="preserve">
|
||||||
<value>请输入...</value>
|
<value>请输入...</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="Count" xml:space="preserve">
|
<data name="Click2Count" xml:space="preserve">
|
||||||
<value>点击计数</value>
|
<value>点击计数</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
@ -4,7 +4,7 @@
|
|||||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
||||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||||
Background="{DynamicResource RegionBrush}"
|
Background="{DynamicResource RegionBrush}"
|
||||||
DataContext="{Binding Path=BadgeDemoCtl, Source={StaticResource Locator}}">
|
DataContext="{Binding BadgeDemo, Source={StaticResource Locator}}">
|
||||||
<controls:TransitioningContentControl>
|
<controls:TransitioningContentControl>
|
||||||
<StackPanel Margin="32" Orientation="Horizontal">
|
<StackPanel Margin="32" Orientation="Horizontal">
|
||||||
<controls:Badge Text="New" BadgeMargin="0,-14,-20,0" Height="30">
|
<controls:Badge Text="New" BadgeMargin="0,-14,-20,0" Height="30">
|
||||||
@ -13,8 +13,8 @@
|
|||||||
<controls:Badge Text="New" BadgeMargin="0,-14,-20,0" Height="30" Margin="32,0,0,0" Style="{StaticResource BadgeDanger}">
|
<controls:Badge Text="New" BadgeMargin="0,-14,-20,0" Height="30" Margin="32,0,0,0" Style="{StaticResource BadgeDanger}">
|
||||||
<Button Content="{x:Static langs:Lang.Comment}"/>
|
<Button Content="{x:Static langs:Lang.Comment}"/>
|
||||||
</controls:Badge>
|
</controls:Badge>
|
||||||
<controls:Badge Value="{Binding Count}" Height="30" Margin="32,0,0,0" Style="{StaticResource BadgePrimary}">
|
<controls:Badge Value="{Binding Count}" BadgeMargin="0,-14,-10,0" Height="30" Margin="32,0,0,0" Style="{StaticResource BadgePrimary}">
|
||||||
<Button Content="{x:Static langs:Lang.Count}" Command="{Binding CountCommand}"/>
|
<Button Content="{x:Static langs:Lang.Click2Count}" Command="{Binding CountCmd}"/>
|
||||||
</controls:Badge>
|
</controls:Badge>
|
||||||
<controls:Badge Value="100" BadgeMargin="0,-14,-20,0" Height="30" Margin="32,0,0,0" Style="{StaticResource BadgeDanger}">
|
<controls:Badge Value="100" BadgeMargin="0,-14,-20,0" Height="30" Margin="32,0,0,0" Style="{StaticResource BadgeDanger}">
|
||||||
<Button Content="{x:Static langs:Lang.Comment}"/>
|
<Button Content="{x:Static langs:Lang.Comment}"/>
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
using System.Windows.Input;
|
|
||||||
using GalaSoft.MvvmLight;
|
|
||||||
using GalaSoft.MvvmLight.CommandWpf;
|
|
||||||
|
|
||||||
namespace HandyControlDemo.ViewModel.Controls
|
|
||||||
{
|
|
||||||
public class BadgeDemoCtlViewModel : ViewModelBase
|
|
||||||
{
|
|
||||||
private int _count;
|
|
||||||
|
|
||||||
public int Count
|
|
||||||
{
|
|
||||||
get => _count;
|
|
||||||
set => Set(ref _count, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ICommand CountCommand { get; }
|
|
||||||
|
|
||||||
public BadgeDemoCtlViewModel()
|
|
||||||
{
|
|
||||||
Count = 1;
|
|
||||||
CountCommand = new RelayCommand(() => Count++);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
20
HandyControlDemo/ViewModel/Controls/BadgeDemoViewModel.cs
Normal file
20
HandyControlDemo/ViewModel/Controls/BadgeDemoViewModel.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using GalaSoft.MvvmLight;
|
||||||
|
using GalaSoft.MvvmLight.CommandWpf;
|
||||||
|
|
||||||
|
namespace HandyControlDemo.ViewModel.Controls
|
||||||
|
{
|
||||||
|
public class BadgeDemoViewModel : ViewModelBase
|
||||||
|
{
|
||||||
|
private int _count = 1;
|
||||||
|
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get => _count;
|
||||||
|
set => Set(ref _count, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RelayCommand CountCmd => new Lazy<RelayCommand>(() =>
|
||||||
|
new RelayCommand(() => Count++)).Value;
|
||||||
|
}
|
||||||
|
}
|
@ -32,7 +32,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
SimpleIoc.Default.Register<SearchBarDemoViewModel>();
|
SimpleIoc.Default.Register<SearchBarDemoViewModel>();
|
||||||
SimpleIoc.Default.Register<NotifyIconDemoViewModel>();
|
SimpleIoc.Default.Register<NotifyIconDemoViewModel>();
|
||||||
SimpleIoc.Default.Register<InteractiveDialogViewModel>();
|
SimpleIoc.Default.Register<InteractiveDialogViewModel>();
|
||||||
SimpleIoc.Default.Register<BadgeDemoCtlViewModel>();
|
SimpleIoc.Default.Register<BadgeDemoViewModel>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||||
@ -70,7 +70,7 @@ namespace HandyControlDemo.ViewModel
|
|||||||
|
|
||||||
public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance<InteractiveDialogViewModel>();
|
public InteractiveDialogViewModel InteractiveDialog => ServiceLocator.Current.GetInstance<InteractiveDialogViewModel>();
|
||||||
|
|
||||||
public BadgeDemoCtlViewModel BadgeDemoCtl => ServiceLocator.Current.GetInstance<BadgeDemoCtlViewModel>();
|
public BadgeDemoViewModel BadgeDemo => ServiceLocator.Current.GetInstance<BadgeDemoViewModel>();
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user