예제 #1
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;
            cbUseDarkTheme.Checked             = Program.Settings.UseDarkTheme;
            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

            // 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;

            // 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;
        }