private void OnMruFile(int number, String filename) { bool loadSuccessful = false; try { SpyWindowHelper.WantToSave(_rootNurseObject); loadSuccessful = ModelFileHandler.LoadRecentModelFile(filename, _presenterModel.GetTreeView()); } catch (Exception ex) { //"Invalid file format, please check log files for more details" MessageBox.Show(StringResources.LPSpy_SpyMainWindow_InvalidFileFormat); //TODO: log message MessageBox.Show(ex.ToString()); } if (loadSuccessful) { mruMenu.SetFirstFile(number); } else { //The file '{0}' cannot be opened and will be removed from the Recent list(s) string message = StringResources.LPSpy_SpyMainWindow_FileRemovedFromRecentList; MessageBox.Show(string.Format(message, filename) , "" , MessageBoxButtons.OK , MessageBoxIcon.Error); mruMenu.RemoveFile(number); } }
private void chineseMenuItem_Click(object sender, EventArgs e) { if (SpySettings.Language == AppLanguageEnum.English) { SpyWindowHelper.SwitchLanguage(AppLanguageEnum.Chinese, () => { SpyWindowHelper.WantToSave(_rootNurseObject); }); } }
private void SpyMainWindow_FormClosing(object sender, FormClosingEventArgs e) { //check whether need to save before exit SpyWindowHelper.WantToSave(_rootNurseObject); SpySettings.SaveUserSettings(); mruMenu.SaveToRegistry(); mruMenu.BuildJumpList(); }
//menu -> new private void newMenuItem_Click(object sender, EventArgs e) { SpyWindowHelper.WantToSave(_rootNurseObject); string filePath = null; if (ModelFileHandler.DlgNewModelFile(out filePath)) { _presenterModel.NewModel(filePath); } }
//menu -> open private void openMenuItem_Click(object sender, EventArgs e) { SpyWindowHelper.WantToSave(_rootNurseObject); try { if (_presenterModel.DlgOpenModelFile()) { mruMenu.AddFile(AppEnvironment.CurrentModelPath); } } catch (Newtonsoft.Json.JsonReaderException ex) { //Invalid file format, please check log files for more detail MessageBox.Show(StringResources.LPSpy_SpyMainWindow_InvalidFileFormat); _Logger.WriteWarning(ex.ToString()); } }