enhance: optimize input elements.

This commit is contained in:
NaBian committed 2023-01-29 23:49:17 +08:00
1 parent 322e3669c2
commit 8e707a66a9
52 files changed
+5095 -7090

No files matched your search

@@ -14,13 +14,35 @@ public class ThicknessSplitConverter : IValueConverter
if (parameter is string str)
{
var arr = str.Split(',');
if (arr.Length != 4) return thickness;
return new Thickness(
arr[0].Equals("1") ? thickness.Left : 0,
arr[1].Equals("1") ? thickness.Top : 0,
arr[2].Equals("1") ? thickness.Right : 0,
arr[3].Equals("1") ? thickness.Bottom : 0);
if (arr.Length != 4)
{
return thickness;
}
var result = new Thickness(thickness.Left, thickness.Top, thickness.Right, thickness.Bottom);
if (double.TryParse(arr[0], out double leftTimes))
{
result.Left = leftTimes * thickness.Left;
}
if (double.TryParse(arr[1], out double topTimes))
{
result.Top = topTimes * thickness.Top;
}
if (double.TryParse(arr[2], out double rightTimes))
{
result.Right = rightTimes * thickness.Right;
}
if (double.TryParse(arr[3], out double bottomTimes))
{
result.Bottom = bottomTimes * thickness.Bottom;
}
return result;
}
}
return value;