add ColLayoutConverter
This commit is contained in:
1 parent
6e1d294202
commit
1bfa5b6854
5 files changed
+452
-2
No files matched your search
@@ -1,9 +1,14 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using System.Windows.Markup;
|
||||
using HandyControl.Data;
|
||||
using HandyControl.Tools.Converter;
|
||||
|
||||
namespace HandyControl.Tools.Extension
|
||||
{
|
||||
[TypeConverter(typeof(ColLayoutConverter))]
|
||||
public class ColLayout : MarkupExtension
|
||||
{
|
||||
public static readonly int ColMaxCellCount = 24;
|
||||
@@ -30,6 +35,31 @@ namespace HandyControl.Tools.Extension
|
||||
|
||||
public int Xxl { get; set; } = 2;
|
||||
|
||||
public ColLayout()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public ColLayout(int uniformWidth)
|
||||
{
|
||||
Xs = uniformWidth;
|
||||
Sm = uniformWidth;
|
||||
Md = uniformWidth;
|
||||
Lg = uniformWidth;
|
||||
Xl = uniformWidth;
|
||||
Xxl = uniformWidth;
|
||||
}
|
||||
|
||||
public ColLayout(int xs, int sm, int md, int lg, int xl, int xxl)
|
||||
{
|
||||
Xs = xs;
|
||||
Sm = sm;
|
||||
Md = md;
|
||||
Lg = lg;
|
||||
Xl = xl;
|
||||
Xxl = xxl;
|
||||
}
|
||||
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
return new ColLayout
|
||||
@@ -67,5 +97,29 @@ namespace HandyControl.Tools.Extension
|
||||
}
|
||||
return ColLayoutStatus.Xxl;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
var cultureInfo = CultureInfo.CurrentCulture;
|
||||
var listSeparator = TokenizerHelper.GetNumericListSeparator(cultureInfo);
|
||||
|
||||
// Initial capacity [128] is an estimate based on a sum of:
|
||||
// 72 = 6x double (twelve digits is generous for the range of values likely)
|
||||
// 4 = 4x separator characters
|
||||
var sb = new StringBuilder(128);
|
||||
|
||||
sb.Append(Xs.ToString(cultureInfo));
|
||||
sb.Append(listSeparator);
|
||||
sb.Append(Sm.ToString(cultureInfo));
|
||||
sb.Append(listSeparator);
|
||||
sb.Append(Md.ToString(cultureInfo));
|
||||
sb.Append(listSeparator);
|
||||
sb.Append(Lg.ToString(cultureInfo));
|
||||
sb.Append(listSeparator);
|
||||
sb.Append(Xl.ToString(cultureInfo));
|
||||
sb.Append(listSeparator);
|
||||
sb.Append(Xxl.ToString(cultureInfo));
|
||||
return sb.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user