/// <summary> /// Fecha o separador de Chat. /// <para>Não deixa fechar o separador do "Lobby".</para> /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void CloseTabButton_OnClick(object sender, RoutedEventArgs e) { string tabName = ((Button)sender).CommandParameter.ToString(); if (tabName == "id0") { return; // Se for o Lobby } TabItem tab = ChatTabControl.Items.Cast <TabItem>().SingleOrDefault(i => i.Name.Equals(tabName)); if (tab == null) { return; } if (TabItems.Count <= 1) { return; } TabItem selectedTabItem = (TabItem)ChatTabControl.SelectedItem; ChatTabControl.DataContext = null; TabItems.Remove(tab); ChatTabControl.DataContext = TabItems; if (selectedTabItem == null || selectedTabItem.Equals(tab)) { selectedTabItem = TabItems[0]; } ChatTabControl.SelectedItem = selectedTabItem; }
public void RemoveTab(TabItemViewModel vm) { if (vm is VideoViewModel) { VideoTabs.Remove(vm); } else if (vm is UserViewModel) { UserTabs.Remove(vm); } else if (vm is PublicMylistViewModel) { MylistTabs.Remove(vm); } else if (vm is CommunityViewModel) { CommunityTabs.Remove(vm); } else if (vm is LiveViewModel) { LiveTabs.Remove(vm); } else if (vm is PlayListViewModel) { PlayListTabs.Remove(vm); } else { TabItems.Remove(vm); } }
public void CloseTab(LoggedInWindowTabItem tabitem) { if (SelectedTabItem == tabitem) { SelectedTabItem = TabItems[TabItems.IndexOf(tabitem) - 1]; } TabItems.Remove(tabitem); }
private void ViewContent_CloseByEvent(object sender, EventArgs e) { if (sender is UserControlViewObject content && TabItems.FirstOrDefault(x => x.Content == content) is LoggedInWindowTabItem tabItem) { content.RemoveByEvent -= ViewContent_CloseByEvent; TabItems.Remove(tabItem); } }
private void OnCloseTab(object param) { string layerName = param.ToString(); TabItems.Remove(TabItems.First(n => n.TableName == layerName)); TabControlSelectedIndex = 0; SetTabControlVisibility(); }
public void RemoveItem(MyTabItem tabItem) { var selector = TabItems.FirstOrDefault(t => t.Id == tabItem.Id); if (selector == null) { return; } TabItems.Remove(selector); }
private void OnOpenTabItemInNewWindow(object?obj) { if (obj is not DirectoryTabItemViewModel directoryTabItem) { return; } TabItems.Remove(directoryTabItem); ChromEr.Instance.OpenTabInNewWindow(directoryTabItem); }
protected override void OnControlRemoved(ControlEventArgs e) { TabItems.CollectionChanged -= TabItems_CollectionChanged; try { base.OnControlRemoved(e); TabItems.Remove((Button)e.Control); } catch (Exception) { } finally { TabItems.CollectionChanged += TabItems_CollectionChanged; } }
private void Delete_Tab(object sender, GeneratorTabItemDeletedEventArgs e) { for (int i = TabItems.Count - 1; i > -1; i--) { var tab = TabItems[i]; if (tab.ID == e.ID) { TabItems.Remove(tab); } } }
private void OnCloseOtherTab() { List <TabItemModel> deleteItems = TabItems.Where( item => item.ItemNamespace != SelectedModel.ItemNamespace || item.DataNum != SelectedModel.DataNum) .ToList(); foreach (var item in deleteItems) { TabItems.Remove(item); } }
private void OnCloseAllTabs(object?obj) { if (obj is not DirectoryTabItemViewModel directoryTabItem) { return; } var removedItems = TabItems.Where(i => i != directoryTabItem).ToList(); foreach (var item in removedItems) { TabItems.Remove(item); } }
private async void OnTabDroppedOutside(TabView sender, TabViewTabDroppedOutsideEventArgs e) { isCreatingNewAppWindow = true; TabItems.Remove(e.Tab); double scaling = XamlRoot.RasterizationScale; await TryCreateNewAppWindowAsync(e.Tab, new Size(ActualWidth *scaling, ActualHeight *scaling)); if (TabItems.Count == 0) { await TryCloseAsync(); } isCreatingNewAppWindow = false; }
private void TabItemCancelHandler(object sender, EventArgs e) { var cntrl = sender as TabItem; if (cntrl == null) { return; } var vm = cntrl.DataContext as CarDetailViewModel; if (vm != null) { vm.CancelHandler -= TabItemCancelHandler; vm.AddWorkHandler -= AddWorkHandler; vm.ShowHistoryHandler -= ShowHistoryHandler; } TabItems.Remove(cntrl); }
private void OnTabItemClose(TabItemModel model) { if (model == null) { return; } if (string.IsNullOrWhiteSpace(model.ItemNamespace)) { return; } var hasItem = HasItemByNamespace(model.ItemNamespace); if (hasItem == null) { return; } if (TabItems.Contains(hasItem)) { TabItems.Remove(hasItem); } }
private void DeleteTabItem() { for (int i = 0; i < TabItems.Count; i++) { if (SelectedItem == null) { break; } if (TabItems.ElementAt(i).Title == SelectedItem.Title) { if (!IsSessionLoaded) //for database { db.tabItems.Remove(TabItems.ElementAt(i)); db.SaveChanges(); LoadDbModels(); } else //for xml file { TabItems.Remove(TabItems.ElementAt(i)); } } } }
/// <summary> /// Closes tab. /// </summary> /// <param name="obj">Tab to close.</param> private void CloseTab(object obj) { var tabItem = obj as TabItem; SelectedTabItem = tabItem; //show user what he is about to close if (tabItem != null && (tabItem.Program != null && tabItem.UnsavedChanged || tabItem.Program == null && tabItem.ProgramEditor.Text != string.Empty)) { var dialog = MessageBox.Show($"Save file {tabItem.Header.Replace("*", string.Empty)}?", "Unsaved data", MessageBoxButton.YesNoCancel, MessageBoxImage.Warning); //if tab contains unsaved changes show dialog to determine wheter user wants to save it or not. User chooses: // *cancel - do nothing // *yes - show saveAs dialog, if he fails to save: do nothing, if he saves sucessfully: close tab // *no - close it without saving, if (dialog == MessageBoxResult.Cancel || (dialog == MessageBoxResult.Yes && SaveTab(tabItem) == false)) { return; } } TabItems.Remove(tabItem); Session.Instance.SavePrograms(TabItems); }
private void CloseClientCommandMethod(object o) { TabItems.Remove(SelectedItem); GC.Collect(); GC.WaitForFullGCComplete(); }
public void RemoveContentItem(TabItem item) { TabItems.Remove(item); }
public override void SaveFileAsExecuted(object sender) { bool exportConfg = false; ITabViewModel <LogFileItem> tabItem; LogFile logFile = new LogFile(); if (sender is LogFile) { // export configuration uses this exportConfg = true; logFile = sender as LogFile; } if (sender is TabItem) { tabItem = (ITabViewModel <LogFileItem>)(sender as TabItem); } else { if (IsValidTabIndex()) { tabItem = (ITabViewModel <LogFileItem>)TabItems[SelectedIndex]; } else { return; } } if (string.IsNullOrEmpty(tabItem.Tag)) { TabItems.Remove(tabItem); } else { bool silent = (sender is string && !String.IsNullOrEmpty(sender as string)) ? true : false; string logName = string.Empty; Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog(); dlg.Filter = "All Files (*.*)|*.*|Csv Files (*.csv)|*.csv"; dlg.InitialDirectory = Path.GetDirectoryName(tabItem.Tag) ?? ""; string extension = string.IsNullOrEmpty(Path.GetExtension(tabItem.Tag)) ? ".csv" : Path.GetExtension(tabItem.Tag); string fileName = Path.GetFileNameWithoutExtension(tabItem.Tag) + extension; if (!fileName.ToLower().Contains(".filtered")) { fileName = string.Format("{0}.filtered{1}", Path.GetFileNameWithoutExtension(tabItem.Tag), extension); } dlg.FileName = fileName; Nullable <bool> result = false; // Show save file dialog box if (silent) { result = true; logName = (sender as string); } else { result = dlg.ShowDialog(); logName = dlg.FileName; if (string.IsNullOrEmpty(logName)) { return; } } // Process save file dialog box results if (result == true) { // Save document if (exportConfg) { // export configuration uses this logFile = sender as LogFile; } else { logFile.ContentItems = tabItem.ContentList; } tabItem.IsNew = false; ViewManager.SaveFile(logName, logFile); // open filtered view into new tab if not a '-new ##-' tab if (string.Compare(tabItem.Tag, logName, true) != 0 && !Regex.IsMatch(tabItem.Tag, _tempTabNameFormatPattern, RegexOptions.IgnoreCase)) { if (!exportConfg) { AddTabItem(_logFileManager.NewFile(logName, tabItem.ContentList)); } } else { RenameTabItem(logName); } } } }
public void RemoveTabAndLastSet(TabItemViewModel vm) { TabItems.Remove(vm); SelectedTab = App.ViewModelRoot.TabItems.Last(); }
public void RemoveTab(TabItemViewModel vm) { TabItems.Remove(vm); }
private void OnCloseTabCommandExecute() { TabItems.Remove(SelectedTabItem); }
private void OnCloseTab() { TabItems.Remove(SelectedModel); }