Beispiel #1
0
        private void InitNotifyIcon()
        {
            this.notifyIcon = new Forms.NotifyIcon();
            this.notifyIcon.BalloonTipText = "px转vw/vh工具";
            this.notifyIcon.ShowBalloonTip(2000);
            this.notifyIcon.Text    = "px转vw/vh工具";
            this.notifyIcon.Icon    = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath);
            this.notifyIcon.Visible = true;
            //打开菜单项
            System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("打开");
            open.Click += new EventHandler(Show);
            //退出菜单项
            System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("退出");
            exit.Click += new EventHandler(Close);
            //关联托盘控件
            System.Windows.Forms.MenuItem [] childen = new System.Windows.Forms.MenuItem [] { open, exit };
            notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen);

            this.notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler((o, e) => {
                if (e.Button == Forms.MouseButtons.Left)
                {
                    this.Show(o, e);
                }
            });
        }
        private void ShowTuoPan()
        {
            this.Visibility         = Visibility.Hidden;
            this.notifyIcon         = new Forms.NotifyIcon();
            this.notifyIcon.Text    = "你保存了吗?";
            this.notifyIcon.Icon    = System.Drawing.Icon.ExtractAssociatedIcon(Forms.Application.ExecutablePath);
            this.notifyIcon.Visible = true;
            System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("设置提醒间隔");
            open.Click += new EventHandler(SetInterval);
            System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("退出");
            exit.Click += new EventHandler(Close);
            System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { open, exit };
            notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen);

            this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler((o, e) =>
            {
                if (e.Button == Forms.MouseButtons.Left)
                {
                    this.SetInterval(o, e);
                }
            });
        }
Beispiel #3
0
        //显示初始化函数
        private void InitDisplay()
        {
            //--------------------------------------------程序驻留系统托盘----------------------------------------------------------
            this.notifyIcon = new Forms.NotifyIcon();
            this.notifyIcon.BalloonTipText = "红警大战已最小化到后台运行";
            this.notifyIcon.ShowBalloonTip(2000);
            this.notifyIcon.Text = "红警大战";
            //读取程序图标作为托盘图标
            this.notifyIcon.Icon    = System.Drawing.Icon.ExtractAssociatedIcon(System.Windows.Forms.Application.ExecutablePath);
            this.notifyIcon.Visible = true;
            //添加系统托盘图标的-打开菜单项
            System.Windows.Forms.MenuItem open = new System.Windows.Forms.MenuItem("打开");
            open.Click += new EventHandler(Show);
            //添加系统托盘图标的-退出菜单项
            System.Windows.Forms.MenuItem exit = new System.Windows.Forms.MenuItem("退出");
            exit.Click += new EventHandler(Close);
            //关联托盘控件菜单
            System.Windows.Forms.MenuItem[] childen = new System.Windows.Forms.MenuItem[] { open, exit };
            notifyIcon.ContextMenu = new System.Windows.Forms.ContextMenu(childen);
            //添加双击打开程序图标
            this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler((o, e) =>
            {
                if (e.Button == Forms.MouseButtons.Left)
                {
                    this.Show(o, e);
                }
            });


            //---------------------------指定窗口显示位置------------------------------------
            WindowStartupLocation = WindowStartupLocation.Manual; //自定义窗口显示位置
            this.Top  = 0;                                        //距离顶部
            this.Left = 188;                                      //距离左边


            //绑定web控件的文档加载完成的回调函数,到web控件中,onLoadDocCompleted
            web1.LoadCompleted += new LoadCompletedEventHandler(onLoadDocCompleted);
        }