frm_Main.cs 3.35 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>
        public Frm_TaskInfo Frm_TaskInfo { get; set; }

        #endregion

        public Frm_Main()
        {
            InitializeComponent();
            lab_Status1.Text = "操作员:" + APP.User.UserName;
            lab_Status2.Text ="登录时间:" + DateTime.Now;
            lab_Status3.Text = "远程连接正常。";
        }

        #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();
        }


    }
}