This commit is contained in:
NaBian committed 2020-05-07 22:57:54 +08:00
1 parent 518afc8845
commit ce94186801
14 files changed
+72 -4

No files matched your search

@@ -97,7 +97,7 @@
</PackageReference> </PackageReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<EmbeddedResource Include="..\..\Shared\HandyControl_Shared\Properties\Langs\Lang.tr.resx"> <EmbeddedResource Include="..\..\Shared\HandyControl_Shared\Properties\Langs\Lang.tr.resx">
<Link>Properties\Langs\Lang.tr.resx</Link> <Link>Properties\Langs\Lang.tr.resx</Link>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="..\..\Shared\HandyControl_Shared\Properties\Langs\Lang.en.resx"> <EmbeddedResource Include="..\..\Shared\HandyControl_Shared\Properties\Langs\Lang.en.resx">
@@ -208,4 +208,4 @@
<Page Remove="..\..\Shared\HandyControl_Shared\Themes\Styles\MessageBox.xaml" /> <Page Remove="..\..\Shared\HandyControl_Shared\Themes\Styles\MessageBox.xaml" />
<Page Remove="..\..\Shared\HandyControl_Shared\Themes\Styles\Window.xaml" /> <Page Remove="..\..\Shared\HandyControl_Shared\Themes\Styles\Window.xaml" />
</ItemGroup> </ItemGroup>
</Project> </Project>
@@ -12,7 +12,7 @@
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<hc:Pagination MaxPageCount="10" PageIndex="{Binding PageIndex}"> <hc:Pagination MaxPageCount="10" PageIndex="{Binding PageIndex}" IsJumpEnabled="True">
<hc:Interaction.Triggers> <hc:Interaction.Triggers>
<hc:EventTrigger EventName="PageUpdated"> <hc:EventTrigger EventName="PageUpdated">
<hc:EventToCommand Command="{Binding PageUpdatedCmd}" PassEventArgsToCommand="True" /> <hc:EventToCommand Command="{Binding PageUpdatedCmd}" PassEventArgsToCommand="True" />
@@ -19,6 +19,7 @@ namespace HandyControl.Controls
[TemplatePart(Name = ElementPanelMain, Type = typeof(Panel))] [TemplatePart(Name = ElementPanelMain, Type = typeof(Panel))]
[TemplatePart(Name = ElementMoreRight, Type = typeof(FrameworkElement))] [TemplatePart(Name = ElementMoreRight, Type = typeof(FrameworkElement))]
[TemplatePart(Name = ElementButtonLast, Type = typeof(RadioButton))] [TemplatePart(Name = ElementButtonLast, Type = typeof(RadioButton))]
[TemplatePart(Name = ElementButtonLast, Type = typeof(NumericUpDown))]
public class Pagination : Control public class Pagination : Control
{ {
#region Constants #region Constants
@@ -30,6 +31,7 @@ namespace HandyControl.Controls
private const string ElementPanelMain = "PART_PanelMain"; private const string ElementPanelMain = "PART_PanelMain";
private const string ElementMoreRight = "PART_MoreRight"; private const string ElementMoreRight = "PART_MoreRight";
private const string ElementButtonLast = "PART_ButtonLast"; private const string ElementButtonLast = "PART_ButtonLast";
private const string ElementJump = "PART_Jump";
#endregion Constants #endregion Constants
@@ -42,6 +44,7 @@ namespace HandyControl.Controls
private Panel _panelMain; private Panel _panelMain;
private FrameworkElement _moreRight; private FrameworkElement _moreRight;
private RadioButton _buttonLast; private RadioButton _buttonLast;
private NumericUpDown _jumpNumericUpDown;
private bool _appliedTemplate; private bool _appliedTemplate;
@@ -72,6 +75,7 @@ namespace HandyControl.Controls
CommandBindings.Add(new CommandBinding(ControlCommands.Prev, ButtonPrev_OnClick)); CommandBindings.Add(new CommandBinding(ControlCommands.Prev, ButtonPrev_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Next, ButtonNext_OnClick)); CommandBindings.Add(new CommandBinding(ControlCommands.Next, ButtonNext_OnClick));
CommandBindings.Add(new CommandBinding(ControlCommands.Selected, ToggleButton_OnChecked)); CommandBindings.Add(new CommandBinding(ControlCommands.Selected, ToggleButton_OnChecked));
CommandBindings.Add(new CommandBinding(ControlCommands.Jump, (s, e) => PageIndex = (int) _jumpNumericUpDown.Value));
this.Show(MaxPageCount > 1); this.Show(MaxPageCount > 1);
} }
@@ -219,6 +223,19 @@ namespace HandyControl.Controls
#endregion MaxPageInterval #endregion MaxPageInterval
#region IsJumpEnabled
public static readonly DependencyProperty IsJumpEnabledProperty = DependencyProperty.Register(
"IsJumpEnabled", typeof(bool), typeof(Pagination), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsJumpEnabled
{
get => (bool) GetValue(IsJumpEnabledProperty);
set => SetValue(IsJumpEnabledProperty, value);
}
#endregion
#endregion #endregion
#region Public Methods #region Public Methods
@@ -235,6 +252,7 @@ namespace HandyControl.Controls
_panelMain = GetTemplateChild(ElementPanelMain) as Panel; _panelMain = GetTemplateChild(ElementPanelMain) as Panel;
_moreRight = GetTemplateChild(ElementMoreRight) as FrameworkElement; _moreRight = GetTemplateChild(ElementMoreRight) as FrameworkElement;
_buttonLast = GetTemplateChild(ElementButtonLast) as RadioButton; _buttonLast = GetTemplateChild(ElementButtonLast) as RadioButton;
_jumpNumericUpDown = GetTemplateChild(ElementJump) as NumericUpDown;
CheckNull(); CheckNull();
@@ -107,6 +107,11 @@ namespace HandyControl.Interactivity
/// </summary> /// </summary>
public static RoutedCommand Next { get; } = new RoutedCommand(nameof(Next), typeof(ControlCommands)); public static RoutedCommand Next { get; } = new RoutedCommand(nameof(Next), typeof(ControlCommands));
/// <summary>
/// 跳转
/// </summary>
public static RoutedCommand Jump { get; } = new RoutedCommand(nameof(Jump), typeof(ControlCommands));
/// <summary> /// <summary>
/// 上午 /// 上午
/// </summary> /// </summary>
@@ -249,6 +249,15 @@ namespace HandyControl.Properties.Langs {
} }
} }
/// <summary>
/// 查找类似 跳转 的本地化字符串。
/// </summary>
public static string Jump {
get {
return ResourceManager.GetString("Jump", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。 /// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。
/// </summary> /// </summary>
@@ -231,4 +231,7 @@
<data name="LangComment" xml:space="preserve"> <data name="LangComment" xml:space="preserve">
<value>Looks up a localized string similar to "{0}".</value> <value>Looks up a localized string similar to "{0}".</value>
</data> </data>
<data name="Jump" xml:space="preserve">
<value>Jump</value>
</data>
</root> </root>
@@ -231,4 +231,7 @@
<data name="LangComment" xml:space="preserve"> <data name="LangComment" xml:space="preserve">
<value>Looks up a localized string similar to "{0}".</value> <value>Looks up a localized string similar to "{0}".</value>
</data> </data>
<data name="Jump" xml:space="preserve">
<value>Jump</value>
</data>
</root> </root>
@@ -231,4 +231,7 @@
<data name="LangComment" xml:space="preserve"> <data name="LangComment" xml:space="preserve">
<value>Looks up a localized string similar to "{0}".</value> <value>Looks up a localized string similar to "{0}".</value>
</data> </data>
<data name="Jump" xml:space="preserve">
<value>Jump</value>
</data>
</root> </root>
@@ -231,4 +231,7 @@
<data name="LangComment" xml:space="preserve"> <data name="LangComment" xml:space="preserve">
<value>Looks up a localized string similar to "{0}".</value> <value>Looks up a localized string similar to "{0}".</value>
</data> </data>
<data name="Jump" xml:space="preserve">
<value>Jump</value>
</data>
</root> </root>
@@ -231,4 +231,7 @@
<data name="LangComment" xml:space="preserve"> <data name="LangComment" xml:space="preserve">
<value>查找类似 {0} 的本地化字符串。</value> <value>查找类似 {0} 的本地化字符串。</value>
</data> </data>
<data name="Jump" xml:space="preserve">
<value>跳转</value>
</data>
</root> </root>
@@ -231,4 +231,7 @@
<data name="LangComment" xml:space="preserve"> <data name="LangComment" xml:space="preserve">
<value>Ищет локализованную строку, похожую на "{0}".</value> <value>Ищет локализованную строку, похожую на "{0}".</value>
</data> </data>
<data name="Jump" xml:space="preserve">
<value>Jump</value>
</data>
</root> </root>
@@ -231,4 +231,7 @@
<data name="LangComment" xml:space="preserve"> <data name="LangComment" xml:space="preserve">
<value>Looks up a localized string similar to "{0}".</value> <value>Looks up a localized string similar to "{0}".</value>
</data> </data>
<data name="Jump" xml:space="preserve">
<value>Jump</value>
</data>
</root> </root>
@@ -58,6 +58,7 @@ namespace HandyControl.Properties.Langs
OnPropertyChanged(nameof(Interval30s)); OnPropertyChanged(nameof(Interval30s));
OnPropertyChanged(nameof(Interval5m)); OnPropertyChanged(nameof(Interval5m));
OnPropertyChanged(nameof(IsNecessary)); OnPropertyChanged(nameof(IsNecessary));
OnPropertyChanged(nameof(Jump));
OnPropertyChanged(nameof(LangComment)); OnPropertyChanged(nameof(LangComment));
OnPropertyChanged(nameof(NextPage)); OnPropertyChanged(nameof(NextPage));
OnPropertyChanged(nameof(No)); OnPropertyChanged(nameof(No));
@@ -182,6 +183,11 @@ namespace HandyControl.Properties.Langs
/// </summary> /// </summary>
public string IsNecessary => Lang.IsNecessary; public string IsNecessary => Lang.IsNecessary;
/// <summary>
/// 查找类似 跳转 的本地化字符串。
/// </summary>
public string Jump => Lang.Jump;
/// <summary> /// <summary>
/// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。 /// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。
/// </summary> /// </summary>
@@ -381,6 +387,11 @@ namespace HandyControl.Properties.Langs
/// </summary> /// </summary>
public static string IsNecessary = nameof(IsNecessary); public static string IsNecessary = nameof(IsNecessary);
/// <summary>
/// 查找类似 跳转 的本地化字符串。
/// </summary>
public static string Jump = nameof(Jump);
/// <summary> /// <summary>
/// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。 /// 查找类似 查找类似 {0} 的本地化字符串。 的本地化字符串。
/// </summary> /// </summary>
@@ -2,7 +2,9 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls" xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity" xmlns:interactivity="clr-namespace:HandyControl.Interactivity"
xmlns:system="clr-namespace:System;assembly=mscorlib"> xmlns:system="clr-namespace:System;assembly=mscorlib"
xmlns:lang="clr-namespace:HandyControl.Properties.Langs"
xmlns:ex="clr-namespace:HandyControl.Tools.Extension">
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../Basic/Geometries.xaml"/> <ResourceDictionary Source="../Basic/Geometries.xaml"/>
@@ -95,6 +97,8 @@
<RadioButton Name="PART_ButtonLast" Content="10" Style="{StaticResource PaginationButtonStyle}"/> <RadioButton Name="PART_ButtonLast" Content="10" Style="{StaticResource PaginationButtonStyle}"/>
</StackPanel> </StackPanel>
<Button x:Name="PART_ButtonRight" MinWidth="30" Padding="10,8" controls:IconElement.Geometry="{StaticResource RightGeometry}" controls:BorderElement.CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='0,1,1,0'}" Margin="-1,0,0,0" Command="interactivity:ControlCommands.Next"/> <Button x:Name="PART_ButtonRight" MinWidth="30" Padding="10,8" controls:IconElement.Geometry="{StaticResource RightGeometry}" controls:BorderElement.CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent},Converter={StaticResource CornerRadiusSplitConverter},ConverterParameter='0,1,1,0'}" Margin="-1,0,0,0" Command="interactivity:ControlCommands.Next"/>
<controls:NumericUpDown x:Name="PART_Jump" IsEnabled="{TemplateBinding IsJumpEnabled}" Visibility="{TemplateBinding IsJumpEnabled,Converter={StaticResource Boolean2VisibilityConverter}}" Margin="6,0,0,0" Maximum="{Binding MaxPageCount,RelativeSource={RelativeSource TemplatedParent}}" Minimum="1"/>
<Button IsEnabled="{TemplateBinding IsJumpEnabled}" Visibility="{TemplateBinding IsJumpEnabled,Converter={StaticResource Boolean2VisibilityConverter}}" Content="{ex:Lang {x:Static lang:LangKeys.Jump}}" Margin="6,0,0,0" Command="interactivity:ControlCommands.Jump"/>
</StackPanel> </StackPanel>
</ControlTemplate> </ControlTemplate>
</Setter.Value> </Setter.Value>