CycleHYControl.cs
2.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
using DeviceLibrary;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace TheMachine
{
public partial class CycleHYControl<T1> : UserControl where T1: UserControl, Idevicetab,new()
{
public CycleHYControl()
{
InitializeComponent();
}
List<T1> hYControls = new List<T1>();
public string DeviceName = "";
public void Init(string devicegroup) {
tabControl1.TabPages.Clear();
foreach (var dg in RobotManage.DeviceGroup.Values) {
if (dg.DeviceType != devicegroup)
continue;
if (string.IsNullOrEmpty(DeviceName))
DeviceName = dg.Name;
var hy = new T1();
hy.Init(dg.GroupName);
hYControls.Add(hy);
AddForm(dg.GroupName, dg.GroupName, hy);
}
}
private void AddForm(string id, string text, UserControl form)
{
foreach (TabPage tp in tabControl1.TabPages)
{
if (tp.Name == id)
{
tp.Text = text;
return;
}
}
TabPage lineTabPage = new TabPage(text);
lineTabPage.Name = id;
Panel linePan = new Panel();
linePan.Dock = DockStyle.Fill;
linePan.AutoScroll = true;
lineTabPage.Controls.Add(linePan);
linePan.Controls.Add(form);
form.Dock = DockStyle.Fill;
linePan.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Anchor = ((AnchorStyles)((AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom | AnchorStyles.Left)));
form.Show();
tabControl1.TabPages.Add(lineTabPage);
}
}
}