private void CheckboxAutostart_Checked(object sender, RoutedEventArgs e) { if (is_initialized) { Autostart.Enable(); } }
public static void Main() { application = new App(); application.InitializeComponent(); ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue)); ToolTipService.InitialShowDelayProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(0)); if (!Directory.Exists(Helpers.UserDataFolder)) { Directory.CreateDirectory(Helpers.UserDataFolder); } System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.RealTime; // Tray icon initialization { System.Windows.Forms.ContextMenuStrip context_menu_strip = new System.Windows.Forms.ContextMenuStrip { Visible = true }; context_menu_strip.SuspendLayout(); System.Windows.Forms.ToolStripMenuItem settings = new System.Windows.Forms.ToolStripMenuItem { Text = "Settings", Visible = true }; settings.Click += OpenSettings; System.Windows.Forms.ToolStripMenuItem reset_calibration = new System.Windows.Forms.ToolStripMenuItem { Text = "Reset calibration", Visible = true }; reset_calibration.Click += ResetCalibration; System.Windows.Forms.ToolStripMenuItem exit = new System.Windows.Forms.ToolStripMenuItem { Text = "Exit", Visible = true }; exit.Click += Shutdown; context_menu_strip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { settings, reset_calibration, exit }); context_menu_strip.ResumeLayout(false); Helpers.tray_icon.ContextMenuStrip = context_menu_strip; Helpers.tray_icon.MouseClick += Tray_icon_Click; } eye_tracking_mouse = new EyeTrackingMouse(); input_manager = new InputManager(eye_tracking_mouse); Task.Run(() => { if (Path.GetFullPath(Environment.CurrentDirectory).StartsWith( Path.GetFullPath(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)))) { try { string path = Environment.GetEnvironmentVariable("EYE_TRACKING_MOUSE_UPDATE_FROM"); if (path == null || path.Length == 0) { using (var update_manager = UpdateManager.GitHubUpdateManager("https://github.com/Romex91/EyeTrackingMouse").Result) { update_manager.UpdateApp().Wait(); } } else { if (!Directory.Exists(path)) { MessageBox.Show("Inexistent directory in EYE_TRACKING_MOUSE_UPDATE_FROM environment variable"); return; } using (var update_manager = new UpdateManager(path)) { update_manager.UpdateApp().Wait(); } } } catch (Exception) { } } }); SquirrelAwareApp.HandleEvents( onAppUninstall: v => { Helpers.RemoveShortcuts(); lock (Helpers.locker) { if (Options.Instance.key_bindings.is_driver_installed) { string interception_installer = System.IO.Path.Combine( Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).FullName, "install-interception.exe"); var process = System.Diagnostics.Process.Start( interception_installer, " /uninstall"); } } Helpers.DeleteAppFiles(); }, onFirstRun: () => { Helpers.CreateShortcuts(); Autostart.Enable(); OpenSettings(null, null); }); application.Run(); eye_tracking_mouse.Dispose(); Helpers.tray_icon.Visible = false; }
public static void Main() { application = new App(); application.InitializeComponent(); ToolTipService.ShowDurationProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue)); ToolTipService.InitialShowDelayProperty.OverrideMetadata( typeof(DependencyObject), new FrameworkPropertyMetadata(0)); if (!Directory.Exists(Helpers.UserDataFolder)) { Directory.CreateDirectory(Helpers.UserDataFolder); } // Tray icon initialization { System.Windows.Forms.ContextMenuStrip context_menu_strip = new System.Windows.Forms.ContextMenuStrip { Visible = true }; context_menu_strip.SuspendLayout(); System.Windows.Forms.ToolStripMenuItem settings = new System.Windows.Forms.ToolStripMenuItem { Text = "Settings", Visible = true }; settings.Click += OpenSettings; System.Windows.Forms.ToolStripMenuItem reset_calibration = new System.Windows.Forms.ToolStripMenuItem { Text = "Reset calibration", Visible = true }; reset_calibration.Click += ResetCalibration; System.Windows.Forms.ToolStripMenuItem exit = new System.Windows.Forms.ToolStripMenuItem { Text = "Exit", Visible = true }; exit.Click += Shutdown; context_menu_strip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { settings, reset_calibration, exit }); context_menu_strip.ResumeLayout(false); Helpers.tray_icon.ContextMenuStrip = context_menu_strip; Helpers.tray_icon.MouseClick += Tray_icon_Click; } eye_tracking_mouse = new EyeTrackingMouse(); input_manager = new InputManager(eye_tracking_mouse); SquirrelAwareApp.HandleEvents( onAppUninstall: v => { Helpers.RemoveShortcuts(); lock (Helpers.locker) { if (Options.Instance.key_bindings.is_driver_installed) { string interception_installer = System.IO.Path.Combine( Directory.GetParent(System.Reflection.Assembly.GetEntryAssembly().Location).FullName, "install-interception.exe"); var process = System.Diagnostics.Process.Start( interception_installer, " /uninstall"); } } Helpers.DeleteAppFiles(); }, onAppUpdate: (Version version) => { lock (Helpers.locker) { Helpers.ShowBaloonNotification("EyeTrackingMouse has updated. It is now faster and more accurate. \n Double press " + Options.Instance.key_bindings[Key.Modifier] + " to toggle Always On mode. \n" + "This is the last automatic update over the network. I removed auto-update for better security. EyeTrackingMouse is completely offline now."); } }, onFirstRun: () => { Helpers.CreateShortcuts(); }); lock (Helpers.locker) { if (!Options.Instance.user_consent_given) { new ConsentWindow(() => { Autostart.Enable(); OpenSettings(null, null); }, () => { Shutdown(null, null); }).Show(); } } application.Run(); eye_tracking_mouse.Dispose(); Helpers.tray_icon.Visible = false; }