Exemple #1
0
 /// <summary>
 /// Run wizard
 /// </summary>
 /// <param name="args">Command line arguments</param>
 /// <returns>Exit code</returns>
 static int RunWizard(ArgsWizard args = null)
 {
     if (RegistryUtil.IsAppRegistered())
     {
         RegistryUtil.RegisterApp(); // overwrites default entry with localized strings
     }
     Application.Run(new Wizard());
     return(0);
 }
Exemple #2
0
        public Wizard()
        {
            InitializeComponent();

            foreach (Control element in GetAllChild(this))
            {
                // ReSharper disable once UnusedVariable (to convince IDE that these resource strings are actually used)
                string[] usedResourceStrings = { Resources.str_wizard_title, Resources.str_wizard_contextentry_title, Resources.str_wizard_contextentry_info, Resources.str_wizard_contextentry_button, Resources.str_wizard_autosave_title, Resources.str_wizard_autosave_info, Resources.str_wizard_autosave_button, Resources.str_wizard_finish };
                element.Text = Resources.ResourceManager.GetString(element.Text) ?? element.Text;
            }

            Icon = Resources.icon;
            Text = Resources.str_main_window_title;

            version.Text = string.Format(Resources.str_version, ProductVersion);

            chkAutoSave.Checked     = Settings.Default.autoSave;
            chkContextEntry.Checked = RegistryUtil.IsAppRegistered();
        }
Exemple #3
0
 private void ChkContextEntry_CheckedChanged(object sender, EventArgs e)
 {
     try
     {
         if (chkContextEntry.Checked && !RegistryUtil.IsAppRegistered())
         {
             RegistryUtil.RegisterApp();
             MessageBox.Show(Resources.str_message_register_context_menu_success, Resources.str_main_window_title, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else if (!chkContextEntry.Checked && RegistryUtil.IsAppRegistered())
         {
             RegistryUtil.UnRegisterApp();
             MessageBox.Show(Resources.str_message_unregister_context_menu_success, Resources.str_main_window_title, MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message + "\n" + Resources.str_message_run_as_admin, Resources.str_main_window_title, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #4
0
 /// <summary>
 /// Run only config update
 /// </summary>
 /// <param name="args">Command line arguments</param>
 /// <returns>Exit code</returns>
 static int RunConfig(ArgsConfig args)
 {
     ApplyCommonArgs(args);
     try
     {
         if (args.Register)
         {
             RegistryUtil.RegisterApp();
         }
         if (args.Unregister)
         {
             RegistryUtil.UnRegisterApp();
         }
     }
     catch (Exception ex)
     {
         Console.Error.WriteLine(ex.Message + "\n" + Resources.str_message_run_as_admin);
         return(1);
     }
     return(0);
 }
Exemple #5
0
        public Dialog(string location, bool forceShowDialog = false)
        {
            // always show GUI if shift pressed during start
            forceShowDialog |= ModifierKeys == Keys.Shift;

            // Setup GUI
            InitializeComponent();

            foreach (Control element in GetAllChild(this))
            {
                if (element is WebBrowser)
                {
                    continue;
                }
                // ReSharper disable once UnusedVariable (to convince IDE that these resource strings are actually used)
                string[] usedResourceStrings = { Resources.str_filename, Resources.str_extension, Resources.str_location, Resources.str_clear_clipboard, Resources.str_save, Resources.str_preview, Resources.str_main_info, Resources.str_autosave_checkbox, Resources.str_contextentry_checkbox, Resources.str_continuous_mode };
                element.Text = Resources.ResourceManager.GetString(element.Text) ?? element.Text;
            }

            Icon           = Resources.icon;
            Text           = Resources.str_main_window_title;
            infoLabel.Text = string.Format(Resources.str_version, ProductVersion);


            // Dark theme
            if (RegistryUtil.IsDarkMode())
            {
                foreach (Control element in GetAllChild(this))
                {
                    element.ForeColor = Color.White;
                    element.BackColor = Color.FromArgb(53, 53, 53);
                }

                BackColor = Color.FromArgb(24, 24, 24);
            }

            // read clipboard and populate GUI
            comExt.Text = "*"; // force to use extension based on format type
            var clipRead = readClipboard();

            updateFilename();
            txtCurrentLocation.Text   = Path.GetFullPath(location);
            chkClrClipboard.Checked   = Settings.Default.clrClipboard;
            chkContinuousMode.Checked = continuousMode;
            updateSavebutton();
            chkAutoSave.Checked     = Settings.Default.autoSave;
            chkContextEntry.Checked = RegistryUtil.IsAppRegistered();


            txtFilename.Select();

            // show dialog or autosave option
            if (forceShowDialog)
            {
                // Make sure to bring window to foreground (holding shift will open window in background)
                WindowState = FormWindowState.Minimized;
                Show();
                BringToFront();
                WindowState = FormWindowState.Normal;
            }
            // otherwise perform autosave if enabled
            else if (Settings.Default.autoSave)
            {
                var file = clipRead ? save() : null;
                if (file != null)
                {
                    ExplorerUtil.RequestFilenameEdit(file);

                    var message = string.Format(Resources.str_autosave_balloontext, file);
                    Program.ShowBalloon(Resources.str_autosave_balloontitle, message, 10_000);

                    Environment.Exit(0);
                }
                else
                {
                    Environment.Exit(1);
                }
            }

            // register clipboard monitor
            clipMonitor.ClipboardChanged += ClipboardChanged;
        }