public void Dispose() { _errorProvider?.Dispose(); _control2?.Dispose(); _control1?.Dispose(); _form?.Dispose(); }
private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { errorProvider?.Dispose(); } disposedValue = true; } }
private static void TryDispose(ErrorProvider errorProvider) { if (!(errorProvider.Tag is int)) { return; } var count = (int)errorProvider.Tag - 1; if (count == 0) { errorProvider.Dispose(); } else { errorProvider.Tag = count; } }
private bool Validation() { err.Dispose(); return(isemptyg(new Control[1] { tno }) && isselectedg(new ComboBox[1] { comboBoxvehicle }) && isemptyg(new Control[1] { tam }) && isselectedg(new ComboBox[1] { comboBoxpmode }) && isemptyg(new Control[1] { tdcode }) && iscorrectg(new TextBox[2] { tam, tdcode })); }
private void textBoxAmmounts_TextChanged(object i_Sender, EventArgs i_EventArgs) { Regex validation = new Regex(@"^([0-9]*)$"); if (!validation.IsMatch(textBoxAmmounts.Text)) { if (m_ErrorProvider == null) { m_ErrorProvider = new ErrorProvider(); m_ErrorProvider.SetError(textBoxAmmounts, "Invalid input! Must be positive number!"); } } else { m_ErrorProvider?.Dispose(); m_ErrorProvider = null; } }
public static string validateDataSources(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { eprWarning.SetIconPadding(control, 5); eprError.SetIconPadding(control, 5); string automatedValue = string.Empty; //Get and set the map value var dict = new Dictionary <string, string>(); dict = MapAction.PageLayoutProperties.getLayoutTextElements(_pMxDoc, targetMapFrame); //Update form text boxes with values from the map if (!dict.ContainsKey("data_sources")) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprWarning.SetError(control, "'data_sources' element not present page layout, cannot validate"); return("warning"); } else { automatedValue = dict["data_sources"]; if (validateEmptyField(control, eprWarning)) { if (control.Text.Trim() != automatedValue && control.Text != string.Empty) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Text differs from the 'data_sources' element on the page layout"); return("Error"); } else { eprError.SetError(control, ""); return("Valid"); } } else { eprError.Dispose(); validateEmptyField(control, eprWarning); return("Blank"); } } }
public static string validateMapDocument(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { eprWarning.SetIconPadding(control, 5); eprError.SetIconPadding(control, 5); string mapValue = string.Empty; string automatedValue = MapAction.PageLayoutProperties.getMxdTitle(ArcMap.Application); //Get and set the map value var dict = new Dictionary <string, string>(); dict = MapAction.PageLayoutProperties.getLayoutTextElements(_pMxDoc, targetMapFrame); //Update form text boxes with values from the map if (dict.ContainsKey("title")) { mapValue = dict["title"]; } if (validateEmptyField(control, eprWarning)) { if (control.Text.Trim() != automatedValue && control.Text.Trim() != mapValue && control.Text != string.Empty) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Text differs from the document title and or the 'title' element on the page layout"); return("Error"); } else { eprError.SetError(control, ""); return("Valid"); } } else { eprError.Dispose(); validateEmptyField(control, eprWarning); return("Blank"); } }
public static string validateProjection(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { eprWarning.SetIconPadding(control, 5); eprError.SetIconPadding(control, 5); // Set the spatial reference information on load var dictSpatialRef = new Dictionary <string, string>(); dictSpatialRef = MapAction.Utilities.getDataFrameSpatialReference(_pMxDoc, targetMapFrame); string automatedValue = string.Empty; if (dictSpatialRef.ContainsKey("projection")) { automatedValue = dictSpatialRef["projection"]; } if (validateEmptyField(control, eprWarning)) { if (control.Text.Trim() != automatedValue && control.Text != string.Empty) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Text differs from automated value"); return("Error"); } else { eprError.SetError(control, ""); return("Valid"); } } else { eprError.Dispose(); validateEmptyField(control, eprWarning); return("Blank"); } }
public static void validateMapDocument(Control control, ErrorProvider eprWarning, ErrorProvider eprError) { eprWarning.SetIconPadding(control, 33); eprError.SetIconPadding(control, 33); string automatedValue = MapAction.PageLayoutProperties.getMxdTitle(ArcMap.Application); if (validateEmptyField(control, eprWarning)) { if (control.Text.Trim() != automatedValue && control.Text != string.Empty) { eprError.SetIconAlignment(control, ErrorIconAlignment.MiddleRight); eprError.SetError(control, "Text differs from automated value"); } else { eprError.SetError(control, ""); } } else { eprError.Dispose(); validateEmptyField(control, eprWarning); } }
private void CreateAssemblyFile(object sender, EventArgs e) { RegexOptions options = RegexOptions.Compiled; if (compileErrorProvider != null) { compileErrorProvider.Dispose(); compileErrorProvider = null; } compileErrorProvider = new ErrorProvider(); // validate input bool error = false; if (((TextBox)ControlDictionary["ClassNameCompileTextBox"]).Text == "") { compileErrorProvider.SetError((TextBox)ControlDictionary["ClassNameCompileTextBox"], ResourceService.GetString("RegExpTk.Messages.ClassNameMissing")); error = true; } if (ControlDictionary["RegularExpressionCompileTextBox"].Text == "") { compileErrorProvider.SetError((TextBox)ControlDictionary["RegularExpressionCompileTextBox"], ResourceService.GetString("RegExpTk.Messages.RegexMissing")); error = true; } if (((TextBox)ControlDictionary["AssemblyFileCompileFileTextBox"]).Text == "") { compileErrorProvider.SetError((TextBox)ControlDictionary["AssemblyFileCompileFileTextBox"], ResourceService.GetString("RegExpTk.Messages.FilenameMissing")); error = true; } string file_ = ((TextBox)ControlDictionary["AssemblyFileCompileFileTextBox"]).Text; if (!FileUtility.IsValidPath(((TextBox)ControlDictionary["AssemblyFileCompileFileTextBox"]).Text)) { compileErrorProvider.SetError((TextBox)ControlDictionary["AssemblyFileCompileFileTextBox"], ResourceService.GetString("RegExpTk.Messages.FilenameInvalid")); error = true; } if (error) { return; } // set options if (((CheckBox)ControlDictionary["IgnoreCaseCompileCheckBox"]).Checked) { options = options | RegexOptions.IgnoreCase; } if (((CheckBox)ControlDictionary["SingleLineCompileCheckBox"]).Checked) { options = options | RegexOptions.Singleline; } if (((CheckBox)ControlDictionary["IgnoreWhitespaceCompileCheckBox"]).Checked) { options = options | RegexOptions.IgnorePatternWhitespace; } if (((CheckBox)ControlDictionary["ExplicitCaptureCompileCheckBox"]).Checked) { options = options | RegexOptions.ExplicitCapture; } if (((CheckBox)ControlDictionary["EcmaScriptCompileCheckBox"]).Checked) { options = options | RegexOptions.ECMAScript; } if (((CheckBox)ControlDictionary["MultilineCompileCheckBox"]).Checked) { options = options | RegexOptions.Multiline; } if (((CheckBox)ControlDictionary["RightToLeftCompileCheckBox"]).Checked) { options = options | RegexOptions.RightToLeft; } try { Regex re = new Regex(((TextBox)ControlDictionary["RegularExpressionCompileTextBox"]).Text, options); } catch (ArgumentException ae) { MessageService.ShowError(ResourceService.GetString("RegExpTk.Messages.CreationError") + " " + ae.Message); return; } RegexCompilationInfo rci = new RegexCompilationInfo(((TextBox)ControlDictionary["RegularExpressionCompileTextBox"]).Text, options, ((TextBox)ControlDictionary["ClassNameCompileTextBox"]).Text, ((TextBox)ControlDictionary["NamespaceCompileTextBox"]).Text, ((CheckBox)ControlDictionary["PublibVisibleCompileCheckBox"]).Checked); AssemblyName asmName = new AssemblyName(); asmName.Name = Path.GetFileNameWithoutExtension(((TextBox)ControlDictionary["AssemblyFileCompileFileTextBox"]).Text); RegexCompilationInfo[] rciArray = new RegexCompilationInfo[] { rci }; try { Regex.CompileToAssembly(rciArray, asmName); } catch (ArgumentException ae) { MessageService.ShowError(ResourceService.GetString("RegExpTk.Messages.CompilationError") + " " + ae.Message); return; } string aboluteFileName = FileUtility.NormalizePath(((TextBox)ControlDictionary["AssemblyFileCompileFileTextBox"]).Text); ((StatusBar)ControlDictionary["StatusBar"]).Text = ResourceService.GetString("RegExpTk.Messages.FileCreated") + " " + aboluteFileName; }
protected override void OnClosed(EventArgs e) { lErrorProvider.Dispose(); base.OnClosed(e); }
//Clear error providers (primarily on form close) public static void disposeErrorProvider(ErrorProvider epr) { epr.Dispose(); }
protected override void OnClosed(EventArgs e) { lErrorProvider.Dispose(); base.OnClosed(e); mbCancel_Click(this, e); }
public static void CekTextboxComboBox(Control control, ErrorProvider errorp) { errorp.Dispose(); CekCombobox(control, errorp); CekTexbox(control, errorp); }