/// <summary> /// Validate the model before the file is saved. /// </summary> protected override bool CanSave(bool allowUserInterface) { // If a silent check then use a temporary ValidationController that is not connected to the error list to avoid any unwanted UI updates DslShell::VsValidationController vc = allowUserInterface ? this.ValidationController : this.CreateValidationController(); if (vc == null) { return(true); } // We check Load category first, because any violation in this category will cause the saved file to be unloadable justifying a special // error message. If the Load category passes, we then check the normal Save category, and give the normal warning message if necessary. bool unloadableError = !vc.Validate(this.GetAllElementsForValidation(), DslValidation::ValidationCategories.Load) && vc.ErrorMessages.Count != 0; // Prompt user for confirmation if there are validation errors and this is not a silent save if (allowUserInterface) { vc.Validate(this.GetAllElementsForValidation(), DslValidation::ValidationCategories.Save); if (vc.ErrorMessages.Count != 0) { string errorMsg = (unloadableError ? "UnloadableSaveValidationFailed" : "SaveValidationFailed"); global::System.Windows.Forms.DialogResult result = DslShell::PackageUtility.ShowMessageBox(this.ServiceProvider, global::TXSoftware.DataObjectsNetEntityModel.Dsl.DONetEntityModelDesignerDomainModel.SingletonResourceManager.GetString(errorMsg), VSShellInterop::OLEMSGBUTTON.OLEMSGBUTTON_YESNO, VSShellInterop::OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, VSShellInterop::OLEMSGICON.OLEMSGICON_WARNING); return(result == global::System.Windows.Forms.DialogResult.Yes); } } return(!unloadableError); }
internal static string smethod_3(string string_0, string string_1, string string_2, string string_3 = "") { global::System.Windows.Forms.SaveFileDialog saveFileDialog = new global::System.Windows.Forms.SaveFileDialog(); string result = null; saveFileDialog.DefaultExt = string_0; saveFileDialog.Filter = string_1; saveFileDialog.InitialDirectory = string_2; saveFileDialog.FileName = string_3; global::System.Windows.Forms.DialogResult dialogResult = saveFileDialog.ShowDialog(); if (dialogResult == global::System.Windows.Forms.DialogResult.OK) { result = saveFileDialog.FileName; } return(result); }
internal static string smethod_1(string string_0, string string_1, string string_2, string string_3 = "") { global::System.Windows.Forms.OpenFileDialog openFileDialog = new global::System.Windows.Forms.OpenFileDialog(); string result = null; string_2 = global::ARC_Studio.Workers.ARC.FileUtils.smethod_2(string_2); openFileDialog.DefaultExt = string_0; openFileDialog.Filter = string_1; openFileDialog.InitialDirectory = string_2; openFileDialog.FileName = string_3; global::System.Windows.Forms.DialogResult dialogResult = openFileDialog.ShowDialog(); if (dialogResult == global::System.Windows.Forms.DialogResult.OK) { result = openFileDialog.FileName; } return(result); }
/// <summary> /// Validate the model before the file is saved. /// </summary> protected override bool CanSave(bool allowUserInterface) { global::System.Windows.Forms.DialogResult result = global::System.Windows.Forms.DialogResult.Yes; // Do not call validation in the case of a silent save, because the user cannot be prompted. if (allowUserInterface) { // We check Load category first, because any violation in this category will cause the saved file to be unloadable, so we want to a special // error message for that. If the Load category passes, we then check the normal Save category, and give the normal warning message if // necessary. bool unloadableError = false; if (!this.ValidationController.Validate(this.Store, DslValidation::ValidationCategories.Load) && this.ValidationController.ErrorMessages.Count != 0) { // Check Load category unloadableError = true; } if ((!this.ValidationController.Validate(this.Store, DslValidation::ValidationCategories.Save) && this.ValidationController.ErrorMessages.Count != 0) || unloadableError) { // Check Save category string errorMsg = (unloadableError ? "UnloadableSaveValidationFailed" : "SaveValidationFailed"); result = DslShell::PackageUtility.ShowMessageBox(this.ServiceProvider, global::DSLFactory.Candle.SystemModel.CandleDomainModel.SingletonResourceManager.GetString(errorMsg), VSShellInterop::OLEMSGBUTTON.OLEMSGBUTTON_YESNO, VSShellInterop::OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_SECOND, VSShellInterop::OLEMSGICON.OLEMSGICON_WARNING); } } return(result == global::System.Windows.Forms.DialogResult.Yes); }