add Transfer

This commit is contained in:
NaBian committed 2019-01-28 00:31:06 +08:00
1 parent 43d1e7e4f4
commit 56aae57ccd
24 files changed
+617 -26

No files matched your search

+54 -1
View File
@@ -29,7 +29,32 @@ namespace HandyControl.Controls
if (_isMouseLeftButtonDown)
{
RaiseEvent(new RoutedEventArgs(SelectedEvent, this));
if (SelfManage)
{
if (!IsSelected)
{
IsSelected = true;
RaiseEvent(new RoutedEventArgs(SelectedEvent, this));
}
else if (CanDeselect)
{
IsSelected = false;
RaiseEvent(new RoutedEventArgs(DeselectedEvent, this));
}
}
else
{
if (CanDeselect)
{
RaiseEvent(IsSelected
? new RoutedEventArgs(DeselectedEvent, this)
: new RoutedEventArgs(SelectedEvent, this));
}
else
{
RaiseEvent(new RoutedEventArgs(SelectedEvent, this));
}
}
_isMouseLeftButtonDown = false;
}
}
@@ -43,6 +68,24 @@ namespace HandyControl.Controls
set => SetValue(IsSelectedProperty, value);
}
public static readonly DependencyProperty SelfManageProperty = DependencyProperty.Register(
"SelfManage", typeof(bool), typeof(SelectableItem), new PropertyMetadata(ValueBoxes.FalseBox));
public bool SelfManage
{
get => (bool) GetValue(SelfManageProperty);
set => SetValue(SelfManageProperty, value);
}
public static readonly DependencyProperty CanDeselectProperty = DependencyProperty.Register(
"CanDeselect", typeof(bool), typeof(SelectableItem), new PropertyMetadata(ValueBoxes.FalseBox));
public bool CanDeselect
{
get => (bool) GetValue(CanDeselectProperty);
set => SetValue(CanDeselectProperty, value);
}
public static readonly RoutedEvent SelectedEvent =
EventManager.RegisterRoutedEvent("Selected", RoutingStrategy.Bubble,
typeof(RoutedEventHandler), typeof(SelectableItem));
@@ -52,5 +95,15 @@ namespace HandyControl.Controls
add => AddHandler(SelectedEvent, value);
remove => RemoveHandler(SelectedEvent, value);
}
public static readonly RoutedEvent DeselectedEvent =
EventManager.RegisterRoutedEvent("Deselected", RoutingStrategy.Bubble,
typeof(RoutedEventHandler), typeof(SelectableItem));
public event RoutedEventHandler Deselected
{
add => AddHandler(DeselectedEvent, value);
remove => RemoveHandler(DeselectedEvent, value);
}
}
}
@@ -1,4 +1,5 @@
using System.Collections.ObjectModel;
using System.Collections;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Windows;
@@ -25,13 +26,23 @@ namespace HandyControl.Controls
"ItemContainerStyle", typeof(Style), typeof(SimpleItemsControl),
new PropertyMetadata(default(Style), OnItemContainerStyleChanged));
public static readonly DependencyProperty ItemsSourceProperty = DependencyProperty.Register(
"ItemsSource", typeof(IEnumerable), typeof(SimpleItemsControl),
new PropertyMetadata(default(IEnumerable), OnItemsSourceChanged));
public SimpleItemsControl()
{
var items = new ObservableCollection<object>();
items.CollectionChanged += OnItemsCollectionChanged;
items.CollectionChanged += OnItemsChanged;
Items = items;
}
public IEnumerable ItemsSource
{
get => (IEnumerable) GetValue(ItemsSourceProperty);
set => SetValue(ItemsSourceProperty, value);
}
[Bindable(true)]
[Category("Content")]
public Style ItemContainerStyle
@@ -53,6 +64,15 @@ namespace HandyControl.Controls
internal Panel ItemsHost { get; set; }
private static void OnItemsSourceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((SimpleItemsControl) d).OnItemsSourceChanged((IEnumerable) e.OldValue, (IEnumerable) e.NewValue);
}
protected virtual void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue)
{
}
public override void OnApplyTemplate()
{
ItemsHost?.Children.Clear();
@@ -63,7 +83,7 @@ namespace HandyControl.Controls
Refresh();
}
private void OnItemsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
protected virtual void OnItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
Refresh();
UpdateItems();
@@ -88,17 +108,15 @@ namespace HandyControl.Controls
}
}
private static void OnItemTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var target = d as SimpleItemsControl;
target?.Refresh();
}
private static void OnItemTemplateChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
=> (d as SimpleItemsControl)?.OnItemTemplateChanged(e);
protected virtual void OnItemTemplateChanged(DependencyPropertyChangedEventArgs e) => Refresh();
private static void OnItemContainerStyleChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var target = d as SimpleItemsControl;
target?.Refresh();
}
=> (d as SimpleItemsControl)?.OnItemContainerStyleChanged(e);
protected virtual void OnItemContainerStyleChanged(DependencyPropertyChangedEventArgs e) => Refresh();
protected virtual void Refresh()
{
@@ -128,7 +146,6 @@ namespace HandyControl.Controls
protected virtual void UpdateItems()
{
}
}
}
+223
View File
@@ -0,0 +1,223 @@
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using HandyControl.Interactivity;
using HandyControl.Tools.Extension;
namespace HandyControl.Controls
{
/// <summary>
/// 穿梭框
/// </summary>
[TemplatePart(Name = ElementItemsOrigin, Type = typeof(SimpleItemsControl))]
[TemplatePart(Name = ElementItemsSelected, Type = typeof(SimpleItemsControl))]
public class Transfer : SimpleItemsControl
{
private const string ElementItemsOrigin = "PART_ItemsOrigin";
private const string ElementItemsSelected = "PART_ItemsSelected";
private readonly Dictionary<object, TransferEntry> _entryDic = new Dictionary<object, TransferEntry>();
private SimpleItemsControl _itemsOrigin;
private SimpleItemsControl _itemsSelected;
private IEnumerable _itemsSourceInternal;
public static readonly RoutedEvent SelectionChangedEvent =
EventManager.RegisterRoutedEvent("SelectionChanged", RoutingStrategy.Bubble,
typeof(SelectionChangedEventHandler), typeof(Transfer));
public event SelectionChangedEventHandler SelectionChanged
{
add => AddHandler(SelectionChangedEvent, value);
remove => RemoveHandler(SelectionChangedEvent, value);
}
private static readonly DependencyPropertyKey SelectedItemsPropertyKey =
DependencyProperty.RegisterReadOnly(
"SelectedItems",
typeof(IList),
typeof(Transfer),
new FrameworkPropertyMetadata(default(IList)));
public static readonly DependencyProperty SelectedItemsProperty = SelectedItemsPropertyKey.DependencyProperty;
public IList SelectedItems
{
get => (IList) GetValue(SelectedItemsProperty);
set => SetValue(SelectedItemsProperty, value);
}
public Transfer()
{
CommandBindings.Add(new CommandBinding(ControlCommands.Selected, SelectItems));
CommandBindings.Add(new CommandBinding(ControlCommands.Cancel, DeselectItems));
SetValue(SelectedItemsPropertyKey, new ObservableCollection<object>());
}
public override void OnApplyTemplate()
{
_itemsOrigin?.ItemsHost.Children.Clear();
_itemsSelected?.ItemsHost.Children.Clear();
_itemsOrigin = GetTemplateChild(ElementItemsOrigin) as SimpleItemsControl;
_itemsSelected = GetTemplateChild(ElementItemsSelected) as SimpleItemsControl;
Refresh();
}
private void AddItem(object item)
{
var origin = new TransferItem
{
Content = item
};
var selected = new TransferItem
{
Content = item,
IsOrigin = false
};
var entry = new TransferEntry
{
OriginItem = origin,
SelectedItem = selected
};
_entryDic.Add(item, entry);
_itemsOrigin.Items.Add(origin);
_itemsSelected.Items.Add(selected);
}
private void RemoveItem(object item)
{
if (_entryDic.TryGetValue(item, out var entry))
{
_itemsOrigin.Items.Remove(entry.OriginItem);
_itemsSelected.Items.Remove(entry.SelectedItem);
_entryDic.Remove(item);
}
}
private void ClearItems()
{
_entryDic.Clear();
_itemsOrigin.Items.Clear();
_itemsSelected.Items.Clear();
}
protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue)
{
if (_itemsSourceInternal != null)
{
if (_itemsSourceInternal is INotifyCollectionChanged s)
{
s.CollectionChanged -= InternalCollectionChanged;
}
ClearItems();
}
_itemsSourceInternal = newValue;
if (_itemsSourceInternal != null)
{
if (_itemsSourceInternal is INotifyCollectionChanged s)
{
s.CollectionChanged += InternalCollectionChanged;
}
foreach (var item in _itemsSourceInternal)
{
AddItem(item);
}
}
}
private void InternalCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.OldItems != null)
{
foreach (var item in e.OldItems)
{
RemoveItem(item);
}
}
if (e.NewItems != null)
{
foreach (var item in e.NewItems)
{
AddItem(item);
}
}
}
protected override DependencyObject GetContainerForItemOverride() => new TransferItem();
protected override bool IsItemItsOwnContainerOverride(object item) => item is TransferItem;
private void SelectItems(object sender, ExecutedRoutedEventArgs e)
{
var list = _entryDic.Where(item => item.Value.OriginItem.IsSelected).ToList();
list.Do(item => item.Value.StatusSwitch(true)).Do(item => SelectedItems.Add(item.Key));
RaiseEvent(new SelectionChangedEventArgs(SelectionChangedEvent, new List<object>(), list));
}
private void DeselectItems(object sender, ExecutedRoutedEventArgs e)
{
var list = _entryDic.Where(item => item.Value.SelectedItem.IsSelected).ToList();
list.Do(item => item.Value.StatusSwitch(false)).Do(item => SelectedItems.Remove(item.Key));
RaiseEvent(new SelectionChangedEventArgs(SelectionChangedEvent, list, new List<object>()));
}
protected override void OnItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
}
protected override void OnItemTemplateChanged(DependencyPropertyChangedEventArgs e)
{
}
protected override void OnItemContainerStyleChanged(DependencyPropertyChangedEventArgs e)
{
}
protected override void Refresh()
{
if (_entryDic.Count > 0)
{
_entryDic.Select(item => item.Value.OriginItem).Do(item => _itemsOrigin.Items.Add(item));
_entryDic.Select(item => item.Value.SelectedItem).Do(item => _itemsSelected.Items.Add(item));
}
}
private struct TransferEntry
{
public TransferItem OriginItem { get; set; }
public TransferItem SelectedItem { get; set; }
public void StatusSwitch(bool isTransferred)
{
if (isTransferred)
{
OriginItem.IsTransferred = true;
SelectedItem.IsTransferred = true;
OriginItem.IsSelected = false;
}
else
{
OriginItem.IsTransferred = false;
SelectedItem.IsTransferred = false;
SelectedItem.IsSelected = false;
}
}
}
}
}
@@ -0,0 +1,54 @@
using System.Collections.Specialized;
using System.Windows;
namespace HandyControl.Controls
{
public class TransferGroup : SimpleItemsControl
{
protected override void Refresh()
{
if (Items.Count > 0)
{
foreach (FrameworkElement item in Items)
{
item.Style = ItemContainerStyle;
ItemsHost.Children.Add(item);
}
}
}
protected override void OnItemTemplateChanged(DependencyPropertyChangedEventArgs e)
{
}
protected override void OnItemContainerStyleChanged(DependencyPropertyChangedEventArgs e)
{
}
protected override DependencyObject GetContainerForItemOverride() => new TransferItem();
protected override bool IsItemItsOwnContainerOverride(object item) => item is TransferItem;
protected override void OnItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (ItemsHost == null) return;
if (e.OldItems != null)
{
foreach (FrameworkElement item in e.OldItems)
{
ItemsHost.Children.Remove(item);
}
}
if (e.NewItems != null)
{
foreach (FrameworkElement item in e.NewItems)
{
item.Style = ItemContainerStyle;
ItemsHost.Children.Add(item);
}
}
}
}
}
@@ -0,0 +1,26 @@
using System.Windows;
using HandyControl.Data;
namespace HandyControl.Controls
{
public class TransferItem : SelectableItem
{
public static readonly DependencyProperty IsTransferredProperty = DependencyProperty.Register(
"IsTransferred", typeof(bool), typeof(TransferItem), new PropertyMetadata(ValueBoxes.FalseBox));
public bool IsTransferred
{
get => (bool) GetValue(IsTransferredProperty);
set => SetValue(IsTransferredProperty, value);
}
public static readonly DependencyProperty IsOriginProperty = DependencyProperty.Register(
"IsOrigin", typeof(bool), typeof(TransferItem), new PropertyMetadata(ValueBoxes.TrueBox));
public bool IsOrigin
{
get => (bool) GetValue(IsOriginProperty);
internal set => SetValue(IsOriginProperty, value);
}
}
}
+12
View File
@@ -110,6 +110,9 @@
<Compile Include="Controls\Button\ContextMenuToggleButton.cs" />
<Compile Include="Controls\Other\Carousel.cs" />
<Compile Include="Controls\Cover\CoverView\CoverView.cs" />
<Compile Include="Controls\Transfer\Transfer.cs" />
<Compile Include="Controls\Transfer\TransferGroup.cs" />
<Compile Include="Controls\Transfer\TransferItem.cs" />
<Compile Include="Controls\Panel\CirclePanel.cs" />
<Compile Include="Controls\Other\CircleProgressBar.cs" />
<Compile Include="Controls\Other\RadioGroup.cs" />
@@ -167,6 +170,7 @@
<Compile Include="Data\SystemVersionInfo.cs" />
<Compile Include="Tools\Converter\Boolean2StrConverter.cs" />
<Compile Include="Tools\Converter\Int2StrConverter.cs" />
<Compile Include="Tools\Extension\EnumerableExtension.cs" />
<Compile Include="Tools\Helper\ColorHelper.cs" />
<Compile Include="Tools\GifImageAnimator.cs" />
<Compile Include="Data\GrowlInfo.cs" />
@@ -396,6 +400,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\TransferBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Base\TreeViewBaseStyle.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -700,6 +708,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\Transfer.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\Styles\TransitioningContentControl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -0,0 +1,115 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls"
xmlns:interactivity="clr-namespace:HandyControl.Interactivity">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="../../Basic/Geometries.xaml"/>
<ResourceDictionary Source="../../Basic/Behaviors.xaml"/>
<ResourceDictionary Source="../../Basic/Sizes.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="TransferItemBaseStyle" TargetType="controls:TransferItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="CanDeselect" Value="True"/>
<Setter Property="SelfManage" Value="True"/>
<Setter Property="Padding" Value="10"/>
<Setter Property="MinHeight" Value="{StaticResource DefaultControlHeight}"/>
<Setter Property="Margin" Value="5,0,5,5"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:TransferItem">
<Border x:Name="BorderRoot" Background="{DynamicResource RegionBrush}" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}">
<ContentPresenter x:Name="ContentPresenter" Margin="{TemplateBinding Padding}" ContentTemplate="{Binding ItemTemplate,RelativeSource={RelativeSource AncestorType=controls:TransferGroup}}"/>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="BorderRoot" Property="Background" Value="{DynamicResource PrimaryBrush}"/>
<Setter TargetName="ContentPresenter" Property="TextElement.Foreground" Value="{DynamicResource TextIconBrush}"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsOrigin" Value="True"/>
<Condition Property="IsTransferred" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" Value="Visible"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsOrigin" Value="True"/>
<Condition Property="IsTransferred" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" Value="Collapsed"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsOrigin" Value="False"/>
<Condition Property="IsTransferred" Value="True"/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" Value="Visible"/>
</MultiTrigger>
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsOrigin" Value="False"/>
<Condition Property="IsTransferred" Value="False"/>
</MultiTrigger.Conditions>
<Setter Property="Visibility" Value="Collapsed"/>
</MultiTrigger>
</Style.Triggers>
</Style>
<Style x:Key="TransferGroupBaseStyle" TargetType="controls:TransferGroup">
<Setter Property="BorderThickness" Value="0"/>
<Setter Property="Background" Value="{DynamicResource DarkDefaultBrush}"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:TransferGroup">
<Border Background="{TemplateBinding Background}" CornerRadius="{Binding Path=(controls:BorderElement.CornerRadius),RelativeSource={RelativeSource TemplatedParent}}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<ScrollViewer Margin="0,5">
<StackPanel x:Name="PART_Panel"/>
</ScrollViewer>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="TransferBaseStyle" TargetType="controls:Transfer">
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="controls:BorderElement.CornerRadius" Value="4"/>
<Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/>
<Setter Property="ItemContainerStyle" Value="{StaticResource TransferItemBaseStyle}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="controls:Transfer">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="200"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition MinWidth="200"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<controls:TransferGroup x:Name="PART_ItemsOrigin" Style="{StaticResource TransferGroupBaseStyle}" Grid.RowSpan="4" ItemTemplate="{TemplateBinding ItemTemplate}" ItemContainerStyle="{TemplateBinding ItemContainerStyle}"/>
<StackPanel Margin="32,0" VerticalAlignment="Center" HorizontalAlignment="Center" Grid.Row="0" Grid.RowSpan="4" Grid.Column="1">
<Button controls:IconElement.Geometry="{StaticResource LeftGeometry}" Command="interactivity:ControlCommands.Cancel"/>
<Button controls:IconElement.Geometry="{StaticResource RightGeometry}" Margin="0,10,0,0" Command="interactivity:ControlCommands.Selected"/>
</StackPanel>
<controls:TransferGroup x:Name="PART_ItemsSelected" Style="{StaticResource TransferGroupBaseStyle}" Grid.Row="0" Grid.RowSpan="4" Grid.Column="2" ItemTemplate="{TemplateBinding ItemTemplate}" ItemContainerStyle="{TemplateBinding ItemContainerStyle}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
+1
View File
@@ -55,6 +55,7 @@
<ResourceDictionary Source="CoverView.xaml"/>
<ResourceDictionary Source="CoverFlow.xaml"/>
<ResourceDictionary Source="ProgressButton.xaml"/>
<ResourceDictionary Source="Transfer.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
+10
View File
@@ -0,0 +1,10 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:controls="clr-namespace:HandyControl.Controls">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Base/TransferBaseStyle.xaml"/>
</ResourceDictionary.MergedDictionaries>
<Style BasedOn="{StaticResource TransferBaseStyle}" TargetType="controls:Transfer"/>
</ResourceDictionary>
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace HandyControl.Tools.Extension
{
public static class EnumerableExtension
{
public static IEnumerable<TSource> Do<TSource>(this IEnumerable<TSource> source, Action<TSource> predicate)
{
var enumerable = source as IList<TSource> ?? source.ToList();
foreach (var item in enumerable)
{
predicate.Invoke(item);
}
return enumerable;
}
}
}
+2
View File
@@ -78,6 +78,8 @@
public static readonly string ProgressButtonDemoCtl = nameof(ProgressButtonDemoCtl);
public static readonly string TransferDemoCtl = nameof(TransferDemoCtl);
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
public static readonly string ToggleButtonDemoCtl = nameof(ToggleButtonDemoCtl);
+2 -1
View File
@@ -41,7 +41,8 @@ var controlList = new List<string>
"WaterfallPanelDemoCtl",
"CoverViewDemoCtl",
"CoverFlowDemoCtl",
"ProgressButtonDemoCtl"
"ProgressButtonDemoCtl",
"TransferDemoCtl"
};
var styleList = new List<string>
{
+8
View File
@@ -216,6 +216,9 @@
<Compile Include="UserControl\Controls\TimePickerDemoCtl.xaml.cs">
<DependentUpon>TimePickerDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Controls\TransferDemoCtl.xaml.cs">
<DependentUpon>TransferDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Controls\WaterfallPanelDemoCtl.xaml.cs">
<DependentUpon>WaterfallPanelDemoCtl.xaml</DependentUpon>
</Compile>
@@ -529,6 +532,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Controls\TransferDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Controls\WaterfallPanelDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -711,6 +718,7 @@
<Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MessageToken.cs</LastGenOutput>
</Content>
<Resource Include="Resources\Img\LeftMainContent\Transfer_16x.png" />
<Resource Include="Resources\Img\LeftMainContent\ProgressButton_16x.png" />
<Resource Include="Resources\Img\LeftMainContent\SortAscending_grey_16x.png" />
<Resource Include="Resources\Img\LeftMainContent\LinearCarousel_16x.png" />
+9
View File
@@ -1095,6 +1095,15 @@ namespace HandyControlDemo.Properties.Langs {
}
}
/// <summary>
/// 查找类似 穿梭框 的本地化字符串。
/// </summary>
public static string Transfer {
get {
return ResourceManager.GetString("Transfer", resourceCulture);
}
}
/// <summary>
/// 查找类似 树视图 的本地化字符串。
/// </summary>
@@ -483,4 +483,7 @@
<data name="OpenCustomMessageWindow" xml:space="preserve">
<value>open custom message window</value>
</data>
<data name="Transfer" xml:space="preserve">
<value>Transfer</value>
</data>
</root>
@@ -483,4 +483,7 @@
<data name="OpenCustomMessageWindow" xml:space="preserve">
<value>点击打开自定义消息窗口</value>
</data>
<data name="Transfer" xml:space="preserve">
<value>穿梭框</value>
</data>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

+2 -2
View File
@@ -14,7 +14,7 @@ namespace HandyControlDemo.Service
internal List<DemoDataModel> GetDemoDataList()
{
var list = new List<DemoDataModel>();
for (var i = 1; i <= 6; i++)
for (var i = 1; i <= 20; i++)
{
var dataList = new List<DemoDataModel>();
for (int j = 0; j < 3; j++)
@@ -34,7 +34,7 @@ namespace HandyControlDemo.Service
Name = $"Name{i}",
Type = (DemoType)i,
DataList = dataList,
ImgPath = $"/HandyControlDemo;component/Resources/Img/Avatar/avatar{i}.png",
ImgPath = $"/HandyControlDemo;component/Resources/Img/Avatar/avatar{i % 7}.png",
Remark = new string(i.ToString()[0], 10)
};
list.Add(model);
@@ -0,0 +1,15 @@
<UserControl x:Class="HandyControlDemo.UserControl.TransferDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="{DynamicResource RegionBrush}"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl">
<controls:TransitioningContentControl>
<controls:Transfer ItemsSource="{Binding DataList}" Margin="32" Height="300">
<controls:Transfer.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}"/>
</DataTemplate>
</controls:Transfer.ItemTemplate>
</controls:Transfer>
</controls:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl
{
public partial class TransferDemoCtl
{
public TransferDemoCtl()
{
InitializeComponent();
}
}
}
@@ -33,7 +33,7 @@
<Border CornerRadius="4" Height="30" Width="30" BorderThickness="1" BorderBrush="{DynamicResource PrimaryBrush}"/>
</controls:StatusSwitchElement.CheckedElement>
</ToggleButton>
<ListBox Name="listStyle" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
<ListBox Name="ListBoxStyle" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
<ListBoxItem Tag="{x:Static data:MessageToken.BrushDemoCtl}" Content="{x:Static langs:Lang.Brush}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/Brush_16x.png"/>
@@ -181,7 +181,7 @@
<Border CornerRadius="4" Height="30" Width="30" BorderThickness="1" BorderBrush="{DynamicResource PrimaryBrush}"/>
</controls:StatusSwitchElement.CheckedElement>
</ToggleButton>
<ListBox Name="listControl" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
<ListBox Name="ListBoxControl" 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"/>
@@ -232,6 +232,11 @@
<Image Source="../../Resources/Img/LeftMainContent/DatePicker_16x.png"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.TransferDemoCtl}" Content="{x:Static langs:Lang.Transfer}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/Transfer_16x.png"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Tag="{x:Static data:MessageToken.FlipClockDemoCtl}" Content="{x:Static langs:Lang.FlipClock}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/FlipVertical_16x.png"/>
@@ -242,7 +247,7 @@
<Image Source="../../Resources/Img/LeftMainContent/Star.png"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.ShieldDemoCtl}" Content="{x:Static langs:Lang.Shield}">
<ListBoxItem Tag="{x:Static data:MessageToken.ShieldDemoCtl}" Content="{x:Static langs:Lang.Shield}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/Shield_16x.png"/>
</controls:EdgeElement.LeftContent>
@@ -36,11 +36,11 @@ namespace HandyControlDemo.UserControl
{
if (ButtonStyleAscending.IsChecked == true)
{
listStyle.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Ascending));
ListBoxStyle.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Ascending));
}
else
{
listStyle.Items.SortDescriptions.Clear();
ListBoxStyle.Items.SortDescriptions.Clear();
}
}
@@ -48,11 +48,11 @@ namespace HandyControlDemo.UserControl
{
if (ButtonControlAscending.IsChecked == true)
{
listControl.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Ascending));
ListBoxControl.Items.SortDescriptions.Add(new SortDescription("Content", ListSortDirection.Ascending));
}
else
{
listControl.Items.SortDescriptions.Clear();
ListBoxControl.Items.SortDescriptions.Clear();
}
}
@@ -60,7 +60,7 @@ namespace HandyControlDemo.UserControl
{
if (e.Info == null) return;
foreach (var listBoxItem in listStyle.Items.OfType<ListBoxItem>())
foreach (var listBoxItem in ListBoxStyle.Items.OfType<ListBoxItem>())
{
listBoxItem.Show(listBoxItem.Content.ToString().ToLower().Contains(e.Info.ToLower()));
}
@@ -70,7 +70,7 @@ namespace HandyControlDemo.UserControl
{
if (e.Info == null) return;
foreach (var listBoxItem in listControl.Items.OfType<ListBoxItem>())
foreach (var listBoxItem in ListBoxControl.Items.OfType<ListBoxItem>())
{
listBoxItem.Show(listBoxItem.Content.ToString().ToLower().Contains(e.Info.ToLower()));
}
+4
View File
@@ -10,6 +10,10 @@
## Latest examples
### Transfer
![Transfer](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/Transfer.png)
### ProgressButton
![ProgressButton](https://raw.githubusercontent.com/NaBian/HandyControl/master/Resources/ProgressButton.png)
Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB