懒羊羊
2023-12-28 e46d3baaf3e8d7d85f4bafec3aad75e52b078408
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
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;
using WeifenLuo.WinFormsUI.Docking;
using YX.BLL;
 
namespace YX
{
    public partial class FrmMain : DockContent
    {
        public FrmMain()
        {      
            InitializeComponent();        
        }
 
        private void Main_Load(object sender, EventArgs e)
        {
            this.dockPanel1.DockLeftPortion = 200;//左侧菜单宽度
            new FrmLeft(this).Show(this.dockPanel1, DockState.DockLeft);
            new Frmhome("").Show(this.dockPanel1,DockState.Document);
            this.toolStripLabel1.Text = "当前账号:"+FrmLogin.loginUserName;
        }
 
        private void Main_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("是否确认退出程序?", "退出", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                LogHelper.WriteLog(typeof(FrmMain), "************软件关闭***********");              
                notifyIcon1.Visible = true;
                notifyIcon1.Dispose();
                this.Dispose();
                Environment.Exit(0);               
            }
            else
            {
                e.Cancel = true;
            }
        }
 
        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            //判断是否已经最小化于托盘
            if (WindowState == FormWindowState.Minimized)
            {
                //还原窗体显示 
                WindowState = FormWindowState.Normal;
                //激活窗体并给予它焦点 
               this.Activate();
                //任务栏区显示图标 
                this.ShowInTaskbar = true;
                //托盘区图标隐藏 
                notifyIcon1.Visible = true;
            }
        }
 
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            this.Dispose();
            FrmLogin login = new FrmLogin();
            login.Show();
        }
 
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}