public MainWindow() { InitializeComponent(); this.notifyIcon = new NotifyIcon(); this.notifyIcon.BalloonTipText = "已停止... ..."; this.notifyIcon.ShowBalloonTip(2000); this.notifyIcon.Text = "已停止... ..."; this.notifyIcon.Icon = UI.Properties.Resources.logo; this.notifyIcon.Visible = true; //退出菜单项 System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("退出"); exit.Click += new EventHandler(Close); //设置菜单项 System.Windows.Forms.MenuItem setting = new System.Windows.Forms.MenuItem("设置"); setting.Click += (obj, e) => { if (settingWindow == null) { settingWindow = new SettingWindow(this); } settingWindow.Show(); }; //System.Windows.Forms.MenuItem log = new System.Windows.Forms.MenuItem("日志"); //log.Click += (obj, e) => //{ // if (LogWindow == null) // LogWindow = new LogWindow(); // LogWindow.Show(); //}; //关联托盘控件 System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { setting, exit }; notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen); this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler((o, e) => { if (e.Button == MouseButtons.Left) { if (settingWindow == null) { settingWindow = new SettingWindow(this); } settingWindow.Show(); } }); //获取UI线程同步上下文 m_SyncContext = SynchronizationContext.Current; this.Loaded += MainWindow_Loaded; this.Deactivated += MainWindow_Deactivated; this.StateChanged += MainWindow_StateChanged; random = new Random(); shared = new SharedPreference(); }
public SettingWindow() { InitializeComponent(); shared = new SharedPreference(); }