public void CloseTab(LoggedInWindowTabItem tabitem) { if (SelectedTabItem == tabitem) { SelectedTabItem = TabItems[TabItems.IndexOf(tabitem) - 1]; } TabItems.Remove(tabitem); }
private void OnOpenWebLogs(object obj) { TabItem tab; if (!TabItems.Any(t => t.Header.Equals("Web Logs"))) { tab = new TabItem { Header = "Web Logs", Content = new WebLogView(), DataContext = new WebLogViewModel(this) }; TabItems.Add(tab); } else { tab = TabItems.FirstOrDefault(t => t.Header.Equals("Web Logs")); } SelectedTabIndex = TabItems.IndexOf(tab); }
private void OnAgentInteract(object obj) { TabItem tab; if (!TabItems.Any(t => t.Header.Equals(SelectedAgent.AgentId))) { tab = new TabItem { Header = SelectedAgent.AgentId, Content = new AgentInteractView(), DataContext = new AgentInteractViewModel(this, SelectedAgent.AgentId) }; TabItems.Add(tab); } else { tab = TabItems.FirstOrDefault(t => t.Header.Equals(SelectedAgent.AgentId)); } SelectedTabIndex = TabItems.IndexOf(tab); }
public void TabsSelectionChanged(object sender, SelectionChangedEventArgs e) { var tabControl = sender as TabControl; var indexBefore = TabItems.IndexOf(CurrentSelectedTab); var indexAfter = tabControl.SelectedIndex; Console.WriteLine("TabsSelectionChanged"); Console.WriteLine("indexBefore : " + indexBefore); Console.WriteLine("indexAfter : " + indexAfter); if (indexAfter == -1) { return; } if (indexBefore != -1) { TabItems[indexBefore].DisableClassChangedCommand(); Console.WriteLine("ClassChangedDisable, Index : " + indexBefore); } TabItems[indexAfter].EnableClassChangedCommand(); Console.WriteLine("ClassChangedEnable, Index : " + indexAfter); CurrentSelectedTab = TabItems[indexAfter]; Console.WriteLine(tabControl.SelectedIndex); }
public void SaveModifiedFiles(object sender) { List <string> delList = new List <string>(); bool noPrompt = false; try { foreach (IFile <T> item in new List <IFile <T> >(ViewManager.FileManager)) { // set tab index to current SelectedIndex = TabItems.IndexOf(TabItems.First(x => x.Tag == item.Tag)); if (!IsValidTabIndex()) { continue; } noPrompt = SaveModifiedFile(noPrompt, item); } } catch (Exception e) { SetStatus("SaveModifiedFiles: exception: " + e.ToString()); } }
private static int GetTabIndex(Actor actor) { var existsItem = TabItems.FirstOrDefault(x => x.Header.ToString() == actor.ShortName); return(TabItems.IndexOf(existsItem)); }
public void SaveModifiedFiles(object sender) { List <string> delList = new List <string>(); try { foreach (IFile <T> item in new List <IFile <T> >(ViewManager.FileManager.Where(x => x.Modified == true))) { // set tab index to current SelectedIndex = TabItems.IndexOf(TabItems.First(x => x.Tag == item.Tag)); if (!IsValidTabIndex()) { continue; } // prompt for saving if (!TextFilterSettings.Settings.AutoSave) { TimedSaveDialog dialog = new TimedSaveDialog(item.Tag); dialog.Enable(); switch (dialog.WaitForResult()) { case TimedSaveDialog.Results.Disable: TextFilterSettings.Settings.AutoSave = true; break; case TimedSaveDialog.Results.DontSave: item.Modified = false; break; case TimedSaveDialog.Results.Save: SaveFileExecuted(item); item.Modified = false; break; case TimedSaveDialog.Results.SaveAs: SaveFileAsExecuted(item); item.Modified = false; break; case TimedSaveDialog.Results.Unknown: // dont worry about errors since we are closing. break; } } else { SaveFileExecuted(item); item.Modified = false; } DeleteIfTempFile(item); } } catch (Exception e) { SetStatus("SaveModifiedFiles: exception: " + e.ToString()); } }