private void App_OnStartup(object sender, StartupEventArgs e)
        {
            if (string.IsNullOrEmpty(Settings.Default.FilePath))
            {
                Settings.Default.FilePath = DefaultCrosshair;
            }

            _notifyIcon = new NotifyIcon()
            {
                Icon    = Icon.ExtractAssociatedIcon(ResourceAssembly.ManifestModule.Name),
                Visible = true
            };

            _notifyIcon.DoubleClick += (o, args) => SettingsWindow.OpenWindow();

            _notifyIcon.ContextMenu = new ContextMenu();
            _notifyIcon.ContextMenu.MenuItems.Add("Settings", (o, args) => SettingsWindow.OpenWindow());
            _notifyIcon.ContextMenu.MenuItems.Add("Exit", (o, args) =>
            {
                _notifyIcon.Visible = false;
                Current.Shutdown();
            });

            if (!File.Exists(Settings.Default.FilePath))
            {
                var title = "Failed to Load Crosshair";
                var text  = $"The previously selected image could not be found. Verify the file exists or select a different one.";
                _notifyIcon.ShowBalloonTip(3000, title, text, ToolTipIcon.Error);
            }

            MainWindow = CrosshairWindow.OpenWindow();
        }
Example #2
0
        public static CrosshairWindow OpenWindow()
        {
            if (_crosshairWindow == null)
            {
                _crosshairWindow = new CrosshairWindow();
                _crosshairWindow.Show();
            }

            return(_crosshairWindow);
        }
Example #3
0
        private void App_OnStartup(object sender, StartupEventArgs e)
        {
            settingsWindow  = new SettingsWindow();
            crosshairWindow = new CrosshairWindow();

            MainWindow = settingsWindow; // #TODO: Better handling of application shutdown

            settingsWindow.Show();
            crosshairWindow.Show();
        }