frm_Main.cs 4.6 KB
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();
        }
    }
}