internal EdiViewModel LoadOutputWindow(string fileName = "") { // Don't need to load output window when output.js is opening if (IsOutputFile(fileName)) { return(null); } var firstPanel = FindFirstLayoutDocumentPane(Win.dockManager.Layout.RootPanel); var paneGroup = firstPanel.Parent as LayoutDocumentPaneGroup; if (paneGroup == null) { return(null); } var vm = this.mFiles.FirstOrDefault(x => IsOutputFile(x.FileName)); if (vm == null) { string outFilePath = GetOutFilePath(); vm = EdiViewModel.LoadFile(outFilePath); this.mFiles.Add(vm); var outputContent = firstPanel.Children.Last(); var layOutPanel = paneGroup.Parent as LayoutPanel; if (layOutPanel != null) { var newPane = new LayoutDocumentPane(outputContent); paneGroup.InsertChildAt(1, newPane); } } return(vm); }
/// <summary> /// Open a file supplied in <paramref name="filePath"/> (without displaying a file open dialog). /// </summary> /// <param name="filePath">file to open</param> /// <param name="AddIntoMRU">indicate whether file is to be added into MRU or not</param> /// <returns></returns> public EdiViewModel Open(string filePath, bool AddIntoMRU = true) { // Verify whether file is already open in editor, and if so, show it var fileViewModel = mFiles.FirstOrDefault(fm => fm.FilePath == filePath); if (fileViewModel != null) { this.ActiveDocument = fileViewModel; // File is already open so shiw it return(fileViewModel); } // try to load the file from file system fileViewModel = EdiViewModel.LoadFile(filePath); if (fileViewModel == null) { if (this.Config.MruList.FindMRUEntry(filePath) != null) { if (Edi.Msg.Box.Show(string.Format(CultureInfo.CurrentCulture, "The file:\n\n'{0}'\n\ndoes not exist or cannot be loaded.\n\nDo you want to remove this file from the list of recent files?", filePath), "Error Loading file", MsgBoxButtons.YesNo) == MsgBoxResult.Yes) { this.Config.MruList.RemoveEntry(filePath); } } return(null); } mFiles.Add(fileViewModel); // reset viewmodel options in accordance to current program settings SetActiveDocumentOnNewFileOrOpenFile(ref fileViewModel); if (AddIntoMRU == true) { this.RecentFiles.AddNewEntryIntoMRU(filePath); } LoadOutputWindow(fileViewModel.FileName); return(fileViewModel); }