frm_Main.cs
4.6 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
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
using HHWCS.Common;
using HHWCS.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace HHWCS.View
{
public partial class Frm_Main : Form
{
#region 属性
public User user { get; set; }
#endregion
#region 子窗体定义
/// <summary>
/// 任务信息
/// </summary>
private Frm_TaskInfo frm_TaskInfo { get; set; }
private Frm_Control frm_Control { get; set; }
#endregion
public Frm_Main()
{
InitializeComponent();
lab_Status1.Text = "操作员:" + APP.User.UserName;
lab_Status2.Text ="登录时间:" + DateTime.Now;
lab_Status3.Text = "远程连接正常。";
frm_Control = new Frm_Control();
frm_Control.MdiParent = this;
frm_Control.Show();
frm_Control.WindowState = FormWindowState.Normal;
frm_Control.Activate();
}
#region 窗体事件
/// <summary>
/// 用于改变背景色
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void frm_Main_Load(object sender, EventArgs e)
{
foreach (Control ctl in this.Controls)
{
try
{
MdiClient ctlMDI;
// Attempt to cast the control to type MdiClient.
ctlMDI = (MdiClient)ctl;
ctlMDI.Margin = new Padding(0);
// Set the BackColor of the MdiClient control.
ctlMDI.BackColor = this.BackColor;
}
catch (InvalidCastException exc)
{
// Catch and ignore the error if casting failed.
}
}
}
#endregion
#region 窗口
private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.Cascade);
}
private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileVertical);
}
private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.TileHorizontal);
}
private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
{
LayoutMdi(MdiLayout.ArrangeIcons);
}
private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
{
foreach (Form childForm in MdiChildren)
{
childForm.Close();
}
}
#endregion
#region 响应事件
private void menu_402_Click(object sender, EventArgs e)
{
if (frm_TaskInfo == null || frm_TaskInfo.IsDisposed)
{
frm_TaskInfo = new Frm_TaskInfo();
//frm_TaskInfo.MdiParent = this;
}
frm_TaskInfo.Show();
if (frm_TaskInfo.WindowState == FormWindowState.Minimized)
frm_TaskInfo.WindowState = FormWindowState.Normal;
frm_TaskInfo.Activate();
}
#endregion
/// <summary>
/// 程序退出
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void frm_Main_FormClosing(object sender, FormClosingEventArgs e)
{
Application.Exit();
}
private void menu_501_Click(object sender, EventArgs e)
{
if (frm_Control == null || frm_Control.IsDisposed)
{
frm_Control = new Frm_Control();
frm_Control.MdiParent = this;
}
frm_Control.Show();
if (frm_Control.WindowState == FormWindowState.Minimized)
frm_Control.WindowState = FormWindowState.Normal;
frm_Control.Activate();
}
/// <summary>
/// 最小化控制台
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menu_502_Click(object sender, EventArgs e)
{
frm_Control.WindowState = FormWindowState.Minimized;
}
private void lEDToolStripMenuItem_Click(object sender, EventArgs e)
{
LEDhelper.LEDHelper led = new LEDhelper.LEDHelper("192.168.10.110", 5005, 10);
led.SendLedInfoTest();
}
}
}