private void tsmiDeleteCurrentModel_Click(object sender, EventArgs e) { if (CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("DeleteModel"), CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo) == CustomMessageBoxReturnValue.Ok) { if (ERMTSession.Instance.CurrentModel != null) { ModelHelper.Delete(ERMTSession.Instance.CurrentModel); ERMTSession.Instance.CurrentModel = null; ViewManager.LoadModelsMenu(); EventManager.RaiseModelChanged(this); if (File.Exists(DirectoryAndFileHelper.ModelViewConfigurationFile + "\\Last.ini")) { File.Delete(DirectoryAndFileHelper.ModelViewConfigurationFile + "\\Last.ini"); } } } }
private void tsmiImportModel_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); if (openFileDialog.ShowDialog() == DialogResult.OK) { StreamReader sr = File.OpenText(openFileDialog.FileName); Document doc = new Document { Content = sr.ReadToEnd() }; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(doc.Content); int importVersion = 0; XmlNode versionNode = xmlDoc.SelectSingleNode("data/Version"); if (versionNode != null) { importVersion = int.Parse(versionNode.Attributes["Number"].Value.Substring(0, 1)); } if (importVersion == 0 || importVersion < 7) { CustomMessageBoxReturnValue customMessageBoxReturnValue = CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("RegionsMustBeLoadedBeforeImport"), CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo); if (customMessageBoxReturnValue == CustomMessageBoxReturnValue.Cancel) { return; } } List <string> message = DocumentHelper.Import(doc); if (message[0] == "true") { //import successfull. if (message.Count > 2) { if (message[1] == "SomeRegionsWereNotImported") { CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportOk") + " " + ResourceHelper.GetResourceText("SomeRegionsWereNotImported") + ": " + message[2]); } } else { CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportOk")); } ViewManager.ShowStart(); ViewManager.LoadModelsMenu(); } else { //import failed. if (message.Count == 1) { //it was an exception CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportNotOk")); return; } if (message[1] == "ModelImportNoExistsRegionsInLocalDB") { CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportNoExistsRegionsInLocalDB") + " " + ResourceHelper.GetResourceText("ModelImportNotOk")); } else if (message[1] == "ModelImportNoExistsParentRegionInLocalDB") { CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportNoExistsParentRegionInLocalDB") + " " + ResourceHelper.GetResourceText("ModelImportNotOk")); } else if (message[1] == "ModelImportMainRegionDoesNotExits") { CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportMainRegionDoesNotExits") + " " + ResourceHelper.GetResourceText("ModelImportNotOk")); } else if (message[1] == "ModelImportErrorVersionUsesDundasAndWrongParent") { CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportErrorVersionUsesDundasAndWrongParent") + " " + ResourceHelper.GetResourceText("ModelImportNotOk")); } else { CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelImportNotOk")); } } } }