示例#1
0
        public void InitMinimizeAndTopMost()
        {
            OpenApplicationMenu        = new System.Windows.Forms.ToolStripMenuItem();
            OpenApplicationMenu.Font   = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
            OpenApplicationMenu.Image  = Properties.Resources.app_16x16;
            OpenApplicationMenu.Text   = "Open Application";
            OpenApplicationMenu.Click += OpenApplicationToolStripMenuItem_Click;
            ExitMenu        = new System.Windows.Forms.ToolStripMenuItem();
            ExitMenu.Image  = Properties.Resources.exit_16x16;
            ExitMenu.Text   = "Exit";
            ExitMenu.Click += (sender, e) => OnExitClick?.Invoke(sender, e);
            TrayMenuStrip   = new System.Windows.Forms.ContextMenuStrip();
            TrayNotifyIcon  = new System.Windows.Forms.NotifyIcon();
            TrayNotifyIcon.ContextMenuStrip = TrayMenuStrip;
            TrayMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                OpenApplicationMenu,
                ExitMenu,
            });
            var iconBytes = JocysCom.ClassLibrary.Helper.FindResource <byte[]>("app.ico");
            var ms        = new MemoryStream(iconBytes);

            TrayNotifyIcon.Icon         = new System.Drawing.Icon(ms);
            TrayNotifyIcon.Visible      = true;
            _hiddenForm.ShowInTaskbar   = false;
            TrayNotifyIcon.Click       += TrayNotifyIcon_Click;
            TrayNotifyIcon.DoubleClick += TrayNotifyIcon_DoubleClick;
        }
示例#2
0
        public void InitMinimizeAndTopMost()
        {
            // Item: Open Application.
            OpenApplicationMenu        = new System.Windows.Forms.ToolStripMenuItem();
            OpenApplicationMenu.Font   = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
            OpenApplicationMenu.Image  = Properties.Resources.app_16x16;
            OpenApplicationMenu.Text   = "Open Application";
            OpenApplicationMenu.Click += OpenApplicationToolStripMenuItem_Click;
            // Item: Exit Menu.
            ExitMenu        = new System.Windows.Forms.ToolStripMenuItem();
            ExitMenu.Image  = Properties.Resources.exit_16x16;
            ExitMenu.Text   = "Exit";
            ExitMenu.Click += (sender, e) => OnExitClick?.Invoke(sender, e);
            // Item: Show Loaded controls.
            ShowLoadedControls        = new System.Windows.Forms.ToolStripMenuItem();
            ShowLoadedControls.Image  = Properties.Resources.test_16x16;
            ShowLoadedControls.Text   = "Show Loaded Controls";
            ShowLoadedControls.Click += (sender, e) =>
            {
                var names = string.Join("\r\n", InitHelper.LoadedControlNames);
                Clipboard.SetText(names);
                MessageBox.Show(names);
            };
            // Tray menu.
            TrayMenuStrip  = new System.Windows.Forms.ContextMenuStrip();
            TrayNotifyIcon = new System.Windows.Forms.NotifyIcon();
            TrayNotifyIcon.ContextMenuStrip = TrayMenuStrip;
            TrayMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                OpenApplicationMenu,
                ShowLoadedControls,
                ExitMenu,
            });
            var iconBytes = JocysCom.ClassLibrary.Helper.FindResource <byte[]>("app.ico");
            var ms        = new MemoryStream(iconBytes);

            TrayNotifyIcon.Icon         = new System.Drawing.Icon(ms);
            TrayNotifyIcon.Visible      = true;
            _hiddenForm.ShowInTaskbar   = false;
            TrayNotifyIcon.Click       += TrayNotifyIcon_Click;
            TrayNotifyIcon.DoubleClick += TrayNotifyIcon_DoubleClick;
        }
示例#3
0
        public void InitMinimizeAndTopMost()
        {
            OpenApplicationToolStripMenuItem        = new System.Windows.Forms.ToolStripMenuItem();
            OpenApplicationToolStripMenuItem.Font   = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 0);
            OpenApplicationToolStripMenuItem.Image  = Properties.Resources.app_16x16;
            OpenApplicationToolStripMenuItem.Text   = "Open Application";
            OpenApplicationToolStripMenuItem.Click += OpenApplicationToolStripMenuItem_Click;
            ExitToolStripMenuItem        = new System.Windows.Forms.ToolStripMenuItem();
            ExitToolStripMenuItem.Image  = Properties.Resources.exit_16x16;
            ExitToolStripMenuItem.Text   = "Exit";
            ExitToolStripMenuItem.Click += (sender, e) => OnExitClick?.Invoke(sender, e);
            TrayContextMenuStrip         = new System.Windows.Forms.ContextMenuStrip();
            TrayNotifyIcon = new System.Windows.Forms.NotifyIcon();
            TrayNotifyIcon.ContextMenuStrip = TrayContextMenuStrip;
            TrayContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                OpenApplicationToolStripMenuItem,
                ExitToolStripMenuItem,
            });
            var iconBytes = JocysCom.ClassLibrary.Helper.FindResource <byte[]>("app.ico");
            var ms        = new MemoryStream(iconBytes);

            TrayNotifyIcon.Icon         = new System.Drawing.Icon(ms);
            TrayNotifyIcon.Visible      = true;
            _hiddenForm.ShowInTaskbar   = false;
            _Window.SizeChanged        += MainWindow_SizeChanged;
            TrayNotifyIcon.Click       += TrayNotifyIcon_Click;
            TrayNotifyIcon.DoubleClick += TrayNotifyIcon_DoubleClick;
            // Run event once to apply settings.
            MainWindow_SizeChanged(this, null);
            var o = SettingsManager.Options;

            _Window.Topmost         = o.AlwaysOnTop;
            InfoForm.MonitorEnabled = o.EnableShowFormInfo;
            // Start monitoring event.
            o.PropertyChanged += Options_PropertyChanged_Tray;
        }
示例#4
0
 private void ExitAction()
 {
     OnExitClick?.Invoke();
     SceneManager.LoadScene("Menu");
 }