推送
This commit is contained in:
1
DHSoftware/Views/AddCameraControl.Designer.cs
generated
1
DHSoftware/Views/AddCameraControl.Designer.cs
generated
@ -128,6 +128,7 @@
|
||||
button_ok.TabIndex = 0;
|
||||
button_ok.Text = "确定";
|
||||
button_ok.Type = AntdUI.TTypeMini.Primary;
|
||||
|
||||
//
|
||||
// divider2
|
||||
//
|
||||
|
1
DHSoftware/Views/AddMotionControl.Designer.cs
generated
1
DHSoftware/Views/AddMotionControl.Designer.cs
generated
@ -118,6 +118,7 @@
|
||||
button_ok.TabIndex = 0;
|
||||
button_ok.Text = "确定";
|
||||
button_ok.Type = AntdUI.TTypeMini.Primary;
|
||||
|
||||
//
|
||||
// divider2
|
||||
//
|
||||
|
@ -96,6 +96,7 @@
|
||||
button_ok.TabIndex = 0;
|
||||
button_ok.Text = "确定";
|
||||
button_ok.Type = AntdUI.TTypeMini.Primary;
|
||||
|
||||
//
|
||||
// divider1
|
||||
//
|
||||
|
@ -97,6 +97,7 @@ namespace DHSoftware.Views
|
||||
Font = new System.Drawing.Font("Microsoft YaHei UI", 9F),
|
||||
Size = new Size(90, 42),
|
||||
Text = name,
|
||||
ForeColor = Color.FromArgb(61, 94, 218)
|
||||
};
|
||||
foreach (var item in Cameras)
|
||||
{
|
||||
|
2
DHSoftware/Views/SettingWindow.Designer.cs
generated
2
DHSoftware/Views/SettingWindow.Designer.cs
generated
@ -48,7 +48,7 @@
|
||||
//
|
||||
// pageHeader1
|
||||
//
|
||||
pageHeader1.BackColor = SystemColors.MenuHighlight;
|
||||
pageHeader1.BackColor = Color.FromArgb(46, 108, 227);
|
||||
pageHeader1.Dock = DockStyle.Top;
|
||||
pageHeader1.Location = new Point(0, 0);
|
||||
pageHeader1.Mode = AntdUI.TAMode.Dark;
|
||||
|
@ -25,8 +25,152 @@ namespace DHSoftware.Views
|
||||
Resize += SettingWindow1_Resize;
|
||||
btnAdd.SelectedValueChanged += btnAdd_SelectedValueChanged;
|
||||
btnSave.Click += BtnSave_Click;
|
||||
menu1.SelectChanged += Menu1_SelectChanged;
|
||||
|
||||
}
|
||||
|
||||
private void Menu1_SelectChanged(object sender, MenuSelectEventArgs e)
|
||||
{
|
||||
|
||||
MenuItem clickedItem = e.Value;
|
||||
|
||||
if (clickedItem != null)
|
||||
{
|
||||
if (clickedItem.PARENTITEM == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (clickedItem.PARENTITEM.Text)
|
||||
{
|
||||
case "相机设置":
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//先获取是否存在该名称的配置
|
||||
//如果没有新建项
|
||||
CameraBase? CameraBase = ConfigModel.CameraBaseList.Where(c => c.CameraName == clickedItem.Text).FirstOrDefault();
|
||||
if (CameraBase == null)
|
||||
{
|
||||
CameraBase = new CameraBase();
|
||||
}
|
||||
UserControl control = null;
|
||||
control = new CameraControl(this, CameraBase);
|
||||
if (control != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control.Dock = DockStyle.Fill;
|
||||
AutoDpi(control);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control;
|
||||
}
|
||||
break;
|
||||
case "工位设置":
|
||||
// 检查是否已存在同名 TabPage
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
DetectionConfig? detectionConfig = ConfigModel.DetectionList.Where(c => c.Name == clickedItem.Text).FirstOrDefault();
|
||||
if (detectionConfig == null)
|
||||
{
|
||||
detectionConfig = new DetectionConfig();
|
||||
}
|
||||
UserControl control1 = null;
|
||||
control1 = new DetectControl(this, detectionConfig);
|
||||
if (control1 != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control1.Dock = DockStyle.Fill;
|
||||
AutoDpi(control1);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control1);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control1;
|
||||
}
|
||||
break;
|
||||
|
||||
case "运控设置":
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//先获取是否存在该名称的配置
|
||||
//如果没有新建项
|
||||
PLCBase? pLCBase = ConfigModel.PLCBaseList.Where(c => c.PLCName == clickedItem.Text).FirstOrDefault();
|
||||
if (pLCBase == null)
|
||||
{
|
||||
pLCBase = new PLCBase();
|
||||
}
|
||||
UserControl control2 = null;
|
||||
control = new MotionControl(this, pLCBase);
|
||||
if (control != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control.Dock = DockStyle.Fill;
|
||||
AutoDpi(control);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private float x; //定义当前窗体的宽度
|
||||
private float y; //定义当前窗体的高度
|
||||
private void InitData()
|
||||
@ -139,150 +283,7 @@ namespace DHSoftware.Views
|
||||
private void menu1_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
// 转换坐标到控件内部坐标系(考虑滚动条)
|
||||
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
|
||||
|
||||
// 递归查找命中的菜单项
|
||||
MenuItem clickedItem = FindClickedItem(menu1.Items, clickPoint);
|
||||
|
||||
if (clickedItem != null)
|
||||
{
|
||||
if (clickedItem.PARENTITEM == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (clickedItem.PARENTITEM.Text)
|
||||
{
|
||||
case "相机设置":
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//先获取是否存在该名称的配置
|
||||
//如果没有新建项
|
||||
CameraBase? CameraBase= ConfigModel.CameraBaseList.Where(c => c.CameraName == clickedItem.Text).FirstOrDefault();
|
||||
if (CameraBase == null)
|
||||
{
|
||||
CameraBase=new CameraBase();
|
||||
}
|
||||
UserControl control = null;
|
||||
control = new CameraControl(this, CameraBase);
|
||||
if (control != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control.Dock = DockStyle.Fill;
|
||||
AutoDpi(control);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control;
|
||||
}
|
||||
break;
|
||||
case "工位设置":
|
||||
// 检查是否已存在同名 TabPage
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
DetectionConfig? detectionConfig = ConfigModel.DetectionList.Where(c => c.Name == clickedItem.Text).FirstOrDefault();
|
||||
if (detectionConfig == null)
|
||||
{
|
||||
detectionConfig = new DetectionConfig();
|
||||
}
|
||||
UserControl control1 = null;
|
||||
control1 = new DetectControl(this, detectionConfig);
|
||||
if (control1 != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control1.Dock = DockStyle.Fill;
|
||||
AutoDpi(control1);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false ,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control1);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control1;
|
||||
}
|
||||
break;
|
||||
|
||||
case "运控设置":
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//先获取是否存在该名称的配置
|
||||
//如果没有新建项
|
||||
PLCBase? pLCBase = ConfigModel.PLCBaseList.Where(c => c.PLCName == clickedItem.Text).FirstOrDefault();
|
||||
if (pLCBase == null)
|
||||
{
|
||||
pLCBase = new PLCBase();
|
||||
}
|
||||
UserControl control2 = null;
|
||||
control = new MotionControl(this, pLCBase);
|
||||
if (control != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control.Dock = DockStyle.Fill;
|
||||
AutoDpi(control);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
|
||||
// 转换坐标到控件内部坐标系(考虑滚动条)
|
||||
|
Reference in New Issue
Block a user