public void RenamingProfile(string oldName, string newName) { if (string.IsNullOrEmpty(oldName)) { return; } if (userConfigManager.Config.LastBatchSettings != null) { if (userConfigManager.Config.LastBatchSettings.ProfileDisplayName == oldName) { userConfigManager.Config.LastBatchSettings.ProfileDisplayName = newName; userConfigManager.Save(); } } }
private void OnClosed(object sender, EventArgs eventArgs) { if (SaveFormState) { UserConfigManager.Save(); } }
private void btnOK_Click(object sender, EventArgs e) { UserConfigManager.Config.EnableOcr = checkBoxEnableOcr.Checked; UserConfigManager.Config.OcrLanguageCode = (string)comboLanguages.SelectedValue; UserConfigManager.Save(); Close(); }
private void SaveImages(List <IScannedImage> images) { if (images.Any()) { var sd = new SaveFileDialog { OverwritePrompt = false, AddExtension = true, Filter = MiscResources.FileTypeBmp + "|*.bmp|" + MiscResources.FileTypeEmf + "|*.emf|" + MiscResources.FileTypeExif + "|*.exif|" + MiscResources.FileTypeGif + "|*.gif|" + MiscResources.FileTypeJpeg + "|*.jpg;*.jpeg|" + MiscResources.FileTypePng + "|*.png|" + MiscResources.FileTypeTiff + "|*.tiff;*.tif", FileName = imageSettingsContainer.ImageSettings.DefaultFileName }; switch ((UserConfigManager.Config.LastImageExt ?? "").ToLowerInvariant()) { case "bmp": sd.FilterIndex = 1; break; case "emf": sd.FilterIndex = 2; break; case "exif": sd.FilterIndex = 3; break; case "gif": sd.FilterIndex = 4; break; case "png": sd.FilterIndex = 6; break; case "tif": case "tiff": sd.FilterIndex = 7; break; default: // Jpeg sd.FilterIndex = 5; break; } if (sd.ShowDialog() == DialogResult.OK) { UserConfigManager.Config.LastImageExt = (Path.GetExtension(sd.FileName) ?? "").Replace(".", ""); UserConfigManager.Save(); imageSaver.SaveImages(sd.FileName, DateTime.Now, images, i => true); changeTracker.HasUnsavedChanges = false; } } }
private void ChooseSystem(string clientName) { UserConfigManager.Config.EmailSetup = UserConfigManager.Config.EmailSetup ?? new EmailSetup(); UserConfigManager.Config.EmailSetup.SystemProviderName = clientName == defaultSystemClientName ? null : clientName; UserConfigManager.Config.EmailSetup.ProviderType = EmailProviderType.System; UserConfigManager.Save(); DialogResult = DialogResult.OK; Close(); }
private void btnOK_Click(object sender, EventArgs e) { if (appConfigManager.Config.OcrState == OcrState.UserConfig) { UserConfigManager.Config.EnableOcr = checkBoxEnableOcr.Checked; UserConfigManager.Config.OcrLanguageCode = (string)comboLanguages.SelectedValue; UserConfigManager.Config.OcrMode = availableModes != null ? (OcrMode)comboOcrMode.SelectedItem : OcrMode.Default; UserConfigManager.Config.OcrAfterScanning = checkBoxRunInBG.Checked; UserConfigManager.Save(); } Close(); }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show(string.Format(MiscResources.ConfirmDelete, comboName.Text), MiscResources.Delete, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { var presets = UserConfigManager.Config.CustomPageSizePresets; presets.RemoveAll(x => x.Name == comboName.Text); UserConfigManager.Save(); UpdateDropdown(); comboName.Text = ""; UpdateDimens(initialDimens); } }
private void btnDelete_Click(object sender, EventArgs e) { if (MessageBox.Show(string.Format(MiscResources.ConfirmDelete, comboName.Text), MiscResources.Delete, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { var savedProxies = UserConfigManager.Config.SavedProxies; savedProxies.RemoveAll(x => x.Name == comboName.Text); UserConfigManager.Save(); ProxyConfig = new ScanProxyConfig(); UpdateDropdown(); UpdateControls(); } }
private void btnOK_Click(object sender, EventArgs e) { var emailSettings = new EmailSettings { AttachmentName = txtAttachmentName.Text }; emailSettingsContainer.EmailSettings = emailSettings; UserConfigManager.Config.EmailSettings = cbRememberSettings.Checked ? emailSettings : null; UserConfigManager.Save(); Close(); }
private void SetCulture(string cultureId) { UserConfigManager.Config.Culture = cultureId; UserConfigManager.Save(); Thread.CurrentThread.CurrentCulture = new CultureInfo(cultureId); Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureId); // Update localized values // Since all forms are opened modally and this is the root form, it should be the only one that needs to be updated live SaveFormState = false; Controls.RemoveAll(); UpdateRTL(); InitializeComponent(); PostInitializeComponent(); UpdateThumbnails(); Focus(); WindowState = FormWindowState.Normal; DoRestoreFormState(); SaveFormState = true; }
private void btnOK_Click(object sender, EventArgs e) { if (!cbUseProxy.Checked) { ProxyConfig = null; DialogResult = DialogResult.OK; Close(); return; } const NumberStyles numberStyle = NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingSign; if (string.IsNullOrWhiteSpace(txtIP.Text) || txtIP.Text.Contains('/')) { txtIP.Focus(); return; } if (!int.TryParse(txtPort.Text, numberStyle, CultureInfo.CurrentCulture, out int port)) { txtPort.Focus(); return; } ProxyConfig = new ScanProxyConfig { Name = comboName.Text, Ip = txtIP.Text, Port = port }; if (!string.IsNullOrWhiteSpace(comboName.Text)) { var savedProxies = UserConfigManager.Config.SavedProxies; savedProxies.RemoveAll(x => x.Name == ProxyConfig.Name); savedProxies.Add(ProxyConfig); UserConfigManager.Save(); } DialogResult = DialogResult.OK; Close(); }
private void btnOK_Click(object sender, EventArgs e) { const NumberStyles numberStyle = NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands | NumberStyles.AllowLeadingWhite | NumberStyles.AllowTrailingSign; decimal width, height; if (!decimal.TryParse(textboxWidth.Text, numberStyle, CultureInfo.CurrentCulture, out width)) { textboxWidth.Focus(); return; } if (!decimal.TryParse(textboxHeight.Text, numberStyle, CultureInfo.CurrentCulture, out height)) { textboxHeight.Focus(); return; } PageSizeName = null; PageSizeDimens = new PageDimensions { Width = width, Height = height, Unit = (PageSizeUnit)comboUnit.SelectedIndex }; if (!string.IsNullOrWhiteSpace(comboName.Text)) { PageSizeName = comboName.Text; var presets = UserConfigManager.Config.CustomPageSizePresets; presets.RemoveAll(x => x.Name == PageSizeName); presets.Add(new NamedPageSize { Name = PageSizeName, Dimens = PageSizeDimens }); UserConfigManager.Save(); } DialogResult = DialogResult.OK; Close(); }
private void ResizeThumbnails(int thumbnailSize) { if (!imageList.Images.Any()) { // Can't show visual feedback so don't do anything return; } // Save the new size to config UserConfigManager.Config.ThumbnailSize = thumbnailSize; UserConfigManager.Save(); UpdateToolbar(); // Adjust the visible thumbnail display with the new size thumbnailList1.ThumbnailSize = new Size(thumbnailSize, thumbnailSize); thumbnailList1.RegenerateThumbnailList(imageList.Images); // Render high-quality thumbnails at the new size in a background task // The existing (poorly scaled) thumbnails are used in the meantime if (renderThumbnailsCts != null) { // Cancel any previous task so that no two run at the same time renderThumbnailsCts.Cancel(); } var imagesToRenderThumbnailsFor = imageList.Images.ToList(); renderThumbnailsCts = new CancellationTokenSource(); var ct = renderThumbnailsCts.Token; Task.Factory.StartNew(() => { foreach (var img in imagesToRenderThumbnailsFor) { if (ct.IsCancellationRequested) { break; } // Save the state to check later for concurrent changes var oldState = img.GetThumbnailState(); // Render the thumbnail Bitmap thumbnail; try { thumbnail = img.RenderThumbnail(thumbnailSize); } catch { // An error occurred, which could mean the image was deleted // In any case we don't need to worry too much about it and can move on to the next continue; } // Do the rest of the stuff on the UI thread to help with synchronization Invoke(new Action(() => { if (ct.IsCancellationRequested) { return; } // Check for concurrent transformations if (oldState != img.GetThumbnailState()) { // The thumbnail has been concurrently updated return; } // Checks passed, so use the newly rendered thumbnail at the appropriate index img.SetThumbnail(thumbnail); int index = imageList.Images.IndexOf(img); if (index != -1) { thumbnailList1.ReplaceThumbnail(index, thumbnail); } })); } }, ct); }