Synchronize the Net40
This commit is contained in:
1 parent
5f299e988e
commit
a5a20d51ae
23 files changed
+394
-226
No files matched your search
@@ -350,6 +350,13 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (ItemsHost == null) return;
|
||||
|
||||
if (e.Action == NotifyCollectionChangedAction.Reset)
|
||||
{
|
||||
ClearItems();
|
||||
ItemsHost?.Children.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.OldItems != null)
|
||||
{
|
||||
foreach (var item in e.OldItems)
|
||||
|
||||
@@ -337,7 +337,7 @@
|
||||
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
|
||||
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
|
||||
<Compile Include="ViewModel\DemoViewModelBase.cs" />
|
||||
<Compile Include="ViewModel\DemoViewModelBase!1.cs" />
|
||||
<Compile Include="ViewModel\Main\ContributorsViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\GrowlDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\ImageBrowserDemoViewModel.cs" />
|
||||
|
||||
@@ -6,21 +6,19 @@
|
||||
DataContext="{Binding CoverView,Source={StaticResource Locator}}"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<controls:TransitioningContentControl>
|
||||
<StackPanel>
|
||||
<controls:CoverView Margin="27" Width="880" Height="432" ItemWidth="160" ItemHeight="160" ItemsSource="{Binding DataList}">
|
||||
<controls:CoverView.ItemHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<Image Source="{Binding ImgPath}"/>
|
||||
</DataTemplate>
|
||||
</controls:CoverView.ItemHeaderTemplate>
|
||||
<controls:CoverView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Margin="10" Height="300" Background="{Binding BackgroundToken,Converter={StaticResource String2BrushConverter}}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</controls:CoverView.ItemTemplate>
|
||||
</controls:CoverView>
|
||||
</StackPanel>
|
||||
<controls:CoverView Margin="27" Width="880" Height="432" ItemWidth="160" ItemHeight="160" ItemsSource="{Binding DataList}">
|
||||
<controls:CoverView.ItemHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<Image Source="{Binding ImgPath}"/>
|
||||
</DataTemplate>
|
||||
</controls:CoverView.ItemHeaderTemplate>
|
||||
<controls:CoverView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Margin="10" Height="300" Background="{Binding BackgroundToken,Converter={StaticResource String2BrushConverter}}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</controls:CoverView.ItemTemplate>
|
||||
</controls:CoverView>
|
||||
</controls:TransitioningContentControl>
|
||||
</UserControl>
|
||||
File renamed without changes.
@@ -0,0 +1,9 @@
|
||||
namespace HandyControlDemo.Data
|
||||
{
|
||||
public class CoverViewDemoModel
|
||||
{
|
||||
public string ImgPath { get; set; }
|
||||
|
||||
public string BackgroundToken { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,7 @@
|
||||
</Compile>
|
||||
<Compile Include="Data\Model\ChatInfoModel.cs" />
|
||||
<Compile Include="Data\Model\ContributorModel.cs" />
|
||||
<Compile Include="Data\Model\CoverViewDemoModel.cs" />
|
||||
<Compile Include="Data\Model\DemoDataModel.cs" />
|
||||
<Compile Include="Data\Model\StepBarDemoModel.cs" />
|
||||
<Compile Include="Properties\Langs\Lang.Designer.cs">
|
||||
@@ -97,6 +98,7 @@
|
||||
<DependentUpon>Lang.en.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Service\DataService.cs" />
|
||||
<Compile Include="Tools\Converter\String2BrushConverter.cs" />
|
||||
<Compile Include="Tools\Helper\AssemblyHelper.cs" />
|
||||
<Compile Include="Tools\Helper\CommonHelper.cs" />
|
||||
<Compile Include="Tools\Converter\StringRepeatConverter.cs" />
|
||||
@@ -313,6 +315,8 @@
|
||||
</Compile>
|
||||
<Compile Include="ViewModel\Basic\ChatBoxViewModel.cs" />
|
||||
<Compile Include="ViewModel\Common\ComboBoxDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\CoverViewModel.cs" />
|
||||
<Compile Include="ViewModel\DemoViewModelBase!1.cs" />
|
||||
<Compile Include="ViewModel\Main\ContributorsViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\GrowlDemoViewModel.cs" />
|
||||
<Compile Include="ViewModel\Controls\ImageBrowserDemoViewModel.cs" />
|
||||
|
||||
@@ -3,5 +3,6 @@
|
||||
xmlns:converter="clr-namespace:HandyControlDemo.Tools.Converter">
|
||||
|
||||
<converter:StringRepeatConverter x:Key="StringRepeatConverter"/>
|
||||
<converter:String2BrushConverter x:Key="String2BrushConverter"/>
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using HandyControl.Data;
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.Tools.Converter;
|
||||
using Newtonsoft.Json;
|
||||
@@ -125,5 +127,62 @@ namespace HandyControlDemo.Service
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
internal ObservableCollection<CoverViewDemoModel> GetCoverViewDemoDataList()
|
||||
{
|
||||
return new ObservableCollection<CoverViewDemoModel>
|
||||
{
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/1.jpg",
|
||||
BackgroundToken = ResourceToken.SuccessBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/2.jpg",
|
||||
BackgroundToken = ResourceToken.PrimaryBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/3.jpg",
|
||||
BackgroundToken = ResourceToken.WarningBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/4.jpg",
|
||||
BackgroundToken = ResourceToken.DangerBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/5.jpg",
|
||||
BackgroundToken = ResourceToken.SuccessBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/6.jpg",
|
||||
BackgroundToken = ResourceToken.PrimaryBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/7.jpg",
|
||||
BackgroundToken = ResourceToken.InfoBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/8.jpg",
|
||||
BackgroundToken = ResourceToken.WarningBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/9.jpg",
|
||||
BackgroundToken = ResourceToken.PrimaryBrush
|
||||
},
|
||||
new CoverViewDemoModel
|
||||
{
|
||||
ImgPath = "/HandyControlDemo;component/Resources/Img/Album/10.jpg",
|
||||
BackgroundToken = ResourceToken.DangerBrush
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Tools;
|
||||
|
||||
namespace HandyControlDemo.Tools.Converter
|
||||
{
|
||||
public class String2BrushConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return value is string str ? ResourceHelper.GetResource<Brush>(str) : default(Brush);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,89 +3,22 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
|
||||
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
|
||||
DataContext="{Binding CoverView,Source={StaticResource Locator}}"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<controls:TransitioningContentControl>
|
||||
<controls:CoverView Margin="27" Width="880" Height="432" ItemWidth="160" ItemHeight="160">
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/1.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource SuccessBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/2.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource PrimaryBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/3.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource WarningBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/4.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource DangerBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/5.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource SuccessBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/6.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource PrimaryBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/7.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource InfoBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/8.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource WarningBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/9.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource PrimaryBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverViewItem>
|
||||
<controls:CoverViewItem.Header>
|
||||
<Image Source="/HandyControlDemo;component/Resources/Img/Album/10.jpg"/>
|
||||
</controls:CoverViewItem.Header>
|
||||
<Border Margin="10" Height="300" Background="{DynamicResource DangerBrush}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</controls:CoverViewItem>
|
||||
<controls:CoverView Margin="27" Width="880" Height="432" ItemWidth="160" ItemHeight="160" ItemsSource="{Binding DataList}">
|
||||
<controls:CoverView.ItemHeaderTemplate>
|
||||
<DataTemplate>
|
||||
<Image Source="{Binding ImgPath}"/>
|
||||
</DataTemplate>
|
||||
</controls:CoverView.ItemHeaderTemplate>
|
||||
<controls:CoverView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Margin="10" Height="300" Background="{Binding BackgroundToken,Converter={StaticResource String2BrushConverter}}">
|
||||
<TextBlock Text="{x:Static langs:Lang.ContentDemoStr}" VerticalAlignment="Center" HorizontalAlignment="Center" Foreground="White"/>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
</controls:CoverView.ItemTemplate>
|
||||
</controls:CoverView>
|
||||
</controls:TransitioningContentControl>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -1,25 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using GalaSoft.MvvmLight;
|
||||
using HandyControlDemo.Service;
|
||||
using HandyControlDemo.Service;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class ComboBoxDemoViewModel : ViewModelBase
|
||||
public class ComboBoxDemoViewModel : DemoViewModelBase<string>
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
private List<string> _dataList;
|
||||
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
public List<string> DataList
|
||||
{
|
||||
get => _dataList;
|
||||
set => Set(nameof(DataList), ref _dataList, value);
|
||||
}
|
||||
|
||||
public ComboBoxDemoViewModel(DataService dataService) => DataList = dataService.GetComboBoxDemoDataList();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.Service;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class CoverViewModel : DemoViewModelBase<CoverViewDemoModel>
|
||||
{
|
||||
public CoverViewModel(DataService dataService) => DataList = dataService.GetCoverViewDemoDataList();
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using HandyControl.Data;
|
||||
using HandyControlDemo.Data;
|
||||
@@ -8,27 +7,13 @@ using HandyControlDemo.Service;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class PaginationDemoViewModel : ViewModelBase
|
||||
public class PaginationDemoViewModel : DemoViewModelBase<DemoDataModel>
|
||||
{
|
||||
/// <summary>
|
||||
/// 所有数据
|
||||
/// </summary>
|
||||
private readonly List<DemoDataModel> _totalDataList;
|
||||
|
||||
/// <summary>
|
||||
/// 显示的数据
|
||||
/// </summary>
|
||||
private List<DemoDataModel> _dataList;
|
||||
|
||||
/// <summary>
|
||||
/// 显示的数据
|
||||
/// </summary>
|
||||
public List<DemoDataModel> DataList
|
||||
{
|
||||
get => _dataList;
|
||||
set => Set(nameof(DataList), ref _dataList, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 页码
|
||||
/// </summary>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq;
|
||||
using System.Windows.Controls;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using HandyControl.Controls;
|
||||
using HandyControlDemo.Data;
|
||||
@@ -9,26 +7,9 @@ using HandyControlDemo.Service;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class StepBarDemoViewModel : ViewModelBase
|
||||
public class StepBarDemoViewModel : DemoViewModelBase<StepBarDemoModel>
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
private List<StepBarDemoModel> _dataList;
|
||||
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
public List<StepBarDemoModel> DataList
|
||||
{
|
||||
get => _dataList;
|
||||
set => Set(nameof(DataList), ref _dataList, value);
|
||||
}
|
||||
|
||||
public StepBarDemoViewModel(DataService dataService)
|
||||
{
|
||||
DataList = dataService.GetStepBarDemoDataList();
|
||||
}
|
||||
public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList();
|
||||
|
||||
private RelayCommand<Panel> _nextCmd;
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using GalaSoft.MvvmLight;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class DemoViewModelBase<T> : ViewModelBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
private IList<T> _dataList;
|
||||
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
public IList<T> DataList
|
||||
{
|
||||
get => _dataList;
|
||||
set => Set(nameof(DataList), ref _dataList, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using GalaSoft.MvvmLight;
|
||||
using System.Threading;
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.Service;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class ContributorsViewModel : ViewModelBase
|
||||
public class ContributorsViewModel : DemoViewModelBase<ContributorModel>
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
private List<ContributorModel> _dataList;
|
||||
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
public List<ContributorModel> DataList
|
||||
{
|
||||
get => _dataList;
|
||||
set => Set(nameof(DataList), ref _dataList, value);
|
||||
}
|
||||
|
||||
public ContributorsViewModel(DataService dataService)
|
||||
{
|
||||
ThreadPool.QueueUserWorkItem(state =>
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using HandyControlDemo.Data;
|
||||
@@ -10,7 +8,7 @@ using HandyControlDemo.Tools;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class MainViewModel : ViewModelBase
|
||||
public class MainViewModel : DemoViewModelBase<DemoDataModel>
|
||||
{
|
||||
#region 字段
|
||||
|
||||
@@ -24,11 +22,6 @@ namespace HandyControlDemo.ViewModel
|
||||
/// </summary>
|
||||
private object _subContent;
|
||||
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
private List<DemoDataModel> _dataList;
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的列表项
|
||||
/// </summary>
|
||||
@@ -57,15 +50,6 @@ namespace HandyControlDemo.ViewModel
|
||||
|
||||
#region 属性
|
||||
|
||||
/// <summary>
|
||||
/// 数据列表
|
||||
/// </summary>
|
||||
public List<DemoDataModel> DataList
|
||||
{
|
||||
get => _dataList;
|
||||
set => Set(nameof(DataList), ref _dataList, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 子内容
|
||||
/// </summary>
|
||||
|
||||
@@ -23,6 +23,7 @@ namespace HandyControlDemo.ViewModel
|
||||
SimpleIoc.Default.Register<StepBarDemoViewModel>();
|
||||
SimpleIoc.Default.Register<PaginationDemoViewModel>();
|
||||
SimpleIoc.Default.Register<ChatBoxViewModel>();
|
||||
SimpleIoc.Default.Register<CoverViewModel>();
|
||||
}
|
||||
|
||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||
@@ -48,6 +49,8 @@ namespace HandyControlDemo.ViewModel
|
||||
|
||||
public ChatBoxViewModel ChatBox => new ChatBoxViewModel();
|
||||
|
||||
public CoverViewModel CoverView => ServiceLocator.Current.GetInstance<CoverViewModel>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -12,5 +12,14 @@ namespace HandyControl.Controls
|
||||
get => GetValue(HeaderProperty);
|
||||
set => SetValue(HeaderProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty HeaderTemplateProperty = DependencyProperty.Register(
|
||||
"HeaderTemplate", typeof(DataTemplate), typeof(HeaderedSelectableItem), new PropertyMetadata(default(DataTemplate)));
|
||||
|
||||
public DataTemplate HeaderTemplate
|
||||
{
|
||||
get => (DataTemplate)GetValue(HeaderTemplateProperty);
|
||||
set => SetValue(HeaderTemplateProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools;
|
||||
@@ -11,6 +14,10 @@ namespace HandyControl.Controls
|
||||
|
||||
private CoverViewItem _selectedItem;
|
||||
|
||||
private IEnumerable _itemsSourceInternal;
|
||||
|
||||
private readonly Dictionary<object, CoverViewItem> _entryDic = new Dictionary<object, CoverViewItem>();
|
||||
|
||||
public CoverView()
|
||||
{
|
||||
_viewContent = new CoverViewContent();
|
||||
@@ -31,6 +38,7 @@ namespace HandyControl.Controls
|
||||
if (_viewContent != null)
|
||||
{
|
||||
_viewContent.Content = item.Content;
|
||||
_viewContent.ContentTemplate = ItemTemplate;
|
||||
UpdateCoverViewContent(true);
|
||||
}
|
||||
|
||||
@@ -54,6 +62,7 @@ namespace HandyControl.Controls
|
||||
if (_viewContent != null)
|
||||
{
|
||||
_viewContent.Content = null;
|
||||
_viewContent.ContentTemplate = null;
|
||||
UpdateCoverViewContent(false);
|
||||
}
|
||||
_selectedItem.IsSelected = false;
|
||||
@@ -78,6 +87,14 @@ namespace HandyControl.Controls
|
||||
|
||||
protected override DependencyObject GetContainerForItemOverride() => new CoverViewItem();
|
||||
|
||||
private void SetBindingForItem(FrameworkElement item)
|
||||
{
|
||||
item.SetBinding(MarginProperty, new Binding(ItemMarginProperty.Name) { Source = this });
|
||||
item.SetBinding(WidthProperty, new Binding(ItemWidthProperty.Name) { Source = this });
|
||||
item.SetBinding(HeightProperty, new Binding(ItemHeightProperty.Name) { Source = this });
|
||||
item.SetBinding(HeaderedSelectableItem.HeaderTemplateProperty, new Binding(ItemHeaderTemplateProperty.Name) { Source = this });
|
||||
}
|
||||
|
||||
protected override bool IsItemItsOwnContainerOverride(object item) => item is CoverViewItem;
|
||||
|
||||
public static readonly DependencyProperty CoverViewContentStyleProperty = DependencyProperty.Register(
|
||||
@@ -133,6 +150,15 @@ namespace HandyControl.Controls
|
||||
set => SetValue(ItemContentHeightFixedProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ItemHeaderTemplateProperty = DependencyProperty.Register(
|
||||
"ItemHeaderTemplate", typeof(DataTemplate), typeof(CoverView), new PropertyMetadata(default(DataTemplate)));
|
||||
|
||||
public DataTemplate ItemHeaderTemplate
|
||||
{
|
||||
get => (DataTemplate)GetValue(ItemHeaderTemplateProperty);
|
||||
set => SetValue(ItemHeaderTemplateProperty, value);
|
||||
}
|
||||
|
||||
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
|
||||
{
|
||||
base.OnRenderSizeChanged(sizeInfo);
|
||||
@@ -144,28 +170,16 @@ namespace HandyControl.Controls
|
||||
{
|
||||
if (ItemsHost == null) return;
|
||||
|
||||
ItemsHost.Children.Clear();
|
||||
var index = 0;
|
||||
_entryDic.Clear();
|
||||
|
||||
foreach (var item in Items)
|
||||
{
|
||||
DependencyObject container;
|
||||
if (IsItemItsOwnContainerOverride(item))
|
||||
{
|
||||
container = item as DependencyObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
container = GetContainerForItemOverride();
|
||||
PrepareContainerForItemOverride(container, item);
|
||||
}
|
||||
|
||||
if (container is CoverViewItem element)
|
||||
{
|
||||
element.Index = index++;
|
||||
element.Style = ItemContainerStyle;
|
||||
ItemsHost.Children.Add(element);
|
||||
}
|
||||
AddItem(item);
|
||||
}
|
||||
|
||||
GenerateIndex();
|
||||
|
||||
UpdateCoverViewContent(_viewContent.IsOpen);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -188,6 +202,18 @@ namespace HandyControl.Controls
|
||||
}
|
||||
}
|
||||
|
||||
UpdateCoverViewContentPosition();
|
||||
if (_viewContent.CanSwitch)
|
||||
{
|
||||
_viewContent.IsOpen = isOpen;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新内容视图位置
|
||||
/// </summary>
|
||||
private void UpdateCoverViewContentPosition()
|
||||
{
|
||||
var total = Items.Count + 1;
|
||||
var totalRow = total / Groups + (total % Groups > 0 ? 1 : 0);
|
||||
if (total <= Groups)
|
||||
@@ -208,10 +234,170 @@ namespace HandyControl.Controls
|
||||
}
|
||||
|
||||
_viewContent.UpdatePosition(_selectedItem.Index, Groups, _selectedItem.DesiredSize.Width);
|
||||
if (_viewContent.CanSwitch)
|
||||
}
|
||||
|
||||
protected override void OnItemsSourceChanged(IEnumerable oldValue, IEnumerable newValue)
|
||||
{
|
||||
if (_itemsSourceInternal != null)
|
||||
{
|
||||
_viewContent.IsOpen = isOpen;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
if (ItemsHost != null)
|
||||
{
|
||||
GenerateIndex();
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearItems()
|
||||
{
|
||||
_selectedItem = null;
|
||||
if (_viewContent != null)
|
||||
{
|
||||
ItemsHost?.Children.Remove(_viewContent);
|
||||
}
|
||||
|
||||
_entryDic.Clear();
|
||||
}
|
||||
|
||||
private void RemoveItem(object item)
|
||||
{
|
||||
if (_entryDic.TryGetValue(item, out var entry))
|
||||
{
|
||||
if (ReferenceEquals(entry, _selectedItem))
|
||||
{
|
||||
_selectedItem = null;
|
||||
if (_viewContent != null)
|
||||
{
|
||||
_viewContent.Content = null;
|
||||
_viewContent.IsOpen = false;
|
||||
ItemsHost.Children.Remove(_viewContent);
|
||||
}
|
||||
}
|
||||
|
||||
ItemsHost.Children.Remove(entry);
|
||||
Items.Remove(item);
|
||||
_entryDic.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddItem(object item) => InsertItem(_entryDic.Count, item);
|
||||
|
||||
private void InsertItem(int index, object item)
|
||||
{
|
||||
if (ItemsHost == null)
|
||||
{
|
||||
Items.Insert(index, item);
|
||||
_entryDic.Add(item, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
DependencyObject container;
|
||||
if (IsItemItsOwnContainerOverride(item))
|
||||
{
|
||||
container = item as DependencyObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
container = GetContainerForItemOverride();
|
||||
PrepareContainerForItemOverride(container, item);
|
||||
}
|
||||
|
||||
if (container is CoverViewItem element)
|
||||
{
|
||||
SetBindingForItem(element);
|
||||
element.Style = ItemContainerStyle;
|
||||
if (element.Header == null)
|
||||
{
|
||||
element.Header = item;
|
||||
}
|
||||
_entryDic[item] = element;
|
||||
ItemsHost.Children.Insert(index, element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成序号
|
||||
/// </summary>
|
||||
private void GenerateIndex()
|
||||
{
|
||||
var index = 0;
|
||||
foreach (var item in Items)
|
||||
{
|
||||
_entryDic[item].Index = index++;
|
||||
}
|
||||
}
|
||||
|
||||
private void InternalCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (ItemsHost == null) return;
|
||||
|
||||
if (e.OldItems != null)
|
||||
{
|
||||
foreach (var item in e.OldItems)
|
||||
{
|
||||
RemoveItem(item);
|
||||
}
|
||||
}
|
||||
if (e.NewItems != null)
|
||||
{
|
||||
if (_viewContent.IsOpen)
|
||||
{
|
||||
ItemsHost.Children.Remove(_viewContent);
|
||||
}
|
||||
|
||||
var count = 0;
|
||||
foreach (var item in e.NewItems)
|
||||
{
|
||||
var index = e.NewStartingIndex + count++;
|
||||
InsertItem(index, item);
|
||||
if (_itemsSourceInternal != null)
|
||||
{
|
||||
Items.Insert(index, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GenerateIndex();
|
||||
if (_viewContent.IsOpen)
|
||||
{
|
||||
UpdateCoverViewContentPosition();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnItemsChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (_itemsSourceInternal != null) return;
|
||||
|
||||
InternalCollectionChanged(sender, e);
|
||||
}
|
||||
|
||||
protected override void OnItemTemplateChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnItemContainerStyleChanged(DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@
|
||||
<ColumnDefinition Width="12" Name="Definition1"/>
|
||||
<ColumnDefinition Name="Definition2"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Ellipse Name="Dot" VerticalAlignment="Top" Fill="{DynamicResource DangerBrush}" Width="6" Height="6" Visibility="{TemplateBinding IsRead,Converter={StaticResource Boolean2BooleanReConverter}}" Margin="0,0,6,0"/>
|
||||
<Ellipse Name="Dot" VerticalAlignment="Top" Fill="{DynamicResource DangerBrush}" Width="6" Height="6" Visibility="{TemplateBinding IsRead,Converter={StaticResource Boolean2VisibilityReConverter}}" Margin="0,0,6,0"/>
|
||||
<Path Name="Tail" Grid.Column="1" Data="{StaticResource BubbleTailGeometry}" Fill="{TemplateBinding Background}" HorizontalAlignment="Right" Stretch="Uniform" VerticalAlignment="Bottom" Width="15" Height="15" RenderTransformOrigin="0.5,0.5"/>
|
||||
<Border Name="Body" Grid.Column="1" Background="{TemplateBinding Background}" CornerRadius="15" Margin="0,0,3,0">
|
||||
<Grid VerticalAlignment="Center" Margin="{TemplateBinding Padding}">
|
||||
|
||||
@@ -3,14 +3,11 @@
|
||||
xmlns:controls="clr-namespace:HandyControl.Controls">
|
||||
|
||||
<Style x:Key="CoverViewItemBaseStyle" TargetType="controls:CoverViewItem">
|
||||
<Setter Property="Margin" Value="{Binding ItemMargin,RelativeSource={RelativeSource AncestorType=controls:CoverView}}"/>
|
||||
<Setter Property="Width" Value="{Binding ItemWidth,RelativeSource={RelativeSource AncestorType=controls:CoverView}}"/>
|
||||
<Setter Property="Height" Value="{Binding ItemHeight,RelativeSource={RelativeSource AncestorType=controls:CoverView}}"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="controls:CoverViewItem">
|
||||
<Border BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}">
|
||||
<ContentPresenter ContentSource="Header" Margin="{TemplateBinding Padding}"/>
|
||||
<ContentPresenter ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" Margin="{TemplateBinding Padding}"/>
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
|
||||
@@ -265,15 +265,6 @@
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<!--<Style.Triggers>
|
||||
<MultiTrigger>
|
||||
<MultiTrigger.Conditions>
|
||||
<Condition Property="IsGrouping" Value="true"/>
|
||||
<Condition Property="VirtualizingPanel.IsVirtualizingWhenGrouping" Value="false"/>
|
||||
</MultiTrigger.Conditions>
|
||||
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
|
||||
</MultiTrigger>
|
||||
</Style.Triggers>-->
|
||||
</Style>
|
||||
|
||||
</ResourceDictionary>
|
||||
Reference in new issue
Block a user