117 lines
4.0 KiB
C#
117 lines
4.0 KiB
C#
using DrawGraph;
|
|
using System;
|
|
using System.Reflection;
|
|
using System.Windows.Forms;
|
|
|
|
namespace DrawGraphManagement.MyUserControl
|
|
{
|
|
public class UCSelect : UCBase
|
|
{
|
|
|
|
//PackObjBase selectPoB = null;
|
|
|
|
public UCSelect(PackObjBase pob)
|
|
{
|
|
selectPoB = pob;
|
|
}
|
|
|
|
|
|
public override Panel GreatPropertyPanel(PropertyInfo info)
|
|
{
|
|
if (selectPoB == null) return null;
|
|
|
|
System.Windows.Forms.Panel panel;
|
|
System.Windows.Forms.Label label;
|
|
System.Windows.Forms.ComboBox comboBox1;
|
|
|
|
panel = new System.Windows.Forms.Panel();
|
|
label = new System.Windows.Forms.Label();
|
|
comboBox1 = new System.Windows.Forms.ComboBox();
|
|
// comboBox1
|
|
//
|
|
comboBox1.FormattingEnabled = true;
|
|
comboBox1.Location = new System.Drawing.Point(435, 4);
|
|
comboBox1.Dock = DockStyle.Left;
|
|
comboBox1.Name = "comboBox" + selectPoB.PackTag;
|
|
comboBox1.Size = new System.Drawing.Size(121, 20);
|
|
comboBox1.Tag = info.Name;
|
|
comboBox1.Items.Clear();
|
|
foreach (string v in datasource)
|
|
{
|
|
comboBox1.Items.Add(v);
|
|
}
|
|
Enum ltype = (Enum)info.GetValue(selectPoB, null);
|
|
comboBox1.Text = ltype.ToString();
|
|
comboBox1.TabIndex = 4;
|
|
comboBox1.SelectedValueChanged += new EventHandler(ComboBox1_SelectedValueChanged);
|
|
|
|
label.AutoSize = true;
|
|
label.Dock = System.Windows.Forms.DockStyle.Left;
|
|
label.Name = "label" + selectPoB.PackTag;
|
|
label.Size = new System.Drawing.Size(41, 12);
|
|
label.TabIndex = 0;
|
|
|
|
string cName = info.Name;
|
|
object[] bookarr = info.GetCustomAttributes(typeof(ClassAttributs), false);
|
|
if (bookarr.Length > 0)
|
|
{
|
|
ClassAttributs bookattribute1 = (ClassAttributs)bookarr[0];
|
|
if (bookattribute1.CName != null)
|
|
{
|
|
cName = bookattribute1.CName;
|
|
}
|
|
if (bookattribute1.Description != null)
|
|
{
|
|
base.toolTip1.SetToolTip(label, bookattribute1.Description.ToString());
|
|
}
|
|
}
|
|
label.Text = cName;
|
|
|
|
panel = new System.Windows.Forms.Panel();
|
|
panel.Dock = DockStyle.Top;
|
|
panel.Controls.Add(comboBox1);
|
|
panel.Controls.Add(label);
|
|
panel.Location = new System.Drawing.Point(3, 6);
|
|
panel.Name = "panel" + selectPoB.PackTag; ;
|
|
panel.Size = new System.Drawing.Size(200, 27);
|
|
panel.TabIndex = 0;
|
|
|
|
return panel;
|
|
}
|
|
|
|
void ComboBox1_SelectedValueChanged(object sender, EventArgs e)
|
|
{
|
|
if (selectPoB == null) return;
|
|
|
|
System.Windows.Forms.ComboBox cbb = (sender as System.Windows.Forms.ComboBox);
|
|
try
|
|
{
|
|
foreach (PropertyInfo p in selectPoB.GetType().GetProperties())
|
|
{
|
|
if (cbb.Tag.ToString() == p.Name)
|
|
{
|
|
MovePackObjCommand cmd = new MovePackObjCommand(CommandManage.GetInstance.AreaManage, selectPoB);
|
|
cmd.PreExecute();
|
|
object value = Enum.Parse(p.PropertyType, cbb.Text.ToString(), false);
|
|
p.SetValue(selectPoB, Convert.ChangeType(value, p.PropertyType), null);
|
|
cmd.LastExecute();
|
|
CommandManage.GetInstance.AddCommand(cmd);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception )
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
if (selectPoB != null)
|
|
{
|
|
selectPoB.Draw();
|
|
onChangeValue(selectPoB, e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|