public FileSwitchDialogViewModel(LayoutElementViewModel layoutElement) { m_layoutElement = layoutElement; m_files = m_layoutElement.FileUseOrder; m_switchFileCommand = new GenericManualCommand<int>(SwitchFile, null, Converter); m_showCloseButton = false; }
public TabsContextMenuViewModel(MainViewModel mainViewModel, LayoutElementViewModel layoutElement) { m_mainViewModel = mainViewModel; m_layoutElement = layoutElement; m_menuItems.Add(new MenuItemViewModel("Close", mainViewModel.CloseFileCommand, layoutElement, "SelectedFile")); m_menuItems.Add(new MenuItemViewModel("Revert", new ManualCommand(() => layoutElement.SelectedFile.Reload()))); m_closeAllMenuItemViewModel = new MenuItemViewModel("Close all", new ManualCommand(() => mainViewModel.CloseAllFiles(false))); m_menuItems.Add(m_closeAllMenuItemViewModel); m_closeOthersMenuItemViewModel = new MenuItemViewModel("Close others", new ManualCommand(() => mainViewModel.CloseAllFiles(true))); m_menuItems.Add(m_closeOthersMenuItemViewModel); m_layoutElement.OpenFiles.PropertyChanged += OpenfilesOnPropertyChanged; m_menuItems.Add(new MenuItemViewModel("Show in project tree", new ManualCommand(ShowInTree))); m_menuItems.Add(new MenuItemViewModel("Open containing folder", new ManualCommand(OpenContainingFolder))); }
public void LoadSetup() { if (File.Exists(Properties.Settings.Default.SettingPath + "\\openFiles.json")) { StreamReader streamReader = File.OpenText(Properties.Settings.Default.SettingPath + "\\openFiles.json"); JsonNode jsonNode = (JsonNode)JsonHelperFunctions.Parse(streamReader.ReadToEnd()); streamReader.Close(); SelectedLayoutType = jsonNode.GetObjectOrDefault("layouttype", LayoutType.Single); JsonArray layouts = jsonNode.GetObjectOrDefault<JsonArray>("layouts", null); int index = 0; foreach (JsonNode layout in layouts) { LayoutElementViewModel layoutElement = m_layoutElements[index]; JsonArray openFiles = layout.GetObjectOrDefault<JsonArray>("openfiles", null); string selectedFilePath = layout.GetObjectOrDefault<string>("selectedFile", null); foreach (JsonValue jsonValue in openFiles) { IFileViewModel fileViewModel = m_mainViewModel.OpenFile((string)jsonValue.Value, layoutElement, (string)jsonValue.Value == selectedFilePath); if (!layoutElement.FileUseOrder.Contains(fileViewModel)) layoutElement.FileUseOrder.Add(fileViewModel); } if (layoutElement.SelectedFile == null && layoutElement.OpenFiles.Count > 0) layoutElement.SelectedFile = layoutElement.OpenFiles.First(); if (layout.GetObjectOrDefault("isactive", false)) m_activeLayoutElement = layoutElement; index++; } } else { SelectedLayoutType = LayoutType.Single; } }
private void CrateView() { switch (m_selectedLayoutType) { case LayoutType.Single: m_view = new SingleLayoutView {DataContext = this}; break; case LayoutType.TwoColumns: m_view = new TwoColumnsView {DataContext = this}; break; case LayoutType.ThreeColumns: m_view = new ThreeColumnsView { DataContext = this }; break; case LayoutType.TwoRows: m_view = new TwoRowsView { DataContext = this }; break; case LayoutType.ThreeRows: m_view = new ThreeRowsView { DataContext = this }; break; case LayoutType.Grid: m_view = new GridView { DataContext = this }; break; default: throw new ArgumentOutOfRangeException(); } while (m_layoutElements.Count > m_selectedLayoutType.ElementCount()) { foreach (IFileViewModel fileViewModel in m_layoutElements.Last().OpenFiles) { m_layoutElements[m_selectedLayoutType.ElementCount() - 1].OpenFiles.Add(fileViewModel); m_layoutElements[m_selectedLayoutType.ElementCount() - 1].FileUseOrder.Add(fileViewModel); } m_layoutElements.Remove(m_layoutElements.Last()); } int index = m_layoutElements.Count; while (m_layoutElements.Count < m_selectedLayoutType.ElementCount()) m_layoutElements.Add(new LayoutElementViewModel(m_mainViewModel, index++)); if (m_activeLayoutElement == null || !m_layoutElements.Contains(m_activeLayoutElement)) m_activeLayoutElement = m_layoutElements.FirstOrDefault(); OnPropertyChanged("View"); }
public IFileViewModel OpenFile(string path, LayoutElementViewModel layoutElement = null, bool select = true) { IFileViewModel fileViewModel = null; foreach (ITreeNode treeNode in m_treeNodes.Values) { if (treeNode == null) continue; fileViewModel = treeNode.GetFile(path); if (fileViewModel != null) break; } if (fileViewModel == null) { IEditor editor = m_editorManager.BaseEditors.FirstOrDefault(n => n.Settings != null && n.Settings.Path == path); if (editor != null) fileViewModel = editor.Settings; } if (fileViewModel == null) fileViewModel = new FileViewModel(path); OpenFile(fileViewModel, layoutElement, select); return fileViewModel; }
public void OpenFile(IFileViewModel file, LayoutElementViewModel layoutElement = null, bool select = true) { if (file == null) return; if (layoutElement == null) layoutElement = m_layoutManager.LayoutElements.FirstOrDefault(n => n.OpenFiles.Contains(file)) ?? LayoutManager.ActiveLayoutElement; if (file.Path == null || !layoutElement.OpenFiles.Any(n => n.Path == file.Path)) { file.FileChangedOnDisk += FileOnFileChangedOnDisk; layoutElement.OpenFiles.Add(file); } if (select) layoutElement.SelectedFile = file; }