protected override void OnValidating(CancelEventArgs e) { base.OnValidating(e); if (!String.IsNullOrEmpty(Text)) { // check if text is a valid Maidenhead Locator if (MaidenheadLocator.Check(Text)) { ForeColor = OriginalForeColor; BackColor = OriginalBackColor; } else { base.ForeColor = ErrorForeColor; base.BackColor = ErrorBackColor; e.Cancel = true; } } }
protected override void OnTextUpdate(EventArgs e) { base.OnTextUpdate(e); // set the location value if (MaidenheadLocator.Check(this.Text)) { if (this.Text.Length >= 6) { GeoLocation = MaidenheadLocator.GPointFromLoc(this.Text); } else { geolocation = MaidenheadLocator.GPointFromLoc(this.Text); } } else { GeoLocation = null; } itemchanged = false; locationchanged = false; }