MetroMDI.cs 13.5 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using MetroFramework.Components;
using System.Windows.Forms;
using MetroFramework.Controls;
using Comm;
using MachineDll;
using Dal;

namespace App
{
    using FrmAdjustQuotietyA = FrmAdjustQuotiety2;
    public partial class MetroMDI : FrmBase
    {

        private readonly TheMachine theMachine;
        private LoginManager _loginManager;
        private float minWidth;
        private float minHeight;
        
        private bool flag = false;//用来标识界面是否已经加载完成
        
        private Dictionary<Control, Rectangle> controlsSize = new Dictionary<Control, Rectangle>();

        public MetroMDI(LoginManager loginManager)
        {
            theMachine = GetMachineFromMe.GetMachine;
            InitializeComponent();
            this.ControlBox = true;
            _loginManager = loginManager;
            _loginManager.IsExit = true;
            this.SetLanguage(this);

            //if ("admin".Equals(Fuction.m_UserName))
            //{
                this.Account.Visible = true;
            //}
            //else
            //{
            //    this.Account.Visible = false;
            //}
            Init();
        }

        private void Init()
        {
            if (Fuction.m_Language == Const.LANGUAGE_ENGLISH)
            {
                this.label1.Text = getMsg("FrmMDItsmi_Dynamic") + " " + getMsg("FrmMDItabTest");
                this.label4.Text = getMsg("FrmMDItsmi_Static") + " " + getMsg("FrmMDItabTest");
            }
            else
            {
                this.label1.Text = getMsg("FrmMDItsmi_Dynamic") + getMsg("FrmMDItabTest");
                this.label4.Text = getMsg("FrmMDItsmi_Static") + getMsg("FrmMDItabTest");
            }
            this.label2.Text = getMsg("FrmProduct");
            this.label3.Text = getMsg("FrmTestResult");
            this.label5.Text = getMsg("frmLoginManageckb_AMMaintenance4");
            //统计分析
            this.label6.Text = getMsg("FrmStatisticAnalysis");
            this.label7.Text = getMsg("frmLoginbtnSetting");
            this.Text = getMsg("ContaminationExplorerTesting");
            this.label8.Text = getMsg("frmLoginManageckb_AMAccountManage3");
        }

        private void MetroMDI_Resize(object sender, EventArgs e)
        {
            //if (( flag == true ) && (( this.WindowState == FormWindowState.Maximized ) || ( this.WindowState == FormWindowState.Normal )))
            //{
            //    float scaleX;
            //    float scaleY;

            //    string[] pos = new string[4];
            //    float[] sizeInfo = new float[4];

            //    scaleX = (float)(this.Width / minWidth);
            //    scaleY = (float)(this.Height / minHeight);
                
            //    foreach (Control ctl in homePanel.Controls)
            //    {
            //        pos = ctl.Tag.ToString().Split(',');
            //        for(int i=0 ; i<pos.Length ; i++)
            //        {
            //            sizeInfo[i] = (float)(Convert.ToDouble(pos[i]));
            //        }
                    
            //        ctl.Top = (int)(sizeInfo[0] * scaleX);
            //        ctl.Left = (int)(sizeInfo[1] * scaleY);
            //        ctl.Width = (int)(sizeInfo[2] * scaleY);
            //        ctl.Height = (int)(sizeInfo[3] * scaleX);
                    
            //    }
            //}

        }

        private void MetroMDI_Load(object sender, EventArgs e)
        {
            //minWidth = (float)this.Width;
            //minHeight = (float)this.Height;
            //foreach (Control ctl in homePanel.Controls)
            //{
            //    ctl.Tag = ctl.Top + "," + ctl.Left + "," + ctl.Width + "," + ctl.Height ;
                
            //}
            //this.flag = true;

            this.label1.Left = (this.DynamicTesting.Width - this.label1.Width) / 2;
            this.label1.Top = (this.DynamicTesting.Height - this.label1.Height) / 2;
            this.label2.Left = (this.Product.Width - this.label2.Width) / 2;
            this.label2.Top = (this.Product.Height - this.label2.Height) / 2;
            this.label3.Left = (this.TestResult.Width - this.label3.Width) / 2;
            this.label3.Top = (this.TestResult.Height - this.label3.Height) / 2;
            this.label4.Left = (this.StaticTesting.Width - this.label4.Width) / 2;
            this.label4.Top = (this.StaticTesting.Height - this.label4.Height) / 2;
            this.label5.Left = (this.adjusting.Width - this.label5.Width) / 2;
            this.label5.Top = (this.adjusting.Height - this.label5.Height) / 2;
            this.label6.Left = (this.StatisticAnalysis.Width - this.label6.Width) / 2;
            this.label6.Top = (this.StatisticAnalysis.Height - this.label6.Height) / 2;
            this.label7.Left = (this.setting.Width - this.label7.Width) / 2;
            this.label7.Top = (this.setting.Height - this.label7.Height) / 2;
            this.label8.Left = (this.Account.Width - this.label8.Width) / 2;
            this.label8.Top = (this.Account.Height - this.label8.Height) / 2;
        }

        private void Setting_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //打开校准参数
            FrmAdjustQuotietyA frm = new FrmAdjustQuotietyA("",_loginManager);
            //frm.Owner = this;
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            //this.Hide();//菜单选择窗口隐藏
            this.Close();
            frm.Show();
            
        }

        private void DynamicTesting_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //打开动态测试
            MetroDynamicTesting frm = new MetroDynamicTesting(_loginManager);
            //frm.Owner = this;
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            //this.Hide();//菜单选择窗口隐藏
            this.Close();
            frm.Show();
            
        }

        private void Product_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //打开产品
            MetroProduct frm = new MetroProduct(Const.OPERATION_ADD, "",_loginManager);
            //frm.Owner = this;
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            //this.Hide();//菜单选择窗口隐藏
            frm.WindowState = FormWindowState.Maximized;
            this.Close();
            frm.Show();
            
        }

        private void StaticTesting_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            this.Close();
            //打开静态测试
            MetroStaticTesting frm = new MetroStaticTesting(_loginManager);
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            frm.Show();
            frm.Activate();
            //frm.Owner = this;
            ////this.Hide();//菜单选择窗口隐藏

            //frm.Show();
        }

        private void TestResult_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //打开测试结果
            MetroTestResult frm = new MetroTestResult(_loginManager,"");
            //frm.Owner = this;
            if (frm.isOpen)
            {
                this.ShowInTaskbar = false;
                frm.ShowInTaskbar = true;
                //this.Hide();//菜单选择窗口隐藏
                this.Close();
                frm.Show();
            }
        }

        private void StatisticAnalysis_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //统计分析
            MetroStatisticAnalysis frm = new MetroStatisticAnalysis(_loginManager);
            //frm.Owner = this;
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            //this.Hide();//菜单选择窗口隐藏
            this.Close();
            frm.Show();
        }

        private void MetroMDI_FormClosed(object sender, FormClosedEventArgs e)
        {
            //this.notifyIcon1.Visible = false;
            if (_loginManager.IsExit)
            {
                Application.Exit();
            }
        }

        private void MetroMDI_FormClosing(object sender, FormClosingEventArgs e)
        {
            //this.notifyIcon1.Visible = false;
        }

        //private void notifyIcon1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
        //{
        //    this.Visible = true; this.WindowState = FormWindowState.Maximized;
        //    this.Activate(); this.notifyIcon1.Visible = false;
        //}

        //private void pictureBox1_Click(object sender, EventArgs e)
        //{
            
        //}

        //private void pictureBox1_MouseHover(object sender, EventArgs e)
        //{
        //    ToolTip tt = new ToolTip();
        //    tt.SetToolTip(this.pictureBox1, getMsg("systemSetting"));
        //}

        private void metroTile1_Click(object sender, EventArgs e)
        {
            //打开设置
            this._loginManager.IsExit = false;
            MetroSetting frm = new MetroSetting(_loginManager);
            //this.ShowInTaskbar = true;
            frm.ShowInTaskbar = true;
            this.Close();
            frm.Show();
        }

        private void label1_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //打开动态测试
            //FrmTestManage ftm = new FrmTestManage();
            //ftm.MaximizeBox = true;
            //ftm.Show();
            MetroDynamicTesting frm = new MetroDynamicTesting(_loginManager);
            //frm.Owner = this;
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            //this.Hide();//菜单选择窗口隐藏
            this.Close();
            frm.Show();
        }

        private void label2_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //打开产品
            MetroProduct frm = new MetroProduct(Const.OPERATION_ADD, "", _loginManager);
            //frm.Owner = this;
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            //this.Hide();//菜单选择窗口隐藏
            frm.WindowState = FormWindowState.Maximized;
            this.Close();
            frm.Show();
        }

        private void label3_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //打开测试结果
            MetroTestResult frm = new MetroTestResult(_loginManager,"");
            if (frm.isOpen)
            {
                //frm.Owner = this;
                this.ShowInTaskbar = false;
                frm.ShowInTaskbar = true;
                //this.Hide();//菜单选择窗口隐藏
                this.Close();
                frm.Show();
            }
        }

        private void label4_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            this.Close();
            //打开静态测试
            MetroStaticTesting frm = new MetroStaticTesting(_loginManager);
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            frm.Show();
            frm.Activate();
        }

        private void label5_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //打开校准参数
            FrmAdjustQuotietyA frm = new FrmAdjustQuotietyA("", _loginManager);
            //frm.Owner = this;
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            //this.Hide();//菜单选择窗口隐藏
            this.Close();
            frm.Show();
        }

        private void label6_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            //统计分析
            MetroStatisticAnalysis frm = new MetroStatisticAnalysis(_loginManager);
            //frm.Owner = this;
            this.ShowInTaskbar = false;
            frm.ShowInTaskbar = true;
            //this.Hide();//菜单选择窗口隐藏
            this.Close();
            frm.Show();
        }

        private void label7_Click(object sender, EventArgs e)
        {
            //打开设置
            this._loginManager.IsExit = false;
            MetroSetting frm = new MetroSetting(_loginManager);
            //this.ShowInTaskbar = true;
            frm.ShowInTaskbar = true;
            this.Close();
            frm.Show();
        }
        //点击账号管理
        private void label8_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            MetroAccount ma = new MetroAccount(_loginManager);
            ma.ShowInTaskbar = true;
            ma.WindowState = FormWindowState.Maximized;
            this.Close();
            ma.Show();
        }
        //点击账号管理
        private void Account_Click(object sender, EventArgs e)
        {
            this._loginManager.IsExit = false;
            MetroAccount ma = new MetroAccount(_loginManager);
            ma.ShowInTaskbar = true;
            ma.WindowState = FormWindowState.Maximized;
            this.Close();
            ma.Show();
        }

        private void DynamicTesting_Paint(object sender, PaintEventArgs e)
        {

        }

        private void StaticTesting_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}