add some demos
This commit is contained in:
1 parent
fa863c5bcb
commit
48920792f0
7 files changed
+113
-22
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using System.Windows;
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Extension;
|
||||
@@ -66,6 +67,10 @@ namespace HandyControl.Controls
|
||||
case ColLayoutStatus.Xxl:
|
||||
result = Layout.Xxl;
|
||||
break;
|
||||
case ColLayoutStatus.Auto:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(status), status, null);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace HandyControl.Controls
|
||||
|
||||
private double _maxChildDesiredHeight;
|
||||
|
||||
private double _totalAutoWidth;
|
||||
|
||||
public static readonly DependencyProperty GutterProperty = DependencyProperty.Register(
|
||||
"Gutter", typeof(double), typeof(Row), new PropertyMetadata(ValueBoxes.Double0Box, null, OnGutterCoerce), ValidateHelper.IsInRangeOfPosDoubleIncludeZero);
|
||||
|
||||
@@ -29,6 +31,7 @@ namespace HandyControl.Controls
|
||||
var totalCellCount = 0;
|
||||
var totalRowCount = 1;
|
||||
var gutterHalf = Gutter / 2;
|
||||
_totalAutoWidth = 0;
|
||||
|
||||
foreach (var child in InternalChildren.OfType<Col>())
|
||||
{
|
||||
@@ -40,12 +43,7 @@ namespace HandyControl.Controls
|
||||
{
|
||||
_maxChildDesiredHeight = childDesiredSize.Height;
|
||||
}
|
||||
}
|
||||
|
||||
_layoutStatus = ColLayout.GetLayoutStatus(constraint.Width);
|
||||
|
||||
foreach (var child in InternalChildren.OfType<Col>())
|
||||
{
|
||||
var cellCount = child.GetLayoutCellCount(_layoutStatus);
|
||||
totalCellCount += cellCount;
|
||||
|
||||
@@ -54,16 +52,21 @@ namespace HandyControl.Controls
|
||||
totalCellCount = cellCount;
|
||||
totalRowCount++;
|
||||
}
|
||||
|
||||
if (cellCount == 0)
|
||||
{
|
||||
_totalAutoWidth += childDesiredSize.Width;
|
||||
}
|
||||
}
|
||||
|
||||
return new Size(0, _maxChildDesiredHeight * totalRowCount - Gutter);
|
||||
return new Size(constraint.Width, _maxChildDesiredHeight * totalRowCount - Gutter);
|
||||
}
|
||||
|
||||
protected override Size ArrangeOverride(Size finalSize)
|
||||
{
|
||||
var totalCellCount = 0;
|
||||
var gutterHalf = Gutter / 2;
|
||||
var itemWidth = (finalSize.Width + Gutter) / ColLayout.ColMaxCellCount;
|
||||
var itemWidth = (finalSize.Width - _totalAutoWidth + Gutter) / ColLayout.ColMaxCellCount;
|
||||
var childBounds = new Rect(-gutterHalf, -gutterHalf, 0, _maxChildDesiredHeight);
|
||||
_layoutStatus = ColLayout.GetLayoutStatus(finalSize.Width);
|
||||
|
||||
@@ -72,7 +75,8 @@ namespace HandyControl.Controls
|
||||
var cellCount = child.GetLayoutCellCount(_layoutStatus);
|
||||
totalCellCount += cellCount;
|
||||
|
||||
var childWidth = cellCount * itemWidth;
|
||||
var childWidth = cellCount > 0 ? cellCount * itemWidth : child.DesiredSize.Width;
|
||||
|
||||
childBounds.Width = childWidth;
|
||||
childBounds.X += child.Offset * itemWidth;
|
||||
if (totalCellCount > ColLayout.ColMaxCellCount)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using HandyControl.Data;
|
||||
|
||||
namespace HandyControl.Controls
|
||||
@@ -11,19 +12,10 @@ namespace HandyControl.Controls
|
||||
|
||||
public object Content
|
||||
{
|
||||
get => (object) GetValue(ContentProperty);
|
||||
get => GetValue(ContentProperty);
|
||||
set => SetValue(ContentProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty DashedProperty = DependencyProperty.Register(
|
||||
"Dashed", typeof(bool), typeof(Divider), new PropertyMetadata(ValueBoxes.FalseBox));
|
||||
|
||||
public bool Dashed
|
||||
{
|
||||
get => (bool) GetValue(DashedProperty);
|
||||
set => SetValue(DashedProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty OrientationProperty = DependencyProperty.Register(
|
||||
"Orientation", typeof(Orientation), typeof(Divider), new PropertyMetadata(default(Orientation)));
|
||||
|
||||
@@ -32,5 +24,59 @@ namespace HandyControl.Controls
|
||||
get => (Orientation) GetValue(OrientationProperty);
|
||||
set => SetValue(OrientationProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ContentTemplateProperty = DependencyProperty.Register(
|
||||
"ContentTemplate", typeof(DataTemplate), typeof(Divider), new PropertyMetadata(default(DataTemplate)));
|
||||
|
||||
public DataTemplate ContentTemplate
|
||||
{
|
||||
get => (DataTemplate) GetValue(ContentTemplateProperty);
|
||||
set => SetValue(ContentTemplateProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ContentStringFormatProperty = DependencyProperty.Register(
|
||||
"ContentStringFormat", typeof(string), typeof(Divider), new PropertyMetadata(default(string)));
|
||||
|
||||
public string ContentStringFormat
|
||||
{
|
||||
get => (string) GetValue(ContentStringFormatProperty);
|
||||
set => SetValue(ContentStringFormatProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty ContentTemplateSelectorProperty = DependencyProperty.Register(
|
||||
"ContentTemplateSelector", typeof(DataTemplateSelector), typeof(Divider), new PropertyMetadata(default(DataTemplateSelector)));
|
||||
|
||||
public DataTemplateSelector ContentTemplateSelector
|
||||
{
|
||||
get => (DataTemplateSelector) GetValue(ContentTemplateSelectorProperty);
|
||||
set => SetValue(ContentTemplateSelectorProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty LineStrokeProperty = DependencyProperty.Register(
|
||||
"LineStroke", typeof(Brush), typeof(Divider), new PropertyMetadata(default(Brush)));
|
||||
|
||||
public Brush LineStroke
|
||||
{
|
||||
get => (Brush) GetValue(LineStrokeProperty);
|
||||
set => SetValue(LineStrokeProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty LineStrokeThicknessProperty = DependencyProperty.Register(
|
||||
"LineStrokeThickness", typeof(double), typeof(Divider), new PropertyMetadata(ValueBoxes.Double1Box));
|
||||
|
||||
public double LineStrokeThickness
|
||||
{
|
||||
get => (double) GetValue(LineStrokeThicknessProperty);
|
||||
set => SetValue(LineStrokeThicknessProperty, value);
|
||||
}
|
||||
|
||||
public static readonly DependencyProperty LineStrokeDashArrayProperty = DependencyProperty.Register(
|
||||
"LineStrokeDashArray", typeof(DoubleCollection), typeof(Divider), new PropertyMetadata(new DoubleCollection()));
|
||||
|
||||
public DoubleCollection LineStrokeDashArray
|
||||
{
|
||||
get => (DoubleCollection) GetValue(LineStrokeDashArrayProperty);
|
||||
set => SetValue(LineStrokeDashArrayProperty, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user