-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDockList.cs
152 lines (129 loc) · 4.38 KB
/
DockList.cs
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace KCB2
{
public partial class DockList : UserControl
{
public DockList()
{
InitializeComponent();
tableLayoutPanel1.DoubleBuffer(true);
}
public void SetOpenDockCount(int nDockCount)
{
if (InvokeRequired)
BeginInvoke((MethodInvoker)(() => _setControlTextColor(nDockCount)));
else
_setControlTextColor(nDockCount);
}
private void _setControlTextColor(int nDockCount)
{
lblDock4.ForeColor = SystemColors.Control;
lblTime4.ForeColor = SystemColors.Control;
lblDock3.ForeColor = SystemColors.Control;
lblTime3.ForeColor = SystemColors.Control;
lblDock2.ForeColor = SystemColors.Control;
lblTime2.ForeColor = SystemColors.Control;
lblDock1.ForeColor = SystemColors.Control;
lblTime1.ForeColor = SystemColors.Control;
switch (nDockCount)
{
case 4:
lblDock4.ForeColor = SystemColors.ControlText;
lblTime4.ForeColor = SystemColors.ControlText;
goto case 3;
case 3:
lblDock3.ForeColor = SystemColors.ControlText;
lblTime3.ForeColor = SystemColors.ControlText;
goto case 2;
case 2:
lblDock2.ForeColor = SystemColors.ControlText;
lblTime2.ForeColor = SystemColors.ControlText;
goto case 1;
case 1:
lblDock1.ForeColor = SystemColors.ControlText;
lblTime1.ForeColor = SystemColors.ControlText;
break;
}
}
public class DockItem
{
public string Name { get; private set; }
public DateTime Finish { get; private set; }
public bool Vacant { get; private set; }
public int Order { get; private set; }
public DockItem(MemberData.Dock.DockInfo dat)
{
Name = dat.Name;
Finish = dat.Finish;
Vacant = dat.Vacant;
Order = dat.Order;
}
}
public void UpdateDockList(IEnumerable<MemberData.Dock.DockInfo> dockData)
{
List<DockItem> items = new List<DockItem>();
lock (dockData)
{
foreach (var it in dockData)
{
items.Add(new DockItem(it));
}
}
if (InvokeRequired)
BeginInvoke((MethodInvoker)(() => updateDockList(items)));
else
updateDockList(items);
}
void updateDockList(IEnumerable<DockItem> items)
{
foreach (var it in items)
updateDockListItem(it.Order, it);
}
void updateDockListItem(int slot,DockItem item)
{
CountdownLabel lblTime;
Label lblDock;
switch (slot)
{
case 1:
lblTime = lblTime1;
lblDock = lblDock1;
break;
case 2:
lblTime = lblTime2;
lblDock = lblDock2;
break;
case 3:
lblTime = lblTime3;
lblDock = lblDock3;
break;
case 4:
lblTime = lblTime4;
lblDock = lblDock4;
break;
default:
throw new ArgumentOutOfRangeException("unknown dock:"+slot.ToString());
}
if (item.Vacant)
{
lblDock.Text = string.Format("ドック{0}", slot);
lblTime.Valid = false;
toolTip1.SetToolTip(lblTime, null);
}
else
{
lblDock.Text = item.Name;
lblTime.FinishTime = item.Finish;
toolTip1.SetToolTip(lblTime, item.Finish.ToString());
lblTime.Valid = true;
}
}
}
}