Synchronize the Net40

1. synchronize the Net40
2. fixed a bug of coverview
This commit is contained in:
NaBian committed 2019-02-22 16:51:31 +08:00
1 parent 52656563b7
commit 36008d83e2
13 files changed
+112 -15

No files matched your search

@@ -18,6 +18,8 @@ namespace HandyControl.Controls
private readonly Dictionary<object, CoverViewItem> _entryDic = new Dictionary<object, CoverViewItem>(); private readonly Dictionary<object, CoverViewItem> _entryDic = new Dictionary<object, CoverViewItem>();
private bool _isRefresh;
public CoverView() public CoverView()
{ {
_viewContent = new CoverViewContent(); _viewContent = new CoverViewContent();
@@ -171,12 +173,15 @@ namespace HandyControl.Controls
if (ItemsHost == null) return; if (ItemsHost == null) return;
_entryDic.Clear(); _entryDic.Clear();
_isRefresh = true;
foreach (var item in Items) foreach (var item in Items)
{ {
AddItem(item); AddItem(item);
} }
_isRefresh = false;
GenerateIndex(); GenerateIndex();
UpdateCoverViewContent(_viewContent.IsOpen); UpdateCoverViewContent(_viewContent.IsOpen);
@@ -214,6 +219,10 @@ namespace HandyControl.Controls
/// </summary> /// </summary>
private void UpdateCoverViewContentPosition() private void UpdateCoverViewContentPosition()
{ {
if (_viewContent.Parent != null)
{
ItemsHost.Children.Remove(_viewContent);
}
var total = Items.Count + 1; var total = Items.Count + 1;
var totalRow = total / Groups + (total % Groups > 0 ? 1 : 0); var totalRow = total / Groups + (total % Groups > 0 ? 1 : 0);
if (total <= Groups) if (total <= Groups)
@@ -245,6 +254,7 @@ namespace HandyControl.Controls
s.CollectionChanged -= InternalCollectionChanged; s.CollectionChanged -= InternalCollectionChanged;
} }
Items.Clear();
ClearItems(); ClearItems();
} }
_itemsSourceInternal = newValue; _itemsSourceInternal = newValue;
@@ -269,9 +279,13 @@ namespace HandyControl.Controls
private void ClearItems() private void ClearItems()
{ {
_selectedItem = null; _selectedItem = null;
if (_viewContent != null) _viewContent.Content = null;
_viewContent.ContentTemplate = null;
if (ItemsHost != null)
{ {
ItemsHost?.Children.Remove(_viewContent); ItemsHost.Children.Remove(_viewContent);
ItemsHost.Children.Clear();
} }
_entryDic.Clear(); _entryDic.Clear();
@@ -330,6 +344,11 @@ namespace HandyControl.Controls
} }
_entryDic[item] = element; _entryDic[item] = element;
ItemsHost.Children.Insert(index, element); ItemsHost.Children.Insert(index, element);
if (IsLoaded && !_isRefresh && _itemsSourceInternal != null)
{
Items.Insert(index, item);
}
} }
} }
} }
@@ -352,8 +371,9 @@ namespace HandyControl.Controls
if (e.Action == NotifyCollectionChangedAction.Reset) if (e.Action == NotifyCollectionChangedAction.Reset)
{ {
if (_entryDic.Count == 0) return;
ClearItems(); ClearItems();
ItemsHost?.Children.Clear(); Items.Clear();
return; return;
} }
@@ -376,10 +396,6 @@ namespace HandyControl.Controls
{ {
var index = e.NewStartingIndex + count++; var index = e.NewStartingIndex + count++;
InsertItem(index, item); InsertItem(index, item);
if (_itemsSourceInternal != null)
{
Items.Insert(index, item);
}
} }
} }
@@ -134,6 +134,8 @@
public static readonly string ToolBarDemoCtl = nameof(ToolBarDemoCtl); public static readonly string ToolBarDemoCtl = nameof(ToolBarDemoCtl);
public static readonly string LabelDemoCtl = nameof(LabelDemoCtl);
public static readonly string CommonWindow = nameof(CommonWindow); public static readonly string CommonWindow = nameof(CommonWindow);
public static readonly string CustomNonClientAreaWindow = nameof(CustomNonClientAreaWindow); public static readonly string CustomNonClientAreaWindow = nameof(CustomNonClientAreaWindow);
@@ -72,7 +72,8 @@ var styleList = new List<string>
"GroupBoxDemoCtl", "GroupBoxDemoCtl",
"ListViewDemoCtl", "ListViewDemoCtl",
"RichTextBoxDemoCtl", "RichTextBoxDemoCtl",
"ToolBarDemoCtl" "ToolBarDemoCtl",
"LabelDemoCtl"
}; };
var windowList = new List<string> var windowList = new List<string>
{ {
@@ -241,6 +241,9 @@
<Compile Include="UserControl\Styles\GroupBoxDemoCtl.xaml.cs"> <Compile Include="UserControl\Styles\GroupBoxDemoCtl.xaml.cs">
<DependentUpon>GroupBoxDemoCtl.xaml</DependentUpon> <DependentUpon>GroupBoxDemoCtl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="UserControl\Styles\LabelDemoCtl.xaml.cs">
<DependentUpon>LabelDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="UserControl\Styles\ListViewDemoCtl.xaml.cs"> <Compile Include="UserControl\Styles\ListViewDemoCtl.xaml.cs">
<DependentUpon>ListViewDemoCtl.xaml</DependentUpon> <DependentUpon>ListViewDemoCtl.xaml</DependentUpon>
</Compile> </Compile>
@@ -580,6 +583,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="UserControl\Styles\LabelDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UserControl\Styles\ListViewDemoCtl.xaml"> <Page Include="UserControl\Styles\ListViewDemoCtl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -718,6 +725,7 @@
<Generator>TextTemplatingFileGenerator</Generator> <Generator>TextTemplatingFileGenerator</Generator>
<LastGenOutput>MessageToken.cs</LastGenOutput> <LastGenOutput>MessageToken.cs</LastGenOutput>
</Content> </Content>
<Resource Include="Resources\Img\LeftMainContent\Label_16x.png" />
<Resource Include="Resources\Img\Chat\chat_back1.jpg" /> <Resource Include="Resources\Img\Chat\chat_back1.jpg" />
<Resource Include="Resources\Img\Chat\chat_back2.jpg" /> <Resource Include="Resources\Img\Chat\chat_back2.jpg" />
<Resource Include="Resources\Img\LeftMainContent\Bubble_16xLG.png" /> <Resource Include="Resources\Img\LeftMainContent\Bubble_16xLG.png" />
@@ -564,6 +564,15 @@ namespace HandyControlDemo.Properties.Langs {
} }
} }
/// <summary>
/// 查找类似 标签 的本地化字符串。
/// </summary>
public static string Label {
get {
return ResourceManager.GetString("Label", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 列表框 的本地化字符串。 /// 查找类似 列表框 的本地化字符串。
/// </summary> /// </summary>
@@ -495,4 +495,7 @@
<data name="Second" xml:space="preserve"> <data name="Second" xml:space="preserve">
<value>Sec</value> <value>Sec</value>
</data> </data>
<data name="Label" xml:space="preserve">
<value>Label</value>
</data>
</root> </root>
@@ -495,4 +495,7 @@
<data name="Second" xml:space="preserve"> <data name="Second" xml:space="preserve">
<value>秒</value> <value>秒</value>
</data> </data>
<data name="Label" xml:space="preserve">
<value>标签</value>
</data>
</root> </root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

@@ -159,6 +159,11 @@
<Image Source="../../Resources/Img/LeftMainContent/BorderElement_16x.png"/> <Image Source="../../Resources/Img/LeftMainContent/BorderElement_16x.png"/>
</controls:EdgeElement.LeftContent> </controls:EdgeElement.LeftContent>
</ListBoxItem> </ListBoxItem>
<ListBoxItem Tag="{x:Static data:MessageToken.LabelDemoCtl}" Content="{x:Static langs:Lang.Label}">
<controls:EdgeElement.LeftContent>
<Image Source="../../Resources/Img/LeftMainContent/Label_16x.png"/>
</controls:EdgeElement.LeftContent>
</ListBoxItem>
</ListBox> </ListBox>
</Grid> </Grid>
</TabItem> </TabItem>
@@ -0,0 +1,17 @@
<UserControl x:Class="HandyControlDemo.UserControl.LabelDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
Background="{DynamicResource RegionBrush}">
<controls:TransitioningContentControl>
<StackPanel Margin="32">
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={x:Static langs:Lang.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}"/>
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={x:Static langs:Lang.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelDanger}"/>
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={x:Static langs:Lang.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelInfo}"/>
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={x:Static langs:Lang.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelPrimary}"/>
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={x:Static langs:Lang.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelSuccess}"/>
<Label HorizontalAlignment="Left" Margin="5" Content="{Binding Source={x:Static langs:Lang.Title},Converter={StaticResource StringRepeatConverter},ConverterParameter=10}" Style="{StaticResource LabelWarning}"/>
</StackPanel>
</controls:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl
{
public partial class LabelDemoCtl
{
public LabelDemoCtl()
{
InitializeComponent();
}
}
}
@@ -18,6 +18,8 @@ namespace HandyControl.Controls
private readonly Dictionary<object, CoverViewItem> _entryDic = new Dictionary<object, CoverViewItem>(); private readonly Dictionary<object, CoverViewItem> _entryDic = new Dictionary<object, CoverViewItem>();
private bool _isRefresh;
public CoverView() public CoverView()
{ {
_viewContent = new CoverViewContent(); _viewContent = new CoverViewContent();
@@ -171,12 +173,15 @@ namespace HandyControl.Controls
if (ItemsHost == null) return; if (ItemsHost == null) return;
_entryDic.Clear(); _entryDic.Clear();
_isRefresh = true;
foreach (var item in Items) foreach (var item in Items)
{ {
AddItem(item); AddItem(item);
} }
_isRefresh = false;
GenerateIndex(); GenerateIndex();
UpdateCoverViewContent(_viewContent.IsOpen); UpdateCoverViewContent(_viewContent.IsOpen);
@@ -214,6 +219,10 @@ namespace HandyControl.Controls
/// </summary> /// </summary>
private void UpdateCoverViewContentPosition() private void UpdateCoverViewContentPosition()
{ {
if (_viewContent.Parent != null)
{
ItemsHost.Children.Remove(_viewContent);
}
var total = Items.Count + 1; var total = Items.Count + 1;
var totalRow = total / Groups + (total % Groups > 0 ? 1 : 0); var totalRow = total / Groups + (total % Groups > 0 ? 1 : 0);
if (total <= Groups) if (total <= Groups)
@@ -245,6 +254,7 @@ namespace HandyControl.Controls
s.CollectionChanged -= InternalCollectionChanged; s.CollectionChanged -= InternalCollectionChanged;
} }
Items.Clear();
ClearItems(); ClearItems();
} }
_itemsSourceInternal = newValue; _itemsSourceInternal = newValue;
@@ -269,9 +279,13 @@ namespace HandyControl.Controls
private void ClearItems() private void ClearItems()
{ {
_selectedItem = null; _selectedItem = null;
if (_viewContent != null) _viewContent.Content = null;
_viewContent.ContentTemplate = null;
if (ItemsHost != null)
{ {
ItemsHost?.Children.Remove(_viewContent); ItemsHost.Children.Remove(_viewContent);
ItemsHost.Children.Clear();
} }
_entryDic.Clear(); _entryDic.Clear();
@@ -330,6 +344,11 @@ namespace HandyControl.Controls
} }
_entryDic[item] = element; _entryDic[item] = element;
ItemsHost.Children.Insert(index, element); ItemsHost.Children.Insert(index, element);
if (IsLoaded && !_isRefresh && _itemsSourceInternal != null)
{
Items.Insert(index, item);
}
} }
} }
} }
@@ -350,6 +369,14 @@ namespace HandyControl.Controls
{ {
if (ItemsHost == null) return; if (ItemsHost == null) return;
if (e.Action == NotifyCollectionChangedAction.Reset)
{
if (_entryDic.Count == 0) return;
ClearItems();
Items.Clear();
return;
}
if (e.OldItems != null) if (e.OldItems != null)
{ {
foreach (var item in e.OldItems) foreach (var item in e.OldItems)
@@ -369,10 +396,6 @@ namespace HandyControl.Controls
{ {
var index = e.NewStartingIndex + count++; var index = e.NewStartingIndex + count++;
InsertItem(index, item); InsertItem(index, item);
if (_itemsSourceInternal != null)
{
Items.Insert(index, item);
}
} }
} }
@@ -297,7 +297,7 @@ namespace HandyControl.Controls
Owner = ownerWindow, Owner = ownerWindow,
WindowStartupLocation = ownerIsNull ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner, WindowStartupLocation = ownerIsNull ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner,
ShowTitle = true, ShowTitle = true,
Title = caption, Title = caption ?? string.Empty,
Topmost = ownerIsNull, Topmost = ownerIsNull,
_messageBoxResult = defaultResult _messageBoxResult = defaultResult
}; };