51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using DevExpress.XtraEditors;
|
|
using DevExpress.XtraEditors.Controls;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UI.Framework.Entitys;
|
|
using static PDDCircleFriends.Enums;
|
|
|
|
namespace PDDCircleFriends.Controls
|
|
{
|
|
class CategoryControl : PropertyGridEditStyle
|
|
{
|
|
public CategoryControl()
|
|
{
|
|
var listBox = new CheckedListBoxControl();
|
|
foreach (CategoryType item in Enum.GetValues(typeof(CategoryType)))
|
|
{
|
|
listBox.Items.Add(new CheckedListBoxItem(null, item.ToString()));
|
|
}
|
|
Control = listBox;
|
|
}
|
|
|
|
public override string GetValue()
|
|
{
|
|
var listBox = Control as CheckedListBoxControl;
|
|
string[] strs = new string[listBox.CheckedItems.Count];
|
|
int i = 0;
|
|
foreach (var item in listBox.CheckedItems)
|
|
{
|
|
strs[i] = item.ToString();
|
|
i++;
|
|
}
|
|
return string.Join(",", strs);
|
|
}
|
|
|
|
public override void SetValue(object value)
|
|
{
|
|
var listBox = Control as CheckedListBoxControl;
|
|
var strs = value.ToString().Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
|
|
int i = 0;
|
|
foreach (var item in listBox.Items)
|
|
{
|
|
listBox.SetItemChecked(i, !string.IsNullOrEmpty(strs.FirstOrDefault(f => f == item.ToString())));
|
|
i++;
|
|
}
|
|
}
|
|
|
|
}
|
|
} |