private void syntaxValidator_DoWork(object sender, DoWorkEventArgs e) { string source = e.Argument as string; string error = ""; bool valid = true; CharPosition position = new CharPosition(-1, -1, -1); try { KmlDocument kdoc = new KmlDocument(); kdoc.LoadFromString(source); } catch (Exception ex) { error = ex.InnerException.Message; position = ex.InnerException.Data["Position"] as CharPosition; valid = false; } e.Result = new SyntaxValidationResult(valid,error,position); }
private void FormatSyntax() { KmlDocument kdoc = new KmlDocument(); ValidateSyntax(); try { kdoc.LoadFromString(syntaxEdit.Text); this.syntaxEdit.Text = kdoc.ToString(); } catch (Exception) { MessageBox.Show("Syntax must be valid before formatting."); } }