add Grid
This commit is contained in:
1 parent
467bedb656
commit
a0707147ae
20 files changed
+314
-24
No files matched your search
@@ -414,6 +414,9 @@
|
||||
<Generator>TextTemplatingFileGenerator</Generator>
|
||||
<LastGenOutput>MessageToken.cs</LastGenOutput>
|
||||
</Content>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\LeftMainContent\GridPane_16x.png">
|
||||
<Link>Resources\Img\LeftMainContent\GridPane_16x.png</Link>
|
||||
</Resource>
|
||||
<Resource Include="..\..\Shared\HandyControlDemo_Shared\Resources\Img\DevOps\DevOps-Boards.png">
|
||||
<Link>Resources\Img\DevOps\DevOps-Boards.png</Link>
|
||||
</Resource>
|
||||
|
||||
@@ -94,6 +94,8 @@
|
||||
|
||||
public static readonly string SideMenuDemoCtl = nameof(SideMenuDemoCtl);
|
||||
|
||||
public static readonly string GridDemoCtl = nameof(GridDemoCtl);
|
||||
|
||||
public static readonly string ButtonDemoCtl = nameof(ButtonDemoCtl);
|
||||
|
||||
public static readonly string RepeatButtonDemoCtl = nameof(RepeatButtonDemoCtl);
|
||||
|
||||
@@ -49,7 +49,8 @@ var controlList = new List<string>
|
||||
"BadgeDemoCtl",
|
||||
"GravatarDemoCtl",
|
||||
"DialogDemoCtl",
|
||||
"SideMenuDemoCtl"
|
||||
"SideMenuDemoCtl",
|
||||
"GridDemoCtl"
|
||||
};
|
||||
var styleList = new List<string>
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Basic\ChatBox.xaml.cs">
|
||||
<DependentUpon>ChatBox.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Basic\IFull.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Basic\InteractiveDialog.xaml.cs">
|
||||
<DependentUpon>InteractiveDialog.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -74,6 +75,9 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\CompareSliderDemoCtl.xaml.cs">
|
||||
<DependentUpon>CompareSliderDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\GridDemoCtl.xaml.cs">
|
||||
<DependentUpon>GridDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="$(MSBuildThisFileDirectory)UserControl\Controls\CoverFlowDemoCtl.xaml.cs">
|
||||
<DependentUpon>CoverFlowDemoCtl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -420,6 +424,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\GridDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="$(MSBuildThisFileDirectory)UserControl\Controls\CoverFlowDemoCtl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -528,6 +528,15 @@ namespace HandyControlDemo.Properties.Langs {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 栅格 的本地化字符串。
|
||||
/// </summary>
|
||||
public static string Grid {
|
||||
get {
|
||||
return ResourceManager.GetString("Grid", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查找类似 分组框 的本地化字符串。
|
||||
/// </summary>
|
||||
|
||||
@@ -582,4 +582,7 @@
|
||||
<data name="Overview" xml:space="preserve">
|
||||
<value>Overview</value>
|
||||
</data>
|
||||
<data name="Grid" xml:space="preserve">
|
||||
<value>Grid</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -582,4 +582,7 @@
|
||||
<data name="Overview" xml:space="preserve">
|
||||
<value>概览</value>
|
||||
</data>
|
||||
<data name="Grid" xml:space="preserve">
|
||||
<value>栅格</value>
|
||||
</data>
|
||||
</root>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 129 B |
@@ -0,0 +1,7 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
internal interface IFull
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<UserControl x:Class="HandyControlDemo.UserControl.GridDemoCtl"
|
||||
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:extension="clr-namespace:HandyControl.Tools.Extension;assembly=HandyControl"
|
||||
Background="{DynamicResource RegionBrush}">
|
||||
<ScrollViewer>
|
||||
<StackPanel Margin="32">
|
||||
<controls:Row>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
<controls:Col>
|
||||
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4" Margin="10"/>
|
||||
</controls:Col>
|
||||
</controls:Row>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace HandyControlDemo.UserControl
|
||||
{
|
||||
public partial class GridDemoCtl : IFull
|
||||
{
|
||||
public GridDemoCtl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,7 +200,7 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/User_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.BadgeDemoCtl}" Content="{x:Static langs:Lang.Badge}">
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.BadgeDemoCtl}" Content="{x:Static langs:Lang.Badge}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/DotLarge_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
@@ -315,6 +315,11 @@
|
||||
<Image Source="../../Resources/Img/LeftMainContent/ColorWheel_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Style="{StaticResource ListBoxItemNew}" Tag="{x:Static data:MessageToken.GridDemoCtl}" Content="{x:Static langs:Lang.Grid}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/GridPane_16x.png"/>
|
||||
</controls:EdgeElement.LeftContent>
|
||||
</ListBoxItem>
|
||||
<ListBoxItem Tag="{x:Static data:MessageToken.WaterfallPanelDemoCtl}" Content="{x:Static langs:Lang.WaterfallPanel}">
|
||||
<controls:EdgeElement.LeftContent>
|
||||
<Image Source="../../Resources/Img/LeftMainContent/Panel_16x.png"/>
|
||||
|
||||
@@ -9,6 +9,7 @@ using GalaSoft.MvvmLight.Messaging;
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.Service;
|
||||
using HandyControlDemo.Tools;
|
||||
using HandyControlDemo.UserControl;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
@@ -114,9 +115,10 @@ namespace HandyControlDemo.ViewModel
|
||||
if (Equals(_listBoxItemCurrent, item)) return;
|
||||
_listBoxItemCurrent = item;
|
||||
ContentTitle = item.Content;
|
||||
Messenger.Default.Send(false, MessageToken.FullSwitch);
|
||||
var obj = AssemblyHelper.ResolveByKey(tag);
|
||||
Messenger.Default.Send(obj ?? AssemblyHelper.CreateInternalInstance($"UserControl.{tag}"), MessageToken.LoadShowContent);
|
||||
var ctl = obj ?? AssemblyHelper.CreateInternalInstance($"UserControl.{tag}");
|
||||
Messenger.Default.Send(ctl is IFull, MessageToken.FullSwitch);
|
||||
Messenger.Default.Send(ctl, MessageToken.LoadShowContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Extension;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class Col : ContentControl
|
||||
{
|
||||
public static readonly DependencyProperty LayoutProperty = DependencyProperty.Register(
|
||||
"Layout", typeof(ColLayout), typeof(Col), new PropertyMetadata(new ColLayout()));
|
||||
|
||||
public ColLayout Layout
|
||||
{
|
||||
get => (ColLayout)GetValue(LayoutProperty);
|
||||
set => SetValue(LayoutProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OffsetProperty = DependencyProperty.Register(
|
||||
"Offset", typeof(int), typeof(Col), new PropertyMetadata(default(int)));
|
||||
|
||||
public int Offset
|
||||
{
|
||||
get => (int)GetValue(OffsetProperty);
|
||||
set => SetValue(OffsetProperty, value);
|
||||
}
|
||||
|
||||
internal int GetLayoutCellCount(ColLayoutStatus status)
|
||||
{
|
||||
switch (status)
|
||||
{
|
||||
case ColLayoutStatus.Xs: return Layout.Xs;
|
||||
case ColLayoutStatus.Sm: return Layout.Sm;
|
||||
case ColLayoutStatus.Md: return Layout.Md;
|
||||
case ColLayoutStatus.Lg: return Layout.Lg;
|
||||
case ColLayoutStatus.Xl: return Layout.Xl;
|
||||
case ColLayoutStatus.Xxl: return Layout.Xxl;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
using HandyControl.Tools.Extension;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using HandyControl.Data;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class Row : Panel
|
||||
{
|
||||
private ColLayoutStatus _layoutStatus;
|
||||
|
||||
public static readonly DependencyProperty GutterProperty = DependencyProperty.Register(
|
||||
"Gutter", typeof(double), typeof(Row), new PropertyMetadata(default(double)));
|
||||
|
||||
public double Gutter
|
||||
{
|
||||
get => (double)GetValue(GutterProperty);
|
||||
set => SetValue(GutterProperty, value);
|
||||
}
|
||||
|
||||
protected override Size MeasureOverride(Size constraint)
|
||||
{
|
||||
var itemWidth = constraint.Width / ColLayout.ColMaxCellCount;
|
||||
var totalCellCount = 0;
|
||||
var totalRowCount = 1;
|
||||
var maxChildDesiredHeight = .0;
|
||||
|
||||
for (int i = 0, count = InternalChildren.Count; i < count; ++i)
|
||||
{
|
||||
var child = InternalChildren[i];
|
||||
|
||||
child.Measure(constraint);
|
||||
var childDesiredSize = child.DesiredSize;
|
||||
|
||||
if (maxChildDesiredHeight < childDesiredSize.Height)
|
||||
{
|
||||
maxChildDesiredHeight = childDesiredSize.Height;
|
||||
}
|
||||
}
|
||||
|
||||
var childBounds = new Rect(0, 0, 0, maxChildDesiredHeight);
|
||||
_layoutStatus = ColLayout.GetLayoutStatus(constraint.Width);
|
||||
|
||||
foreach (var child in InternalChildren.OfType<Col>())
|
||||
{
|
||||
var cellCount = child.GetLayoutCellCount(_layoutStatus);
|
||||
totalCellCount += cellCount;
|
||||
|
||||
if (totalCellCount > ColLayout.ColMaxCellCount)
|
||||
{
|
||||
childBounds.X = 0;
|
||||
childBounds.Y += maxChildDesiredHeight;
|
||||
totalCellCount = cellCount;
|
||||
totalRowCount++;
|
||||
}
|
||||
|
||||
var childWidth = cellCount * itemWidth;
|
||||
childBounds.Width = childWidth;
|
||||
child.Arrange(childBounds);
|
||||
childBounds.X += childWidth;
|
||||
}
|
||||
|
||||
return new Size(constraint.Width, maxChildDesiredHeight * totalRowCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class Col : Panel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
{
|
||||
public class Row : Panel
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace HandyControl.Data
|
||||
{
|
||||
public enum ColLayoutStatus
|
||||
{
|
||||
Xs,
|
||||
Sm,
|
||||
Md,
|
||||
Lg,
|
||||
Xl,
|
||||
Xxl,
|
||||
}
|
||||
}
|
||||
@@ -40,6 +40,8 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Cover\CoverView\CoverView.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Cover\CoverView\CoverViewContent.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Cover\CoverView\CoverViewItem.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Grid\Col.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Grid\Row.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Image\GifImage.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Image\ImageViewer.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Input\ComboBox.cs" />
|
||||
@@ -72,8 +74,6 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\Shield.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Other\TransitioningContentControl.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Panel\CirclePanel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Panel\Col.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Panel\Row.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Panel\SimplePanel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\Panel\WaterfallPanel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Controls\ProgressBar\CircleProgressBar.cs" />
|
||||
@@ -114,6 +114,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\BadgeStatus.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\ChatMessageType.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\ChatRoleType.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\ColLayoutStatus.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\ExpandMode.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\InfoType.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Data\Enum\IpType.cs" />
|
||||
@@ -219,6 +220,7 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\String2VisibilityConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\String2VisibilityReConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Converter\TreeViewItemMarginConverter.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ColLayout.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\ColorExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\DialogExtension.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Tools\Extension\EnumerableExtension.cs" />
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Windows.Markup;
|
||||
using HandyControl.Data;
|
||||
|
||||
namespace HandyControl.Tools.Extension
|
||||
{
|
||||
public class ColLayout : MarkupExtension
|
||||
{
|
||||
public static readonly int ColMaxCellCount = 24;
|
||||
|
||||
public static readonly int XsMaxWidth = 768;
|
||||
|
||||
public static readonly int SmMaxWidth = 992;
|
||||
|
||||
public static readonly int MdMaxWidth = 1200;
|
||||
|
||||
public static readonly int LgMaxWidth = 1920;
|
||||
|
||||
public static readonly int XlMaxWidth = 2560;
|
||||
|
||||
public int Xs { get; set; } = 24;
|
||||
|
||||
public int Sm { get; set; } = 12;
|
||||
|
||||
public int Md { get; set; } = 8;
|
||||
|
||||
public int Lg { get; set; } = 6;
|
||||
|
||||
public int Xl { get; set; } = 4;
|
||||
|
||||
public int Xxl { get; set; } = 2;
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return new ColLayout
|
||||
{
|
||||
Xs = Xs,
|
||||
Sm = Sm,
|
||||
Md = Md,
|
||||
Lg = Lg,
|
||||
Xl = Xl,
|
||||
Xxl = Xxl
|
||||
};
|
||||
}
|
||||
|
||||
public static ColLayoutStatus GetLayoutStatus(double width)
|
||||
{
|
||||
if (width < MdMaxWidth)
|
||||
{
|
||||
if (width < SmMaxWidth)
|
||||
{
|
||||
if (width < XsMaxWidth)
|
||||
{
|
||||
return ColLayoutStatus.Xs;
|
||||
}
|
||||
return ColLayoutStatus.Sm;
|
||||
}
|
||||
return ColLayoutStatus.Md;
|
||||
}
|
||||
if (width < XlMaxWidth)
|
||||
{
|
||||
if (width < LgMaxWidth)
|
||||
{
|
||||
return ColLayoutStatus.Lg;
|
||||
}
|
||||
return ColLayoutStatus.Xl;
|
||||
}
|
||||
return ColLayoutStatus.Xxl;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user