public void CloseItem(ITabItem item) { if (_lDocDict.ContainsKey(item)) { item.FloatClosed -= OnTabFloatClosed; LayoutDocument ldoc = _lDocDict[item]; _lDocDict.Remove(item); TabItemCollection.Remove(item); if (item.IsFloat) { LayoutFloatingWindowControl fwctrl = item.FloatControl; fwctrl.Close(); item.IsFloat = false; } else { Children.Remove(ldoc); } if (item is LadderDiagramViewModel) { IEnumerable <MainTabDiagramItem> fit = DiagramCollection.Where( (MainTabDiagramItem _mtditem) => { return(_mtditem.LDVM_ladder == item); }); MainTabDiagramItem mtditem = null; if (fit.Count() > 0) { mtditem = fit.First(); DiagramCollection.Remove(mtditem); } } CloseTabItem(this, new RoutedEventArgs()); } }
public void RemoveSelectedTabClick(object obj) { // Debugger.Launch(); // WebBrowser.Navigate("about:blank"); if (WebBrowser != null) { WebBrowser.Dispose(); } GC.Collect(); TabItemCollection.Remove(this); if (TabItemCollection.Where(x => x.CloseButtonVisibility == Visibility.Visible).Count() == 0) { AddNewTabClick(this); Model.SelectedIndex = 0; ShowAddNewTabIfNeeded(); } else { Model.SelectedIndex = Model.TabItemCollection.Count - 2; } ShowAddNewTabIfNeeded(); }
/// <summary> /// 关闭选项卡 /// </summary> /// <param name="header"></param> private void CloseTab(string header) { var tabItem = tabItems.FirstOrDefault(a => a.Header.Equals(header)); if (tabItem == null) { return; } tabItems.Remove(tabItem); }
public void ShowAddNewTabIfNeeded() { int count = TabItemCollection.Where(x => x.NewTabButtonVisibility == true).Count(); if (count == 0) { if (TabItemCollection.Count < MAX_TAB_COUNT) { TabItem item = new TabItem(Model, resolver); TabItemCollection.Add(item); } } if (TabItemCollection.Count > MAX_TAB_COUNT) { var tab = TabItemCollection.FirstOrDefault(x => x.NewTabButtonVisibility); TabItemCollection.Remove(tab); } }
private void OnTabFloatClosed(object sender, RoutedEventArgs e) { if (sender is MainTabDiagramItem) { MainTabDiagramItem mtditem = (MainTabDiagramItem)sender; mtditem.IsFloat = false; //mtditem.FloatClosed -= OnTabFloatClosed; DiagramCollection.Remove(mtditem); TabItemCollection.Remove(mtditem.LDVM_ladder); _lDocDict.Remove(mtditem.LDVM_ladder); } else { ITabItem titem = (ITabItem)sender; titem.IsFloat = false; //titem.FloatClosed -= OnTabFloatClosed; TabItemCollection.Remove(titem); _lDocDict.Remove(titem); } FloatingWinClosed(this, null); }