Exemple #1
0
        private void SaveBTN_Click(object sender, RoutedEventArgs e)
        {
            if (ShowToastCheckBox.IsChecked != null)
            {
                Settings.Default.ShowToast = (bool)ShowToastCheckBox.IsChecked;
            }

            if (FullScreenRDBTN.IsChecked == true)
            {
                Settings.Default.DefaultLaunch = "Fullscreen";
            }
            else if (GrabFrameRDBTN.IsChecked == true)
            {
                Settings.Default.DefaultLaunch = "GrabFrame";
            }
            else if (EditTextRDBTN.IsChecked == true)
            {
                Settings.Default.DefaultLaunch = "EditText";
            }

            if (ErrorCorrectBox.IsChecked != null)
            {
                Settings.Default.CorrectErrors = (bool)ErrorCorrectBox.IsChecked;
            }

            if (NeverUseClipboardChkBx.IsChecked != null)
            {
                Settings.Default.NeverAutoUseClipboard = (bool)NeverUseClipboardChkBx.IsChecked;
            }

            if (RunInBackgroundChkBx.IsChecked != null)
            {
                Settings.Default.RunInTheBackground = (bool)RunInBackgroundChkBx.IsChecked;

                if ((bool)RunInBackgroundChkBx.IsChecked == true)
                {
                    // Get strongly-typed current application
                    NotifyIconUtilities.SetupNotifyIcon();
                }
                else
                {
                    App app = (App)App.Current;
                    if (app.TextGrabIcon != null)
                    {
                        app.TextGrabIcon.Dispose();
                    }
                }
            }

            if (TryInsertCheckbox.IsChecked != null)
            {
                Settings.Default.TryInsert = (bool)TryInsertCheckbox.IsChecked;
            }


            Settings.Default.Save();
            Close();
        }
Exemple #2
0
        void appStartup(object sender, StartupEventArgs e)
        {
            NumberOfRunningInstances = Process.GetProcessesByName("Text-Grab").Length;

            // Register COM server and activator type
            bool handledArgument = false;

            ToastNotificationManagerCompat.OnActivated += toastArgs =>
            {
                string argsInvoked = toastArgs.Argument;
                // Need to dispatch to UI thread if performing UI operations
                Dispatcher.BeginInvoke((Action)(() =>
                {
                    if (String.IsNullOrWhiteSpace(argsInvoked) == false)
                    {
                        EditTextWindow mtw = new EditTextWindow(argsInvoked);
                        mtw.Show();
                        handledArgument = true;
                    }
                }));
            };

            if (Settings.Default.RunInTheBackground == true &&
                NumberOfRunningInstances < 2)
            {
                NotifyIconUtilities.SetupNotifyIcon();
            }

            Current.DispatcherUnhandledException += CurrentDispatcherUnhandledException;

            for (int i = 0; i != e.Args.Length && !handledArgument; ++i)
            {
                Debug.WriteLine($"ARG {i}:{e.Args[i]}");
                if (e.Args[i].Contains("ToastActivated"))
                {
                    Debug.WriteLine("Launched from toast");
                    handledArgument = true;
                }
                else if (e.Args[i] == "Settings")
                {
                    SettingsWindow sw = new SettingsWindow();
                    sw.Show();
                    handledArgument = true;
                }
                else if (e.Args[i] == "GrabFrame")
                {
                    GrabFrame gf = new GrabFrame();
                    gf.Show();
                    handledArgument = true;
                }
                else if (e.Args[i] == "Fullscreen")
                {
                    WindowUtilities.LaunchFullScreenGrab();
                    handledArgument = true;
                }
                else if (e.Args[i] == "EditText")
                {
                    EditTextWindow manipulateTextWindow = new EditTextWindow();
                    manipulateTextWindow.Show();
                    handledArgument = true;
                }
                else if (File.Exists(e.Args[i]))
                {
                    EditTextWindow manipulateTextWindow = new EditTextWindow();
                    manipulateTextWindow.OpenThisPath(e.Args[i]);
                    manipulateTextWindow.Show();
                    handledArgument = true;
                }
            }

            if (!handledArgument)
            {
                if (Settings.Default.FirstRun)
                {
                    FirstRunWindow frw = new FirstRunWindow();
                    frw.Show();

                    Settings.Default.FirstRun = false;
                    Settings.Default.Save();
                }
                else
                {
                    switch (Settings.Default.DefaultLaunch)
                    {
                    case "Fullscreen":
                        WindowUtilities.LaunchFullScreenGrab();
                        break;

                    case "GrabFrame":
                        GrabFrame gf = new GrabFrame();
                        gf.Show();
                        break;

                    case "EditText":
                        EditTextWindow manipulateTextWindow = new EditTextWindow();
                        manipulateTextWindow.Show();
                        break;

                    default:
                        EditTextWindow editTextWindow = new EditTextWindow();
                        editTextWindow.Show();
                        break;
                    }
                }
            }
        }