Example #1
0
        public void Apply()
        {
            // Update Shortcut
            var shortcut = CreateShortcut();

            Settings.Default.OpenShortcut = shortcut.ToString();
            _context.EnableKeyboardHook(shortcut);

            // Settings
            Settings.Default.WindowListSingleClick = WindowListSingleClick;

            // Plugins
            var disabledPlugins = new StringCollection();

            disabledPlugins.AddRange(Plugins.Where(plugin => !plugin.Enabled).Select(plugin => plugin.Id).ToArray());
            Settings.Default.DisabledPlugins = disabledPlugins;

            // Save
            Settings.Default.Save();
            Log.InfoFormat("Settings updated. Shortcut is '{0}' ({1})", shortcut.ToHumanReadableString(), shortcut);
        }
Example #2
0
		private void Application_Startup(object sender, StartupEventArgs e)
		{
			var isFirstRun = false;
			if(e.Args.Any() && e.Args[0].StartsWith("--squirrel"))
			{
				var cliHandler = new SquirrelCommandLineArgumentsHandler();
				if (cliHandler.HandleSquirrelArguments(e.Args))
				{
					Log.Info("Handled Squirrel arguments. Shutting down.");
					Current.Shutdown(1);
					return;
				}

				isFirstRun = cliHandler.IsFirstRun;
			}

			if (!WaitForOtherInstancesToShutDown())
			{
				MessageBox.Show(
					"Another Go To Window instance is already running." + Environment.NewLine +
					"Exit by right-clicking the icon in the tray, and selecting 'Exit'.",
					"Go To Window",
					MessageBoxButton.OK,
					MessageBoxImage.Information
					);
				Log.Warn("Application already running. Shutting down.");
				Current.Shutdown(1);
				return;
			}

			// http://stackoverflow.com/questions/14635862/exception-occurs-while-pressing-a-button-on-touchscreen-using-a-stylus-or-a-fing
			DisableWpfTabletSupport();

			_context = new GoToWindowContext();
			
			_menu = new GoToWindowTrayIcon(_context);

			var shortcut = KeyboardShortcut.FromString(GoToWindow.Properties.Settings.Default.OpenShortcut);
			_context.EnableKeyboardHook(shortcut);

			_context.Init();

			if (shortcut.IsValid)
				Log.InfoFormat("Application started. Shortcut is '{0}' ({1})", shortcut.ToHumanReadableString(), GoToWindow.Properties.Settings.Default.OpenShortcut);
			else
				Log.WarnFormat("Application started with invalid shortcut. Shortcut is '{0}', reason: {1}", GoToWindow.Properties.Settings.Default.OpenShortcut, shortcut.InvalidReason);

			if (isFirstRun)
			{
				Log.Info("Squirrel: First run");
				Dispatcher.InvokeAsync(() =>
				{
					new FirstRunWindow(_context) {DataContext = new FirstRunViewModel()}.Show();
				});
			}
			else
			{
				_menu.ShowStartupTooltip();
			}

			SquirrelContext.AcquireUpdater().CheckForUpdates(_context.UpdateAvailable, null);
		}
Example #3
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            var isFirstRun = false;

            if (e.Args.Any() && e.Args[0].StartsWith("--squirrel"))
            {
                var cliHandler = new SquirrelCommandLineArgumentsHandler();
                if (cliHandler.HandleSquirrelArguments(e.Args))
                {
                    Log.Info("Handled Squirrel arguments. Shutting down.");
                    Current.Shutdown(1);
                    return;
                }

                isFirstRun = cliHandler.IsFirstRun;
            }

            if (!WaitForOtherInstancesToShutDown())
            {
                MessageBox.Show(
                    "Another Go To Window instance is already running." + Environment.NewLine +
                    "Exit by right-clicking the icon in the tray, and selecting 'Exit'.",
                    "Go To Window",
                    MessageBoxButton.OK,
                    MessageBoxImage.Information
                    );
                Log.Warn("Application already running. Shutting down.");
                Current.Shutdown(1);
                return;
            }

            // http://stackoverflow.com/questions/14635862/exception-occurs-while-pressing-a-button-on-touchscreen-using-a-stylus-or-a-fing
            DisableWpfTabletSupport();

            _context = new GoToWindowContext();

            _menu = new GoToWindowTrayIcon(_context);

            var shortcut = KeyboardShortcut.FromString(GoToWindow.Properties.Settings.Default.OpenShortcut);

            _context.EnableKeyboardHook(shortcut);

            _context.Init();

            if (shortcut.IsValid)
            {
                Log.InfoFormat("Application started. Shortcut is '{0}' ({1})", shortcut.ToHumanReadableString(), GoToWindow.Properties.Settings.Default.OpenShortcut);
            }
            else
            {
                Log.WarnFormat("Application started with invalid shortcut. Shortcut is '{0}', reason: {1}", GoToWindow.Properties.Settings.Default.OpenShortcut, shortcut.InvalidReason);
            }

            if (isFirstRun)
            {
                Log.Info("Squirrel: First run");
                Dispatcher.InvokeAsync(() =>
                {
                    new FirstRunWindow(_context)
                    {
                        DataContext = new FirstRunViewModel()
                    }.Show();
                });
            }
            else
            {
                _menu.ShowStartupTooltip();
            }

            SquirrelContext.AcquireUpdater().CheckForUpdates(_context.UpdateAvailable, null);
        }