优化轴属性界面,改成自适应布局

master
lhiven 10 months ago
parent a0aa68371f
commit 17d22a1608

File diff suppressed because it is too large Load Diff

@ -41,27 +41,40 @@ namespace Rs.MotionPlat
m_axisProControls.Clear(); m_axisProControls.Clear();
foreach (Control ctl in gboxCardProperty.Controls) foreach (Control ctl in gboxCardProperty.Controls)
{ {
if (ctl != null && ctl is TextBox) AddTextControl(ctl);
{
m_axisProControls.Add((TextBox)ctl);
}
} }
foreach (Control ctl in gboxHomePro.Controls) foreach (Control ctl in gboxHomePro.Controls)
{ {
if (ctl != null && ctl is TextBox) AddTextControl(ctl);
{
m_axisProControls.Add((TextBox)ctl);
}
} }
foreach (Control ctl in gboxMotorPro.Controls) foreach (Control ctl in gboxMotorPro.Controls)
{ {
if (ctl != null && ctl is TextBox) AddTextControl(ctl);
{ }
m_axisProControls.Add((TextBox)ctl); }
}
else if(ctl!=null && ctl is CheckBox) void AddTextControl(Control control)
{
if (control != null && control.Controls.Count > 0)
{
foreach (Control item in control.Controls)
{ {
m_axisProControls.Add(ctl); if (item != null && item.Controls.Count > 0)
{
foreach (Control subItem in item.Controls)
{
if (subItem != null && subItem is TextBox)
{
m_axisProControls.Add((TextBox)subItem);
}
else if (subItem != null && subItem is CheckBox)
{
m_axisProControls.Add(subItem);
}
}
}
} }
} }
} }
@ -132,6 +145,57 @@ namespace Rs.MotionPlat
} }
void DataBind()
{
foreach (Control ctl in m_axisProControls)
{
if (ctl != null && ctl is TextBox)
{
try
{
ctl.DataBindings.Clear();
ctl.DataBindings.Add("Text", m_axis.Config, ctl.Name.Replace("txt", ""));
ctl.MouseLeave += (s, e) => {
TextBox tbox = (TextBox)s;
m_tip.Hide(tbox);
};
ctl.MouseHover += (s, e) => {
TextBox tbox = (TextBox)s;
//获取这个轴属性的自定义属性
Type type = m_axis.Config.GetType();
ZTMPropertyDescriptionAttribute ztmPro = type.GetProperty(tbox.Name.Replace("txt", "")).GetCustomAttribute<ZTMPropertyDescriptionAttribute>();
if (ztmPro == null)
{
CommonPropertyDescriptionAttribute pro = type.GetProperty(tbox.Name.Replace("txt", "")).GetCustomAttribute<CommonPropertyDescriptionAttribute>();
if (pro != null)
{
//m_tip.SetToolTip(tbox, pro.Description);
m_tip.Show(pro.Description, ctl, 60 * 1000);
}
}
else
{
//m_tip.SetToolTip(tbox, ztmPro.Description);
m_tip.Show(ztmPro.Description, ctl, 60 * 1000);
}
};
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
else if (ctl != null && ctl is CheckBox)
{
ctl.DataBindings.Clear();
ctl.DataBindings.Add("Checked", m_axis.Config, "CanJogMove");
}
}
}
private void Ctl_GotFocus(object sender, EventArgs e) private void Ctl_GotFocus(object sender, EventArgs e)
{ {

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save