📄 groupcategory.cs
字号:
namespace Imps.Client.Pc
{
using Imps.Client.Core;
using Imps.Client.Pc.Controls;
using Imps.Client.Resource;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
public class GroupCategory : UserControl
{
private Dictionary<PersonalGroupCategory.Category, List<PersonalGroupCategory.Category>> _categorys;
private IFrameworkWindow _framework;
private bool _unselected;
private IContainer components;
public XComboBox xcmbCategoryOne;
public XComboBox xcmbCategoryTwo;
public GroupCategory()
{
this.InitializeComponent();
}
protected override void Dispose(bool disposing)
{
if (disposing && (this.components != null))
{
this.components.Dispose();
}
base.Dispose(disposing);
}
private void InitializeComponent()
{
this.xcmbCategoryTwo = new XComboBox();
this.xcmbCategoryOne = new XComboBox();
base.SuspendLayout();
this.xcmbCategoryTwo.BackColor = Color.White;
this.xcmbCategoryTwo.DisplayMember = "Name";
this.xcmbCategoryTwo.DropDownStyle = ComboBoxStyle.DropDownList;
this.xcmbCategoryTwo.EmptyTextTip = "";
this.xcmbCategoryTwo.EmptyTextTipColor = Color.DarkGray;
this.xcmbCategoryTwo.set_FormattingEnabled(true);
this.xcmbCategoryTwo.Location = new System.Drawing.Point(0x4f, 3);
this.xcmbCategoryTwo.Name = "xcmbCategoryTwo";
this.xcmbCategoryTwo.Size = new Size(100, 0x15);
this.xcmbCategoryTwo.TabIndex = 6;
this.xcmbCategoryOne.BackColor = Color.White;
this.xcmbCategoryOne.DisplayMember = "Name";
this.xcmbCategoryOne.DropDownStyle = ComboBoxStyle.DropDownList;
this.xcmbCategoryOne.EmptyTextTip = "";
this.xcmbCategoryOne.EmptyTextTipColor = Color.DarkGray;
this.xcmbCategoryOne.set_FormattingEnabled(true);
this.xcmbCategoryOne.Location = new System.Drawing.Point(0, 3);
this.xcmbCategoryOne.Name = "xcmbCategoryOne";
this.xcmbCategoryOne.Size = new Size(70, 0x15);
this.xcmbCategoryOne.TabIndex = 5;
this.xcmbCategoryOne.SelectedIndexChanged += new EventHandler(this.xcmbCategoryOne_SelectedIndexChanged);
base.set_AutoScaleDimensions(new SizeF(6f, 13f));
base.set_AutoScaleMode(1);
this.BackColor = Color.Transparent;
base.Controls.Add(this.xcmbCategoryTwo);
base.Controls.Add(this.xcmbCategoryOne);
base.Name = "GroupCategory";
base.Size = new Size(0xb5, 0x23);
base.ResumeLayout(false);
}
private void xcmbCategoryOne_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.xcmbCategoryOne.SelectedItem != null)
{
this.xcmbCategoryTwo.Items.Clear();
PersonalGroupCategory.Category category = this.xcmbCategoryOne.SelectedItem as PersonalGroupCategory.Category;
if (this._unselected)
{
PersonalGroupCategory.Category item = new PersonalGroupCategory.Category();
item.Id = "-1";
item.Name = "-请选择-";
item.Parent = category;
this.xcmbCategoryTwo.Items.Add(item);
}
if (this._categorys.ContainsKey(category))
{
List<PersonalGroupCategory.Category>.Enumerator enumerator = this._categorys.get_Item(this.xcmbCategoryOne.SelectedItem as PersonalGroupCategory.Category).GetEnumerator();
try
{
while (enumerator.MoveNext())
{
PersonalGroupCategory.Category category3 = enumerator.get_Current();
this.xcmbCategoryTwo.Items.Add(category3);
}
}
finally
{
enumerator.Dispose();
}
}
if (this.xcmbCategoryTwo.Items.Count > 0)
{
this.xcmbCategoryTwo.SelectedIndex = 0;
}
}
}
public Dictionary<PersonalGroupCategory.Category, List<PersonalGroupCategory.Category>> Categorys
{
set
{
this._categorys = value;
this.xcmbCategoryOne.DataSource = null;
this.xcmbCategoryTwo.DataSource = null;
this.xcmbCategoryOne.Items.Clear();
this.xcmbCategoryTwo.Items.Clear();
new List<PersonalGroupCategory.Category>();
if (this._unselected)
{
PersonalGroupCategory.Category item = new PersonalGroupCategory.Category();
item.Id = "-1";
item.Name = "-请选择-";
this.xcmbCategoryOne.Items.Add(item);
}
int length = 1;
Dictionary<PersonalGroupCategory.Category, List<PersonalGroupCategory.Category>>.KeyCollection.Enumerator enumerator = value.get_Keys().GetEnumerator();
try
{
while (enumerator.MoveNext())
{
PersonalGroupCategory.Category category2 = enumerator.get_Current();
this.xcmbCategoryOne.Items.Add(category2);
if (category2.Name.Length > length)
{
length = category2.Name.Length;
}
}
}
finally
{
enumerator.Dispose();
}
if (this.xcmbCategoryOne.Items.Count > 0)
{
this.xcmbCategoryOne.SelectedIndex = 0;
}
int num2 = length * 20;
if (num2 >= base.Width)
{
this.xcmbCategoryOne.Width = (base.Width / 2) - 5;
}
else
{
this.xcmbCategoryOne.Width = num2;
}
this.xcmbCategoryTwo.Width = (base.Width - this.xcmbCategoryOne.Width) - 5;
this.xcmbCategoryTwo.Left = this.xcmbCategoryOne.Right + 5;
}
}
public bool Unselected
{
set
{
this._unselected = value;
if (this._unselected)
{
this.xcmbCategoryOne.SelectedItem = null;
this.xcmbCategoryTwo.SelectedItem = null;
this.xcmbCategoryOne.Text = StringTable.GroupCategory.PleaseSelect;
this.xcmbCategoryTwo.Text = StringTable.GroupCategory.PleaseSelect;
}
}
}
public string Value
{
get
{
PersonalGroupCategory.Category category = this.xcmbCategoryTwo.SelectedItem as PersonalGroupCategory.Category;
if ((category != null) && (category.Id != "-1"))
{
return category.Id;
}
category = this.xcmbCategoryOne.SelectedItem as PersonalGroupCategory.Category;
if (category != null)
{
return category.Id;
}
return "-1";
}
set
{
if (value != "-1")
{
Dictionary<PersonalGroupCategory.Category, List<PersonalGroupCategory.Category>>.KeyCollection.Enumerator enumerator = this._categorys.get_Keys().GetEnumerator();
try
{
while (enumerator.MoveNext())
{
PersonalGroupCategory.Category category = enumerator.get_Current();
if (category.Id == value)
{
this.xcmbCategoryOne.SelectedItem = category;
return;
}
List<PersonalGroupCategory.Category>.Enumerator enumerator2 = this._categorys.get_Item(category).GetEnumerator();
try
{
while (enumerator2.MoveNext())
{
PersonalGroupCategory.Category category2 = enumerator2.get_Current();
if (category2.Id == value)
{
this.xcmbCategoryOne.SelectedItem = category;
this.xcmbCategoryTwo.SelectedItem = category2;
break;
}
}
continue;
}
finally
{
enumerator2.Dispose();
}
}
}
finally
{
enumerator.Dispose();
}
}
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -