예제 #1
0
        private void ConfigureWindowsStoreStartup()
        {
            if (cbStartWithWindows.Enabled)
            {
                cbStartWithWindows.Enabled           = false;
                lblWindowsStoreStartupStatus.Text    = "Configuring startup...";
                lblWindowsStoreStartupStatus.Visible = true;

                bool             enable = cbStartWithWindows.Checked;
                StartupTaskState state  = StartupTaskState.Error;

                TaskEx.Run(() =>
                {
                    state = IntegrationHelpers.ConfigureStartupWindowsStore(enable);
                },
                           () =>
                {
                    if (!IsDisposed)
                    {
                        if (state == StartupTaskState.Error)
                        {
                            lblWindowsStoreStartupStatus.Text = "Startup configuration failed. Check debug log for more info.";
                        }
                        else if (state == StartupTaskState.DisabledByUser)
                        {
                            lblWindowsStoreStartupStatus.Text = "The startup has been disabled by the user.";
                        }
                        else
                        {
                            lblWindowsStoreStartupStatus.Visible = false;
                            cbStartWithWindows.Enabled           = true;
                        }
                    }
                });
            }
        }
예제 #2
0
        private void UpdateControls()
        {
            ready = false;

            // General
            ChangeLanguage(Program.Settings.Language);

            cbShowTray.Checked  = Program.Settings.ShowTray;
            cbSilentRun.Enabled = Program.Settings.ShowTray;
            cbSilentRun.Checked = Program.Settings.SilentRun;
            cbTrayIconProgressEnabled.Checked  = Program.Settings.TrayIconProgressEnabled;
            cbTaskbarProgressEnabled.Enabled   = TaskbarManager.IsPlatformSupported;
            cbTaskbarProgressEnabled.Checked   = Program.Settings.TaskbarProgressEnabled;
            cbRememberMainFormPosition.Checked = Program.Settings.RememberMainFormPosition;
            cbRememberMainFormSize.Checked     = Program.Settings.RememberMainFormSize;

            cbTrayLeftDoubleClickAction.SelectedIndex = (int)Program.Settings.TrayLeftDoubleClickAction;
            cbTrayLeftClickAction.SelectedIndex       = (int)Program.Settings.TrayLeftClickAction;
            cbTrayMiddleClickAction.SelectedIndex     = (int)Program.Settings.TrayMiddleClickAction;

            cbCheckPreReleaseUpdates.Checked = Program.Settings.CheckPreReleaseUpdates;

            // Integration
            cbStartWithWindows.Checked = IntegrationHelpers.CheckStartupShortcut();
            cbShellContextMenu.Checked = IntegrationHelpers.CheckShellContextMenuButton();
            cbSendToMenu.Checked       = IntegrationHelpers.CheckSendToMenuButton();

#if STEAM
            cbSteamShowInApp.Checked = IntegrationHelpers.CheckSteamShowInApp();
#else
            gbSteam.Visible = false;
#endif

            // Paths
            txtPersonalFolderPath.Text = Program.ReadPersonalPathConfig();
            UpdatePersonalFolderPathPreview();
            cbUseCustomScreenshotsPath.Checked = Program.Settings.UseCustomScreenshotsPath;
            txtCustomScreenshotsPath.Text      = Program.Settings.CustomScreenshotsPath;
            txtSaveImageSubFolderPattern.Text  = Program.Settings.SaveImageSubFolderPattern;

            // Export / Import
            cbExportSettings.Checked = Program.Settings.ExportSettings;
            cbExportHistory.Checked  = Program.Settings.ExportHistory;
            cbExportLogs.Checked     = Program.Settings.ExportLogs;
            UpdateExportButton();

            // Proxy
            cbProxyMethod.SelectedIndex = (int)Program.Settings.ProxySettings.ProxyMethod;
            txtProxyUsername.Text       = Program.Settings.ProxySettings.Username;
            txtProxyPassword.Text       = Program.Settings.ProxySettings.Password;
            txtProxyHost.Text           = Program.Settings.ProxySettings.Host ?? "";
            nudProxyPort.SetValue(Program.Settings.ProxySettings.Port);
            UpdateProxyControls();

            // Upload
            nudUploadLimit.SetValue(Program.Settings.UploadLimit);

            cbBufferSize.Items.Clear();
            for (int i = 0; i < MaxBufferSizePower; i++)
            {
                string size = ((long)(Math.Pow(2, i) * 1024)).ToSizeString(Program.Settings.BinaryUnits, 0);
                cbBufferSize.Items.Add(size);
            }

            cbBufferSize.SelectedIndex = Program.Settings.BufferSizePower.Between(0, MaxBufferSizePower);

            lvClipboardFormats.Items.Clear();
            foreach (ClipboardFormat cf in Program.Settings.ClipboardContentFormats)
            {
                AddClipboardFormat(cf);
            }

            nudRetryUpload.SetValue(Program.Settings.MaxUploadFailRetry);
            chkUseSecondaryUploaders.Checked = Program.Settings.UseSecondaryUploaders;
            tlpBackupDestinations.Enabled    = Program.Settings.UseSecondaryUploaders;

            Program.Settings.SecondaryImageUploaders.AddRange(Helpers.GetEnums <ImageDestination>().Where(n => Program.Settings.SecondaryImageUploaders.All(e => e != n)));
            Program.Settings.SecondaryTextUploaders.AddRange(Helpers.GetEnums <TextDestination>().Where(n => Program.Settings.SecondaryTextUploaders.All(e => e != n)));
            Program.Settings.SecondaryFileUploaders.AddRange(Helpers.GetEnums <FileDestination>().Where(n => Program.Settings.SecondaryFileUploaders.All(e => e != n)));

            Program.Settings.SecondaryImageUploaders.Where(n => Helpers.GetEnums <ImageDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryImageUploaders.Remove(x));
            Program.Settings.SecondaryTextUploaders.Where(n => Helpers.GetEnums <TextDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryTextUploaders.Remove(x));
            Program.Settings.SecondaryFileUploaders.Where(n => Helpers.GetEnums <FileDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryFileUploaders.Remove(x));

            lvSecondaryImageUploaders.Items.Clear();
            Program.Settings.SecondaryImageUploaders.ForEach <ImageDestination>(x => lvSecondaryImageUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));
            lvSecondaryTextUploaders.Items.Clear();
            Program.Settings.SecondaryTextUploaders.ForEach <TextDestination>(x => lvSecondaryTextUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));
            lvSecondaryFileUploaders.Items.Clear();
            Program.Settings.SecondaryFileUploaders.ForEach <FileDestination>(x => lvSecondaryFileUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));

            // History
            cbHistorySaveTasks.Checked = Program.Settings.HistorySaveTasks;
            cbHistoryCheckURL.Checked  = Program.Settings.HistoryCheckURL;

            cbRecentTasksSave.Checked = Program.Settings.RecentTasksSave;
            nudRecentTasksMaxCount.SetValue(Program.Settings.RecentTasksMaxCount);
            cbRecentTasksShowInMainWindow.Checked        = Program.Settings.RecentTasksShowInMainWindow;
            cbRecentTasksShowInTrayMenu.Checked          = Program.Settings.RecentTasksShowInTrayMenu;
            cbRecentTasksTrayMenuMostRecentFirst.Checked = Program.Settings.RecentTasksTrayMenuMostRecentFirst;

            // Print
            cbDontShowPrintSettingDialog.Checked = Program.Settings.DontShowPrintSettingsDialog;
            cbPrintDontShowWindowsDialog.Checked = !Program.Settings.PrintSettings.ShowPrintDialog;

            // Advanced
            pgSettings.SelectedObject = Program.Settings;

            tttvMain.MainTabControl = tcSettings;

            ready = true;
        }
예제 #3
0
        private void UpdateControls()
        {
            ready = false;

            // General
            ChangeLanguage(Program.Settings.Language);

            cbShowTray.Checked  = Program.Settings.ShowTray;
            cbSilentRun.Enabled = Program.Settings.ShowTray;
            cbSilentRun.Checked = Program.Settings.SilentRun;
            cbTrayIconProgressEnabled.Checked  = Program.Settings.TrayIconProgressEnabled;
            cbTaskbarProgressEnabled.Enabled   = TaskbarManager.IsPlatformSupported;
            cbTaskbarProgressEnabled.Checked   = Program.Settings.TaskbarProgressEnabled;
            cbUseCustomTheme.Checked           = Program.Settings.UseCustomTheme;
            cbUseWhiteShareXIcon.Checked       = Program.Settings.UseWhiteShareXIcon;
            cbRememberMainFormPosition.Checked = Program.Settings.RememberMainFormPosition;
            cbRememberMainFormSize.Checked     = Program.Settings.RememberMainFormSize;

            cbTrayLeftDoubleClickAction.SelectedIndex = (int)Program.Settings.TrayLeftDoubleClickAction;
            cbTrayLeftClickAction.SelectedIndex       = (int)Program.Settings.TrayLeftClickAction;
            cbTrayMiddleClickAction.SelectedIndex     = (int)Program.Settings.TrayMiddleClickAction;

#if STEAM || WindowsStore
            cbCheckPreReleaseUpdates.Visible = false;
            btnCheckDevBuild.Visible         = false;
#else
            cbCheckPreReleaseUpdates.Checked = Program.Settings.CheckPreReleaseUpdates;
#endif

            // Theme
            cbThemes.Items.AddRange(Program.Settings.Themes.ToArray());
            cbThemes.SelectedIndex = Program.Settings.SelectedTheme;
            pgTheme.SelectedObject = Program.Settings.Themes[Program.Settings.SelectedTheme];
            UpdateThemeControls();

            // Integration
#if WindowsStore
            cbShellContextMenu.Visible = false;
            cbEditWithShareX.Visible   = false;
            cbSendToMenu.Visible       = false;
            gbChrome.Visible           = false;
            gbFirefox.Visible          = false;
#else
            cbShellContextMenu.Checked         = IntegrationHelpers.CheckShellContextMenuButton();
            cbEditWithShareX.Checked           = IntegrationHelpers.CheckEditShellContextMenuButton();
            cbSendToMenu.Checked               = IntegrationHelpers.CheckSendToMenuButton();
            cbChromeExtensionSupport.Checked   = IntegrationHelpers.CheckChromeExtensionSupport();
            btnChromeOpenExtensionPage.Enabled = cbChromeExtensionSupport.Checked;
            cbFirefoxAddonSupport.Checked      = IntegrationHelpers.CheckFirefoxAddonSupport();
            btnFirefoxOpenAddonPage.Enabled    = cbFirefoxAddonSupport.Checked;
#endif

#if STEAM
            cbSteamShowInApp.Checked = IntegrationHelpers.CheckSteamShowInApp();
#else
            gbSteam.Visible = false;
#endif

            // Paths
            lastPersonalPath           = Program.ReadPersonalPathConfig();
            txtPersonalFolderPath.Text = lastPersonalPath;
            UpdatePersonalFolderPathPreview();
            cbUseCustomScreenshotsPath.Checked = Program.Settings.UseCustomScreenshotsPath;
            txtCustomScreenshotsPath.Text      = Program.Settings.CustomScreenshotsPath;
            txtSaveImageSubFolderPattern.Text  = Program.Settings.SaveImageSubFolderPattern;

            // Settings
            cbAutomaticallyCleanupBackupFiles.Checked = Program.Settings.AutoCleanupBackupFiles;
            cbAutomaticallyCleanupLogFiles.Checked    = Program.Settings.AutoCleanupLogFiles;
            nudCleanupKeepFileCount.SetValue(Program.Settings.CleanupKeepFileCount);

            // Proxy
            cbProxyMethod.SelectedIndex = (int)Program.Settings.ProxySettings.ProxyMethod;
            txtProxyUsername.Text       = Program.Settings.ProxySettings.Username;
            txtProxyPassword.Text       = Program.Settings.ProxySettings.Password;
            txtProxyHost.Text           = Program.Settings.ProxySettings.Host ?? "";
            nudProxyPort.SetValue(Program.Settings.ProxySettings.Port);
            UpdateProxyControls();

            // Upload
            nudUploadLimit.SetValue(Program.Settings.UploadLimit);

            cbBufferSize.Items.Clear();
            int maxBufferSizePower = 14;
            for (int i = 0; i < maxBufferSizePower; i++)
            {
                string size = ((long)(Math.Pow(2, i) * 1024)).ToSizeString(Program.Settings.BinaryUnits, 0);
                cbBufferSize.Items.Add(size);
            }
            cbBufferSize.SelectedIndex = Program.Settings.BufferSizePower.Clamp(0, maxBufferSizePower);

            lvClipboardFormats.Items.Clear();
            foreach (ClipboardFormat cf in Program.Settings.ClipboardContentFormats)
            {
                AddClipboardFormat(cf);
            }

            nudRetryUpload.SetValue(Program.Settings.MaxUploadFailRetry);
            chkUseSecondaryUploaders.Checked  = Program.Settings.UseSecondaryUploaders;
            gbSecondaryImageUploaders.Enabled = gbSecondaryTextUploaders.Enabled = gbSecondaryFileUploaders.Enabled = Program.Settings.UseSecondaryUploaders;

            Program.Settings.SecondaryImageUploaders.AddRange(Helpers.GetEnums <ImageDestination>().Where(n => Program.Settings.SecondaryImageUploaders.All(e => e != n)));
            Program.Settings.SecondaryTextUploaders.AddRange(Helpers.GetEnums <TextDestination>().Where(n => Program.Settings.SecondaryTextUploaders.All(e => e != n)));
            Program.Settings.SecondaryFileUploaders.AddRange(Helpers.GetEnums <FileDestination>().Where(n => Program.Settings.SecondaryFileUploaders.All(e => e != n)));

            Program.Settings.SecondaryImageUploaders.Where(n => Helpers.GetEnums <ImageDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryImageUploaders.Remove(x));
            Program.Settings.SecondaryTextUploaders.Where(n => Helpers.GetEnums <TextDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryTextUploaders.Remove(x));
            Program.Settings.SecondaryFileUploaders.Where(n => Helpers.GetEnums <FileDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryFileUploaders.Remove(x));

            lvSecondaryImageUploaders.Items.Clear();
            Program.Settings.SecondaryImageUploaders.ForEach <ImageDestination>(x => lvSecondaryImageUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));
            lvSecondaryTextUploaders.Items.Clear();
            Program.Settings.SecondaryTextUploaders.ForEach <TextDestination>(x => lvSecondaryTextUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));
            lvSecondaryFileUploaders.Items.Clear();
            Program.Settings.SecondaryFileUploaders.ForEach <FileDestination>(x => lvSecondaryFileUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));

            // History
            cbHistorySaveTasks.Checked = Program.Settings.HistorySaveTasks;
            cbHistoryCheckURL.Checked  = Program.Settings.HistoryCheckURL;

            cbRecentTasksSave.Checked = Program.Settings.RecentTasksSave;
            nudRecentTasksMaxCount.SetValue(Program.Settings.RecentTasksMaxCount);
            cbRecentTasksShowInMainWindow.Checked        = Program.Settings.RecentTasksShowInMainWindow;
            cbRecentTasksShowInTrayMenu.Checked          = Program.Settings.RecentTasksShowInTrayMenu;
            cbRecentTasksTrayMenuMostRecentFirst.Checked = Program.Settings.RecentTasksTrayMenuMostRecentFirst;

            // Print
            cbDontShowPrintSettingDialog.Checked = Program.Settings.DontShowPrintSettingsDialog;
            cbPrintDontShowWindowsDialog.Checked = !Program.Settings.PrintSettings.ShowPrintDialog;

            // Advanced
            pgSettings.SelectedObject = Program.Settings;

            tttvMain.MainTabControl = tcSettings;

            ready = true;
        }
예제 #4
0
        private void LoadSettings()
        {
            // General

            foreach (SupportedLanguage language in Helpers.GetEnums <SupportedLanguage>())
            {
                ToolStripMenuItem tsmi = new ToolStripMenuItem(language.GetLocalizedDescription());
                tsmi.Image        = GetLanguageIcon(language);
                tsmi.ImageScaling = ToolStripItemImageScaling.None;
                SupportedLanguage lang = language;
                tsmi.Click += (sender, e) => ChangeLanguage(lang);
                cmsLanguages.Items.Add(tsmi);
            }

            ChangeLanguage(Program.Settings.Language);

            cbShowTray.Checked  = Program.Settings.ShowTray;
            cbSilentRun.Enabled = Program.Settings.ShowTray;
            cbSilentRun.Checked = Program.Settings.SilentRun;
            cbTrayIconProgressEnabled.Checked  = Program.Settings.TrayIconProgressEnabled;
            cbTaskbarProgressEnabled.Enabled   = TaskbarManager.IsPlatformSupported;
            cbTaskbarProgressEnabled.Checked   = Program.Settings.TaskbarProgressEnabled;
            cbRememberMainFormPosition.Checked = Program.Settings.RememberMainFormPosition;
            cbRememberMainFormSize.Checked     = Program.Settings.RememberMainFormSize;

            // Integration
            cbStartWithWindows.Checked = IntegrationHelpers.CheckStartupShortcut();
            cbShellContextMenu.Checked = IntegrationHelpers.CheckShellContextMenuButton();
            cbSendToMenu.Checked       = IntegrationHelpers.CheckSendToMenuButton();

#if STEAM
            cbSteamShowInApp.Checked = IntegrationHelpers.CheckSteamShowInApp();
#else
            gbSteam.Visible = false;
#endif

            // Paths
            txtPersonalFolderPath.Text = Program.ReadPersonalPathConfig();
            UpdatePersonalFolderPathPreview();
            cbUseCustomScreenshotsPath.Checked = Program.Settings.UseCustomScreenshotsPath;
            txtCustomScreenshotsPath.Text      = Program.Settings.CustomScreenshotsPath;
            txtSaveImageSubFolderPattern.Text  = Program.Settings.SaveImageSubFolderPattern;
            CodeMenu.Create <ReplCodeMenuEntry>(txtSaveImageSubFolderPattern, ReplCodeMenuEntry.t, ReplCodeMenuEntry.pn, ReplCodeMenuEntry.i,
                                                ReplCodeMenuEntry.width, ReplCodeMenuEntry.height, ReplCodeMenuEntry.n);

            // Proxy
            cbProxyMethod.Items.AddRange(Helpers.GetLocalizedEnumDescriptions <ProxyMethod>());
            cbProxyMethod.SelectedIndex = (int)Program.Settings.ProxySettings.ProxyMethod;
            txtProxyUsername.Text       = Program.Settings.ProxySettings.Username;
            txtProxyPassword.Text       = Program.Settings.ProxySettings.Password;
            txtProxyHost.Text           = Program.Settings.ProxySettings.Host ?? string.Empty;
            nudProxyPort.Value          = Program.Settings.ProxySettings.Port;
            UpdateProxyControls();

            // Upload
            nudUploadLimit.Value = Program.Settings.UploadLimit;

            for (int i = 0; i < MaxBufferSizePower; i++)
            {
                string size = ((long)(Math.Pow(2, i) * 1024)).ToSizeString(Program.Settings.BinaryUnits, 0);
                cbBufferSize.Items.Add(size);
            }

            cbBufferSize.SelectedIndex = Program.Settings.BufferSizePower.Between(0, MaxBufferSizePower);

            foreach (ClipboardFormat cf in Program.Settings.ClipboardContentFormats)
            {
                AddClipboardFormat(cf);
            }

            nudRetryUpload.Value             = Program.Settings.MaxUploadFailRetry;
            chkUseSecondaryUploaders.Checked = Program.Settings.UseSecondaryUploaders;
            tlpBackupDestinations.Enabled    = Program.Settings.UseSecondaryUploaders;

            Program.Settings.SecondaryImageUploaders.AddRange(Helpers.GetEnums <ImageDestination>().Where(n => Program.Settings.SecondaryImageUploaders.All(e => e != n)));
            Program.Settings.SecondaryTextUploaders.AddRange(Helpers.GetEnums <TextDestination>().Where(n => Program.Settings.SecondaryTextUploaders.All(e => e != n)));
            Program.Settings.SecondaryFileUploaders.AddRange(Helpers.GetEnums <FileDestination>().Where(n => Program.Settings.SecondaryFileUploaders.All(e => e != n)));

            Program.Settings.SecondaryImageUploaders.Where(n => Helpers.GetEnums <ImageDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryImageUploaders.Remove(x));
            Program.Settings.SecondaryTextUploaders.Where(n => Helpers.GetEnums <TextDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryTextUploaders.Remove(x));
            Program.Settings.SecondaryFileUploaders.Where(n => Helpers.GetEnums <FileDestination>().All(e => e != n)).ForEach(x => Program.Settings.SecondaryFileUploaders.Remove(x));

            Program.Settings.SecondaryImageUploaders.ForEach <ImageDestination>(x => lvSecondaryImageUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));
            Program.Settings.SecondaryTextUploaders.ForEach <TextDestination>(x => lvSecondaryTextUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));
            Program.Settings.SecondaryFileUploaders.ForEach <FileDestination>(x => lvSecondaryFileUploaders.Items.Add(new ListViewItem(x.GetLocalizedDescription())
            {
                Tag = x
            }));

            // Print
            cbDontShowPrintSettingDialog.Checked = Program.Settings.DontShowPrintSettingsDialog;
            cbPrintDontShowWindowsDialog.Checked = !Program.Settings.PrintSettings.ShowPrintDialog;

            // Advanced
            pgSettings.SelectedObject = Program.Settings;

            tttvMain.MainTabControl = tcSettings;
        }