public static void Main(string[] args) { // Make sure the MouseUnSnag.exe has only one instance running at a time. if ((new Mutex(true, "__MouseUnSnag_EXE__", out bool createdNew) == null) || !createdNew) { //Console.WriteLine("Already running!! Quitting this instance..."); return; } //Application.SetHighDpiMode(HighDpiMode.SystemAware); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var mouseUnSnag = new MouseUnSnag(); Task.Run(() => mouseUnSnag.Run(args)); var mouseUnSnagForm = new MouseUnSnagForm(); mouseUnSnagForm.onToggleWrap += (sender, e) => { mouseUnSnag.EnableWrap = (e as CustomEvent <bool>).Payload; }; Application.Run(mouseUnSnagForm); }
public MouseUnSnag() { // Create the system tray icon NotifyIcon notifyIcon = new NotifyIcon(); // Set up the events on the tray icon MenuItem configMenuItem = new MenuItem("Configuration", new EventHandler(ShowConfig)); MenuItem exitMenuItem = new MenuItem("Exit", new EventHandler(Exit)); notifyIcon.ContextMenu = new ContextMenu(new MenuItem[] { configMenuItem, exitMenuItem }); notifyIcon.Click += new EventHandler(ShowConfig); // Set up the visuals for the icon notifyIcon.Icon = new Icon("../../poop-emoji.ico"); notifyIcon.Visible = true; // Set the private variables this._notifyIcon = notifyIcon; this._configWindow = new MouseUnSnagForm(this); Start(); }