/// <summary> /// Raise the System.Windows.Forms.Form.Closing event /// </summary> /// <param name="e">CancelEventArgs containing the event data</param> protected override void OnClosing(CancelEventArgs e) { base.OnClosing(e); // Catch ok button press if (this.DialogResult != DialogResult.OK) { return; } this.errorProvider1.Clear(); foreach (TextBox textbox in this.directories) { // the directory must exist if not empty if (textbox.Text.Length > 0 && !System.IO.Directory.Exists(textbox.Text)) { this.errorProvider1.SetError(textbox, Resource.GetString("Invalid Directory")); e.Cancel = true; } } int width; if (this.textBoxWidth.Text.Length > 0) { if (!int.TryParse(this.textBoxWidth.Text, out width) || width < 1) { this.errorProvider1.SetError(this.textBoxHeight, Resource.GetString("Invalid Output Size")); e.Cancel = true; } } else { width = -1; } int height; if (this.textBoxHeight.Text.Length > 0) { if (!int.TryParse(this.textBoxHeight.Text, out height) || height < 1) { this.errorProvider1.SetError(this.textBoxHeight, Resource.GetString("Invalid Output Size")); e.Cancel = true; } } else { height = -1; } if (width == -1 && height == -1) { this.errorProvider1.SetError(this.textBoxHeight, Resource.GetString("Invalid Output Size")); e.Cancel = true; } if (!e.Cancel) { this.OutputSize = new Size(width, height); } }
/// <summary> /// Updates the title. /// </summary> private void UpdateTitle() { int amount = (int)(((float)this.zoom.Amount * 100f) + 0.5); this.Text = Resource.GetString("Colour Preview") + " (" + amount + "%)"; }