public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if (!(value is OpenStreetMapProviderBase)) { if (!UserAcceptedLicenseOnce) { if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "License.txt")) { string ctn = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "License.txt"); int li = ctn.IndexOf("License"); string txt = ctn.Substring(li); var d = new Demo.WindowsPresentation.Windows.Message(); d.richTextBox1.Text = txt; if (true == d.ShowDialog()) { UserAcceptedLicenseOnce = true; if (Window != null) { Window.Title += " - license accepted by " + Environment.UserName + " at " + DateTime.Now; } } } else { // user deleted License.txt ;} UserAcceptedLicenseOnce = true; } } if (!UserAcceptedLicenseOnce) { return(new ValidationResult(false, "user do not accepted license ;/")); } } return(new ValidationResult(true, null)); }
public override ValidationResult Validate(object value, CultureInfo cultureInfo) { if(!(value is OpenStreetMapProviderBase)) { if(!UserAcceptedLicenseOnce) { if(File.Exists(AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "License.txt")) { string ctn = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "License.txt"); int li = ctn.IndexOf("License"); string txt = ctn.Substring(li); var d = new Demo.WindowsPresentation.Windows.Message(); d.richTextBox1.Text = txt; if(true == d.ShowDialog()) { UserAcceptedLicenseOnce = true; if(Window != null) { Window.Title += " - license accepted by " + Environment.UserName + " at " + DateTime.Now; } } } else { // user deleted License.txt ;} UserAcceptedLicenseOnce = true; } } if(!UserAcceptedLicenseOnce) { return new ValidationResult(false, "user do not accepted license ;/"); } } return new ValidationResult(true, null); }