Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
HandyControl
提交
81ddae5f
H
HandyControl
项目概览
jobily
/
HandyControl
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
HandyControl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
81ddae5f
编写于
6月 07, 2023
作者:
N
NaBian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: close #1374
上级
4206bfd6
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
77 addition
and
85 deletion
+77
-85
src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
+1
-1
src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
...andyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
+1
-1
src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj
...t_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj
+1
-1
src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml
...yControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml
+2
-3
src/Shared/HandyControl_Shared/Controls/Panel/Grid/Col.cs
src/Shared/HandyControl_Shared/Controls/Panel/Grid/Col.cs
+20
-38
src/Shared/HandyControl_Shared/Controls/Panel/Grid/Row.cs
src/Shared/HandyControl_Shared/Controls/Panel/Grid/Row.cs
+42
-31
src/Shared/HandyControl_Shared/Themes/Styles/Base/DividerBaseStyle.xaml
...dyControl_Shared/Themes/Styles/Base/DividerBaseStyle.xaml
+2
-2
src/Shared/HandyControl_Shared/Themes/Theme.xaml
src/Shared/HandyControl_Shared/Themes/Theme.xaml
+1
-1
src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
+7
-7
未找到文件。
src/Net_40/HandyControl_Net_40/Themes/Theme.xaml
浏览文件 @
81ddae5f
...
...
@@ -8582,7 +8582,7 @@
<hc:Col Layout="12" x:Name="ColStart">
<Line VerticalAlignment="Center" StrokeDashArray="{TemplateBinding LineStrokeDashArray}" Stroke="{TemplateBinding LineStroke}" X2="1" StrokeThickness="{TemplateBinding LineStrokeThickness}" Stretch="Fill" StrokeEndLineCap="Square" StrokeStartLineCap="Square" />
</hc:Col>
<hc:Col
Layout="0
">
<hc:Col
IsFixed="True
">
<ContentPresenter Margin="{TemplateBinding Padding}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" />
</hc:Col>
<hc:Col Layout="12" x:Name="ColEnd">
...
...
src/Net_GE45/HandyControlDemo_Net_GE45/HandyControlDemo_Net_GE45.csproj
浏览文件 @
81ddae5f
...
...
@@ -5,7 +5,7 @@
<RootNamespace>HandyControlDemo</RootNamespace>
<TargetFrameworks>netcoreapp3.0;netcoreapp3.1;net45;net451;net452;net46;net461;net462;net47;net471;net472;net48;net481;net5.0-windows;net6.0-windows;net7.0-windows</TargetFrameworks>
<ApplicationIcon>..\..\Shared\HandyControlDemo_Shared\Resources\Img\icon.ico</ApplicationIcon>
<NoWarn>0108;MSB3026;MSB3061</NoWarn>
<NoWarn>0108;MSB3026;MSB3061
;SYSLIB0014
</NoWarn>
<MSBuildWarningsAsMessages>NETSDK1138</MSBuildWarningsAsMessages>
<ApplicationManifest>..\..\Shared\HandyControlDemo_Shared\app.manifest</ApplicationManifest>
</PropertyGroup>
...
...
src/Net_GE45/HandyControl_Net_GE45/HandyControl_Net_GE45.csproj
浏览文件 @
81ddae5f
...
...
@@ -6,7 +6,7 @@
<Description>Contains some simple and commonly used WPF controls</Description>
<PackageId>HandyControl</PackageId>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<NoWarn>0067;0649;1591;MSB3061;SYSLIB0003;SYSLIB0004</NoWarn>
<NoWarn>0067;0649;1591;MSB3061;SYSLIB0003;SYSLIB0004
;SYSLIB0032
</NoWarn>
<MSBuildWarningsAsMessages>NETSDK1138</MSBuildWarningsAsMessages>
<AssemblyOriginatorKeyFile>..\..\Shared\HandyControl_Shared\key.snk</AssemblyOriginatorKeyFile>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
...
...
src/Shared/HandyControlDemo_Shared/UserControl/Controls/GridDemoCtl.xaml
浏览文件 @
81ddae5f
...
...
@@ -2,7 +2,6 @@
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:extension="clr-namespace:HandyControl.Tools.Extension;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
xmlns:ex="clr-namespace:HandyControlDemo.Tools.Extension"
Background="{DynamicResource RegionBrush}">
...
...
@@ -146,10 +145,10 @@
<hc:Col Layout="4 6 8 9 11">
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4"/>
</hc:Col>
<hc:Col Layout="{
extension
:ColLayout Xs=4, Sm=6, Md=8, Lg=9, Xl=11}">
<hc:Col Layout="{
hc
:ColLayout Xs=4, Sm=6, Md=8, Lg=9, Xl=11}">
<Border Background="{DynamicResource BorderBrush}" Height="36" CornerRadius="4"/>
</hc:Col>
<hc:Col Layout="{
extension
:ColLayout Xs=8, Sm=6, Md=4, Lg=3, Xl=1}">
<hc:Col Layout="{
hc
:ColLayout Xs=8, Sm=6, Md=4, Lg=3, Xl=1}">
<Border Background="{DynamicResource SecondaryBorderBrush}" Height="36" CornerRadius="4"/>
</hc:Col>
</hc:Row>
...
...
src/Shared/HandyControl_Shared/Controls/Panel/Grid/Col.cs
浏览文件 @
81ddae5f
...
...
@@ -9,7 +9,7 @@ namespace HandyControl.Controls;
public
class
Col
:
ContentControl
{
public
static
readonly
DependencyProperty
LayoutProperty
=
DependencyProperty
.
Register
(
nameof
(
Layout
),
typeof
(
ColLayout
),
typeof
(
Col
),
new
PropertyMetadata
(
default
(
ColLayout
)
));
nameof
(
Layout
),
typeof
(
ColLayout
),
typeof
(
Col
),
new
FrameworkPropertyMetadata
(
default
(
ColLayout
),
FrameworkPropertyMetadataOptions
.
AffectsParentMeasure
));
public
ColLayout
Layout
{
...
...
@@ -18,7 +18,7 @@ public class Col : ContentControl
}
public
static
readonly
DependencyProperty
OffsetProperty
=
DependencyProperty
.
Register
(
nameof
(
Offset
),
typeof
(
int
),
typeof
(
Col
),
new
PropertyMetadata
(
ValueBoxes
.
Int0Box
));
nameof
(
Offset
),
typeof
(
int
),
typeof
(
Col
),
new
FrameworkPropertyMetadata
(
ValueBoxes
.
Int0Box
,
FrameworkPropertyMetadataOptions
.
AffectsParentMeasure
));
public
int
Offset
{
...
...
@@ -27,12 +27,12 @@ public class Col : ContentControl
}
public
static
readonly
DependencyProperty
SpanProperty
=
DependencyProperty
.
Register
(
nameof
(
Span
),
typeof
(
int
),
typeof
(
Col
),
new
PropertyMetadata
(
24
),
OnSpanValidate
);
nameof
(
Span
),
typeof
(
int
),
typeof
(
Col
),
new
FrameworkPropertyMetadata
(
ColLayout
.
ColMaxCellCount
,
FrameworkPropertyMetadataOptions
.
AffectsParentMeasure
),
OnSpanValidate
);
private
static
bool
OnSpanValidate
(
object
value
)
{
var
v
=
(
int
)
value
;
return
v
is
>=
1
and
<=
24
;
return
v
is
>=
1
and
<=
ColLayout
.
ColMaxCellCount
;
}
public
int
Span
...
...
@@ -42,7 +42,7 @@ public class Col : ContentControl
}
public
static
readonly
DependencyProperty
IsFixedProperty
=
DependencyProperty
.
Register
(
nameof
(
IsFixed
),
typeof
(
bool
),
typeof
(
Col
),
new
PropertyMetadata
(
ValueBoxes
.
FalseBox
));
nameof
(
IsFixed
),
typeof
(
bool
),
typeof
(
Col
),
new
FrameworkPropertyMetadata
(
ValueBoxes
.
FalseBox
,
FrameworkPropertyMetadataOptions
.
AffectsParentMeasure
));
public
bool
IsFixed
{
...
...
@@ -52,44 +52,26 @@ public class Col : ContentControl
internal
int
GetLayoutCellCount
(
ColLayoutStatus
status
)
{
var
result
=
0
;
if
(
Layout
!=
null
)
if
(
Layout
is
not
null
)
{
if
(!
IsFixed
)
return
status
switch
{
switch
(
status
)
{
case
ColLayoutStatus
.
Xs
:
result
=
Layout
.
Xs
;
break
;
case
ColLayoutStatus
.
Sm
:
result
=
Layout
.
Sm
;
break
;
case
ColLayoutStatus
.
Md
:
result
=
Layout
.
Md
;
break
;
case
ColLayoutStatus
.
Lg
:
result
=
Layout
.
Lg
;
break
;
case
ColLayoutStatus
.
Xl
:
result
=
Layout
.
Xl
;
break
;
case
ColLayoutStatus
.
Xxl
:
result
=
Layout
.
Xxl
;
break
;
case
ColLayoutStatus
.
Auto
:
break
;
default
:
throw
new
ArgumentOutOfRangeException
(
nameof
(
status
),
status
,
null
);
}
}
ColLayoutStatus
.
Xs
=>
Layout
.
Xs
,
ColLayoutStatus
.
Sm
=>
Layout
.
Sm
,
ColLayoutStatus
.
Md
=>
Layout
.
Md
,
ColLayoutStatus
.
Lg
=>
Layout
.
Lg
,
ColLayoutStatus
.
Xl
=>
Layout
.
Xl
,
ColLayoutStatus
.
Xxl
=>
Layout
.
Xxl
,
ColLayoutStatus
.
Auto
=>
0
,
_
=>
throw
new
ArgumentOutOfRangeException
(
nameof
(
status
),
status
,
null
),
};
}
else
if
(
IsFixed
)
{
re
sult
=
Span
;
re
turn
0
;
}
return
result
;
return
Span
;
}
}
src/Shared/HandyControl_Shared/Controls/Panel/Grid/Row.cs
浏览文件 @
81ddae5f
...
...
@@ -14,12 +14,15 @@ public class Row : Panel
private
double
_maxChildDesiredHeight
;
private
double
_
totalAuto
Width
;
private
double
_
fixed
Width
;
public
static
readonly
DependencyProperty
GutterProperty
=
DependencyProperty
.
Register
(
nameof
(
Gutter
),
typeof
(
double
),
typeof
(
Row
),
new
PropertyMetadata
(
ValueBoxes
.
Double0Box
,
null
,
OnGutterCoerce
),
ValidateHelper
.
IsInRangeOfPosDoubleIncludeZero
);
nameof
(
Gutter
),
typeof
(
double
),
typeof
(
Row
),
new
FrameworkPropertyMetadata
(
ValueBoxes
.
Double0Box
,
FrameworkPropertyMetadataOptions
.
AffectsMeasure
,
null
,
OnGutterCoerce
),
ValidateHelper
.
IsInRangeOfPosDoubleIncludeZero
);
private
static
object
OnGutterCoerce
(
DependencyObject
d
,
object
basevalue
)
=>
ValidateHelper
.
IsInRangeOfPosDoubleIncludeZero
(
basevalue
)
?
basevalue
:
.
0
;
private
static
object
OnGutterCoerce
(
DependencyObject
d
,
object
basevalue
)
=>
ValidateHelper
.
IsInRangeOfPosDoubleIncludeZero
(
basevalue
)
?
basevalue
:
.
0
;
public
double
Gutter
{
...
...
@@ -29,51 +32,59 @@ public class Row : Panel
protected
override
Size
MeasureOverride
(
Size
constraint
)
{
var
gutter
=
Gutter
;
var
totalCellCount
=
0
;
var
totalRowCount
=
1
;
var
gutterHalf
=
Gutter
/
2
;
_totalAutoWidth
=
0
;
_fixedWidth
=
0
;
_maxChildDesiredHeight
=
0
;
var
cols
=
InternalChildren
.
OfType
<
Col
>().
ToList
();
foreach
(
var
child
in
InternalChildren
.
OfType
<
Col
>()
)
foreach
(
var
child
in
cols
)
{
child
.
Margin
=
new
Thickness
(
gutterHalf
);
child
.
Measure
(
constraint
);
var
childDesiredSize
=
child
.
DesiredSize
;
if
(
_maxChildDesiredHeight
<
childDesiredSize
.
Height
)
{
_maxChildDesiredHeight
=
childDesiredSize
.
Height
;
}
var
cellCount
=
child
.
GetLayoutCellCount
(
_layoutStatus
);
totalCellCount
+=
cellCount
;
if
(
totalCellCount
>
ColLayout
.
ColMaxCellCount
)
if
(
cellCount
==
0
||
child
.
IsFixed
)
{
totalCellCount
=
cellCount
;
totalRowCount
++;
child
.
Measure
(
constraint
);
_maxChildDesiredHeight
=
Math
.
Max
(
_maxChildDesiredHeight
,
child
.
DesiredSize
.
Height
);
_fixedWidth
+=
child
.
DesiredSize
.
Width
+
gutter
;
}
}
if
(
cellCount
==
0
||
child
.
IsFixed
)
var
itemWidth
=
(
constraint
.
Width
-
_fixedWidth
+
gutter
)
/
ColLayout
.
ColMaxCellCount
;
itemWidth
=
Math
.
Max
(
0
,
itemWidth
);
foreach
(
var
child
in
cols
)
{
var
cellCount
=
child
.
GetLayoutCellCount
(
_layoutStatus
);
if
(
cellCount
>
0
&&
!
child
.
IsFixed
)
{
_totalAutoWidth
+=
childDesiredSize
.
Width
;
totalCellCount
+=
cellCount
;
child
.
Measure
(
new
Size
(
cellCount
*
itemWidth
-
gutter
,
constraint
.
Height
));
_maxChildDesiredHeight
=
Math
.
Max
(
_maxChildDesiredHeight
,
child
.
DesiredSize
.
Height
);
if
(
totalCellCount
>
ColLayout
.
ColMaxCellCount
)
{
totalCellCount
=
cellCount
;
totalRowCount
++;
}
}
}
return
new
Size
(
0
,
_maxChildDesiredHeight
*
totalRowCount
-
Gutter
);
return
new
Size
(
0
,
_maxChildDesiredHeight
*
totalRowCount
);
}
protected
override
Size
ArrangeOverride
(
Size
finalSize
)
{
var
gutter
=
Gutter
;
var
totalCellCount
=
0
;
var
gutterHalf
=
Gutter
/
2
;
var
itemWidth
=
(
finalSize
.
Width
-
_
totalAutoWidth
+
G
utter
)
/
ColLayout
.
ColMaxCellCount
;
var
cols
=
InternalChildren
.
OfType
<
Col
>().
ToList
()
;
var
itemWidth
=
(
finalSize
.
Width
-
_
fixedWidth
+
g
utter
)
/
ColLayout
.
ColMaxCellCount
;
itemWidth
=
Math
.
Max
(
0
,
itemWidth
);
var
childBounds
=
new
Rect
(
-
gutterHalf
,
-
gutterHalf
,
0
,
_maxChildDesiredHeight
);
var
childBounds
=
new
Rect
(
0
,
0
,
0
,
_maxChildDesiredHeight
);
_layoutStatus
=
ColLayout
.
GetLayoutStatus
(
finalSize
.
Width
);
foreach
(
var
child
in
InternalChildren
.
OfType
<
Col
>()
)
foreach
(
var
child
in
cols
)
{
if
(!
child
.
IsVisible
)
{
...
...
@@ -83,19 +94,19 @@ public class Row : Panel
var
cellCount
=
child
.
GetLayoutCellCount
(
_layoutStatus
);
totalCellCount
+=
cellCount
;
var
childWidth
=
cellCount
>
0
?
cellCount
*
itemWidth
:
child
.
DesiredSize
.
Width
;
var
childWidth
=
(
cellCount
>
0
&&
!
child
.
IsFixed
)
?
cellCount
*
itemWidth
-
gutter
:
child
.
DesiredSize
.
Width
;
childBounds
.
Width
=
childWidth
;
childBounds
.
X
+=
child
.
Offset
*
itemWidth
;
if
(
totalCellCount
>
ColLayout
.
ColMaxCellCount
)
{
childBounds
.
X
=
-
gutterHalf
;
childBounds
.
X
=
0
;
childBounds
.
Y
+=
_maxChildDesiredHeight
;
totalCellCount
=
cellCount
;
}
child
.
Arrange
(
childBounds
);
childBounds
.
X
+=
childWidth
;
childBounds
.
X
+=
childWidth
+
gutter
;
}
return
finalSize
;
...
...
src/Shared/HandyControl_Shared/Themes/Styles/Base/DividerBaseStyle.xaml
浏览文件 @
81ddae5f
...
...
@@ -16,7 +16,7 @@
<hc:Col Layout="12" x:Name="ColStart">
<Line VerticalAlignment="Center" StrokeDashArray="{TemplateBinding LineStrokeDashArray}" Stroke="{TemplateBinding LineStroke}" X2="1" StrokeThickness="{TemplateBinding LineStrokeThickness}" Stretch="Fill" StrokeEndLineCap="Square" StrokeStartLineCap="Square"/>
</hc:Col>
<hc:Col
Layout="0
">
<hc:Col
IsFixed="True
">
<ContentPresenter Margin="{TemplateBinding Padding}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}"/>
</hc:Col>
<hc:Col Layout="12" x:Name="ColEnd">
...
...
@@ -60,4 +60,4 @@
</Style.Triggers>
</Style>
</ResourceDictionary>
\ No newline at end of file
</ResourceDictionary>
src/Shared/HandyControl_Shared/Themes/Theme.xaml
浏览文件 @
81ddae5f
...
...
@@ -8701,7 +8701,7 @@
<hc:Col Layout="12" x:Name="ColStart">
<Line VerticalAlignment="Center" StrokeDashArray="{TemplateBinding LineStrokeDashArray}" Stroke="{TemplateBinding LineStroke}" X2="1" StrokeThickness="{TemplateBinding LineStrokeThickness}" Stretch="Fill" StrokeEndLineCap="Square" StrokeStartLineCap="Square" />
</hc:Col>
<hc:Col
Layout="0
">
<hc:Col
IsFixed="True
">
<ContentPresenter Margin="{TemplateBinding Padding}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" ContentStringFormat="{TemplateBinding ContentStringFormat}" ContentTemplate="{TemplateBinding ContentTemplate}" />
</hc:Col>
<hc:Col Layout="12" x:Name="ColEnd">
...
...
src/Shared/HandyControl_Shared/Tools/Extension/ColLayout.cs
浏览文件 @
81ddae5f
...
...
@@ -11,19 +11,19 @@ namespace HandyControl.Tools.Extension;
[
TypeConverter
(
typeof
(
ColLayoutConverter
))]
public
class
ColLayout
:
MarkupExtension
{
public
static
readonly
int
ColMaxCellCount
=
24
;
public
const
int
ColMaxCellCount
=
24
;
public
static
readonly
int
HalfColMaxCellCount
=
12
;
public
const
int
HalfColMaxCellCount
=
12
;
public
static
readonly
int
XsMaxWidth
=
768
;
public
const
int
XsMaxWidth
=
768
;
public
static
readonly
int
SmMaxWidth
=
992
;
public
const
int
SmMaxWidth
=
992
;
public
static
readonly
int
MdMaxWidth
=
1200
;
public
const
int
MdMaxWidth
=
1200
;
public
static
readonly
int
LgMaxWidth
=
1920
;
public
const
int
LgMaxWidth
=
1920
;
public
static
readonly
int
XlMaxWidth
=
2560
;
public
const
int
XlMaxWidth
=
2560
;
public
int
Xs
{
get
;
set
;
}
=
24
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录