add UniformSpacingPanel Demo

This commit is contained in:
NaBian committed 2021-01-05 23:45:12 +08:00
1 parent f069b5236d
commit 968441ad83
21 files changed
+13418 -9

No files matched your search

@@ -439,6 +439,9 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\ImageStack_16x.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\ImageStack_16x.png">
<Link>Resources\Img\LeftMainContent\ImageStack_16x.png</Link> <Link>Resources\Img\LeftMainContent\ImageStack_16x.png</Link>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\IncreaseHorizontalSpacing_16x.png">
<Link>Resources\Img\LeftMainContent\IncreaseHorizontalSpacing_16x.png</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\Dynamic_16x.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\Dynamic_16x.png">
<Link>Resources\Img\LeftMainContent\Dynamic_16x.png</Link> <Link>Resources\Img\LeftMainContent\Dynamic_16x.png</Link>
</Resource> </Resource>
@@ -440,6 +440,9 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\ImageStack_16x.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\ImageStack_16x.png">
<Link>Resources\Img\LeftMainContent\ImageStack_16x.png</Link> <Link>Resources\Img\LeftMainContent\ImageStack_16x.png</Link>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\IncreaseHorizontalSpacing_16x.png">
<Link>Resources\Img\LeftMainContent\IncreaseHorizontalSpacing_16x.png</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\Dynamic_16x.png"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\Dynamic_16x.png">
<Link>Resources\Img\LeftMainContent\Dynamic_16x.png</Link> <Link>Resources\Img\LeftMainContent\Dynamic_16x.png</Link>
</Resource> </Resource>
@@ -113,6 +113,9 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\DrawerDemoCtl.xaml"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\DrawerDemoCtl.xaml">
<Link>UserControl\Controls\DrawerDemoCtl.xaml</Link> <Link>UserControl\Controls\DrawerDemoCtl.xaml</Link>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\FlexPanelDemoCtl.xaml">
<Link>UserControl\Controls\FlexPanelDemoCtl.xaml</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\FlipClockDemoCtl.xaml"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\FlipClockDemoCtl.xaml">
<Link>UserControl\Controls\FlipClockDemoCtl.xaml</Link> <Link>UserControl\Controls\FlipClockDemoCtl.xaml</Link>
</Resource> </Resource>
@@ -245,6 +248,9 @@
<Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\TransitioningContentControlDemoCtl.xaml"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\TransitioningContentControlDemoCtl.xaml">
<Link>UserControl\Controls\TransitioningContentControlDemoCtl.xaml</Link> <Link>UserControl\Controls\TransitioningContentControlDemoCtl.xaml</Link>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\UniformSpacingPanelDemoCtl.xaml">
<Link>UserControl\Controls\UniformSpacingPanelDemoCtl.xaml</Link>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\WaterfallPanelDemoCtl.xaml"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\WaterfallPanelDemoCtl.xaml">
<Link>UserControl\Controls\WaterfallPanelDemoCtl.xaml</Link> <Link>UserControl\Controls\WaterfallPanelDemoCtl.xaml</Link>
</Resource> </Resource>
@@ -678,6 +684,10 @@
<Link>UserControl\Controls\TransitioningContentControlDemoCtl.xaml.cs</Link> <Link>UserControl\Controls\TransitioningContentControlDemoCtl.xaml.cs</Link>
<DependentUpon>TransitioningContentControlDemoCtl.xaml</DependentUpon> <DependentUpon>TransitioningContentControlDemoCtl.xaml</DependentUpon>
</Resource> </Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\UniformSpacingPanelDemoCtl.xaml.cs">
<Link>UserControl\Controls\UniformSpacingPanelDemoCtl.xaml.cs</Link>
<DependentUpon>UniformSpacingPanelDemoCtl.xaml</DependentUpon>
</Resource>
<Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\WaterfallPanelDemoCtl.xaml.cs"> <Resource Include="..\..\Shared\HandyControlDemo_Shared\UserControl\Controls\WaterfallPanelDemoCtl.xaml.cs">
<Link>UserControl\Controls\WaterfallPanelDemoCtl.xaml.cs</Link> <Link>UserControl\Controls\WaterfallPanelDemoCtl.xaml.cs</Link>
<DependentUpon>WaterfallPanelDemoCtl.xaml</DependentUpon> <DependentUpon>WaterfallPanelDemoCtl.xaml</DependentUpon>
@@ -1,4 +1,4 @@
[ [
{ {
"title": "Styles", "title": "Styles",
"selectedIndex": -1, "selectedIndex": -1,
@@ -79,6 +79,7 @@
[ "CirclePanel", "CirclePanelDemoCtl", "ColorWheel_16x", "" ], [ "CirclePanel", "CirclePanelDemoCtl", "ColorWheel_16x", "" ],
[ "Grid", "GridDemoCtl", "GridPane_16x", "" ], [ "Grid", "GridDemoCtl", "GridPane_16x", "" ],
[ "FlexPanel", "FlexPanelDemoCtl", "layout-FlexLayout-16", "1" ], [ "FlexPanel", "FlexPanelDemoCtl", "layout-FlexLayout-16", "1" ],
[ "UniformSpacingPanel", "UniformSpacingPanelDemoCtl", "IncreaseHorizontalSpacing_16x", "1" ],
[ "RelativePanel", "RelativePanelDemoCtl", "TransformRelative_16x", "" ], [ "RelativePanel", "RelativePanelDemoCtl", "TransformRelative_16x", "" ],
[ "WaterfallPanel", "WaterfallPanelDemoCtl", "Panel_16x", "" ], [ "WaterfallPanel", "WaterfallPanelDemoCtl", "Panel_16x", "" ],
[ "HoneycombPanel", "HoneycombPanelDemoCtl", "PolygonHexagon_16x", "" ], [ "HoneycombPanel", "HoneycombPanelDemoCtl", "PolygonHexagon_16x", "" ],
@@ -105,7 +106,7 @@
[ "Sprite", "SpriteDemoCtl", "HandyControl", "" ], [ "Sprite", "SpriteDemoCtl", "HandyControl", "" ],
[ "Notification", "NotificationDemoCtl", "Procedure_16x", "" ], [ "Notification", "NotificationDemoCtl", "Procedure_16x", "" ],
[ "Dialog", "DialogDemoCtl", "Dialog_16x", "" ], [ "Dialog", "DialogDemoCtl", "Dialog_16x", "" ],
[ "Screenshot", "ScreenshotDemoCtl", "WindowScreenshot_16x", "1" ], [ "Screenshot", "ScreenshotDemoCtl", "WindowScreenshot_16x", "" ],
[ "Window", "WindowDemoCtl", "WindowsForm_16x", "" ] [ "Window", "WindowDemoCtl", "WindowsForm_16x", "" ]
] ]
}, },
@@ -118,4 +119,4 @@
[ "Effects", "EffectsDemoCtl", "Effects_16x", "" ] [ "Effects", "EffectsDemoCtl", "Effects_16x", "" ]
] ]
} }
] ]
@@ -254,6 +254,9 @@
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\TransitioningContentControlDemoCtl.xaml.cs"> <Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\TransitioningContentControlDemoCtl.xaml.cs">
<DependentUpon>TransitioningContentControlDemoCtl.xaml</DependentUpon> <DependentUpon>TransitioningContentControlDemoCtl.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\UniformSpacingPanelDemoCtl.xaml.cs">
<DependentUpon>UniformSpacingPanelDemoCtl.xaml</DependentUpon>
</Compile>
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\WaterfallPanelDemoCtl.xaml.cs"> <Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\WaterfallPanelDemoCtl.xaml.cs">
<DependentUpon>WaterfallPanelDemoCtl.xaml</DependentUpon> <DependentUpon>WaterfallPanelDemoCtl.xaml</DependentUpon>
</Compile> </Compile>
@@ -796,6 +799,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\UniformSpacingPanelDemoCtl.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\WaterfallPanelDemoCtl.xaml"> <Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\WaterfallPanelDemoCtl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
@@ -2365,6 +2365,17 @@ namespace HandyControlDemo.Properties.Langs
} }
} }
/// <summary>
/// 查找类似 等间距布局 的本地化字符串。
/// </summary>
public static string UniformSpacingPanel
{
get
{
return ResourceManager.GetString("UniformSpacingPanel", resourceCulture);
}
}
/// <summary> /// <summary>
/// 查找类似 上传文件 的本地化字符串。 /// 查找类似 上传文件 的本地化字符串。
/// </summary> /// </summary>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>open touch drag move window</value> <value>open touch drag move window</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>UniformSpacingPanel</value>
</data>
</root> </root>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>open touch drag move window</value> <value>open touch drag move window</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>UniformSpacingPanel</value>
</data>
</root> </root>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>open touch drag move window</value> <value>open touch drag move window</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>UniformSpacingPanel</value>
</data>
</root> </root>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>open touch drag move window</value> <value>open touch drag move window</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>UniformSpacingPanel</value>
</data>
</root> </root>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>open touch drag move window</value> <value>open touch drag move window</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>UniformSpacingPanel</value>
</data>
</root> </root>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>open touch drag move window</value> <value>open touch drag move window</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>UniformSpacingPanel</value>
</data>
</root> </root>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>点击打开触摸拖动窗口</value> <value>点击打开触摸拖动窗口</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>等间距布局</value>
</data>
</root> </root>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>open touch drag move window</value> <value>open touch drag move window</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>UniformSpacingPanel</value>
</data>
</root> </root>
@@ -768,4 +768,7 @@
<data name="OpenTouchDragMoveWindow" xml:space="preserve"> <data name="OpenTouchDragMoveWindow" xml:space="preserve">
<value>open touch drag move window</value> <value>open touch drag move window</value>
</data> </data>
<data name="UniformSpacingPanel" xml:space="preserve">
<value>UniformSpacingPanel</value>
</data>
</root> </root>
@@ -246,6 +246,7 @@ namespace HandyControlDemo.Properties.Langs
OnPropertyChanged(nameof(TreeView)); OnPropertyChanged(nameof(TreeView));
OnPropertyChanged(nameof(Try2CloseApp)); OnPropertyChanged(nameof(Try2CloseApp));
OnPropertyChanged(nameof(Type)); OnPropertyChanged(nameof(Type));
OnPropertyChanged(nameof(UniformSpacingPanel));
OnPropertyChanged(nameof(UploadFile)); OnPropertyChanged(nameof(UploadFile));
OnPropertyChanged(nameof(UploadStr)); OnPropertyChanged(nameof(UploadStr));
OnPropertyChanged(nameof(Visibility)); OnPropertyChanged(nameof(Visibility));
@@ -1301,6 +1302,11 @@ namespace HandyControlDemo.Properties.Langs
/// </summary> /// </summary>
public string Type => Lang.Type; public string Type => Lang.Type;
/// <summary>
/// 查找类似 等间距布局 的本地化字符串。
/// </summary>
public string UniformSpacingPanel => Lang.UniformSpacingPanel;
/// <summary> /// <summary>
/// 查找类似 上传文件 的本地化字符串。 /// 查找类似 上传文件 的本地化字符串。
/// </summary> /// </summary>
Binary file not shown.

After

Width:  |  Height:  |  Size: 201 B

@@ -0,0 +1,39 @@
<UserControl x:Class="HandyControlDemo.UserControl.UniformSpacingPanelDemoCtl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
<hc:TransitioningContentControl>
<hc:SimpleStackPanel Margin="32">
<hc:UniformSpacingPanel Spacing="10">
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="2,2"/>
<hc:UniformSpacingPanel Spacing="10" Orientation="Vertical">
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="2,2"/>
<hc:UniformSpacingPanel Spacing="10" Width="300" ChildWrapping="Wrap" HorizontalAlignment="Left">
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
</hc:UniformSpacingPanel>
<hc:Divider LineStrokeDashArray="2,2"/>
<hc:UniformSpacingPanel Spacing="10" Orientation="Vertical" Height="70" ChildWrapping="Wrap" HorizontalAlignment="Left">
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
<Button Content="{ex:Lang Key={x:Static langs:LangKeys.ContentDemoStr}}"/>
</hc:UniformSpacingPanel>
</hc:SimpleStackPanel>
</hc:TransitioningContentControl>
</UserControl>
@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl
{
public partial class UniformSpacingPanelDemoCtl
{
public UniformSpacingPanelDemoCtl()
{
InitializeComponent();
}
}
}
@@ -135,7 +135,7 @@ namespace HandyControl.Controls
itemWidthSet ? itemWidth : child.DesiredSize.Width, itemWidthSet ? itemWidth : child.DesiredSize.Width,
itemHeightSet ? itemHeight : child.DesiredSize.Height); itemHeightSet ? itemHeight : child.DesiredSize.Height);
if (childWrapping == VisualWrapping.Wrap && MathHelper.GreaterThan(curLineSize.U + sz.U, uvConstraint.U)) if (childWrapping == VisualWrapping.Wrap && MathHelper.GreaterThan(curLineSize.U + sz.U + spacing, uvConstraint.U))
{ {
panelSize.U = Math.Max(curLineSize.U, panelSize.U); panelSize.U = Math.Max(curLineSize.U, panelSize.U);
panelSize.V += curLineSize.V + spacing; panelSize.V += curLineSize.V + spacing;
@@ -153,8 +153,9 @@ namespace HandyControl.Controls
else else
{ {
curLineSize.U += isFirst ? sz.U : sz.U + spacing; curLineSize.U += isFirst ? sz.U : sz.U + spacing;
isFirst = false;
curLineSize.V = Math.Max(sz.V, curLineSize.V); curLineSize.V = Math.Max(sz.V, curLineSize.V);
isFirst = false;
} }
} }
@@ -180,6 +181,7 @@ namespace HandyControl.Controls
var childWrapping = ChildWrapping; var childWrapping = ChildWrapping;
var children = InternalChildren; var children = InternalChildren;
var isFirst = true;
for (int i = 0, count = children.Count; i < count; i++) for (int i = 0, count = children.Count; i < count; i++)
{ {
@@ -191,7 +193,7 @@ namespace HandyControl.Controls
itemWidthSet ? itemWidth : child.DesiredSize.Width, itemWidthSet ? itemWidth : child.DesiredSize.Width,
itemHeightSet ? itemHeight : child.DesiredSize.Height); itemHeightSet ? itemHeight : child.DesiredSize.Height);
if (childWrapping == VisualWrapping.Wrap && MathHelper.GreaterThan(curLineSize.U + sz.U, uvFinalSize.U)) if (childWrapping == VisualWrapping.Wrap && MathHelper.GreaterThan(curLineSize.U + sz.U + spacing, uvFinalSize.U))
{ {
ArrangeLine(accumulatedV, curLineSize.V, firstInLine, i, useItemU, itemU, spacing); ArrangeLine(accumulatedV, curLineSize.V, firstInLine, i, useItemU, itemU, spacing);
@@ -205,12 +207,16 @@ namespace HandyControl.Controls
accumulatedV += sz.V + spacing; accumulatedV += sz.V + spacing;
curLineSize = new UVSize(_orientation); curLineSize = new UVSize(_orientation);
} }
firstInLine = i; firstInLine = i;
isFirst = true;
} }
else else
{ {
curLineSize.U += sz.U; curLineSize.U += isFirst ? sz.U : sz.U + spacing;
curLineSize.V = Math.Max(sz.V, curLineSize.V); curLineSize.V = Math.Max(sz.V, curLineSize.V);
isFirst = false;
} }
} }
File diff suppressed because it is too large. Load diff