void ITabTearOffHandler.HandleTargetedDrop(object item, TabControl sourceTabControl, int sourceIndex, TabControl targetTabControl, int insertionIndex) { ShellView sourceWindow = Window.GetWindow(sourceTabControl) as ShellView; if (sourceWindow == null) { return; } using (sourceWindow.CreateIgnoreSelectionChangedScope()) { sourceTabControl.Items.RemoveAt(sourceIndex); } targetTabControl.Items.Insert(insertionIndex, item); targetTabControl.SelectedIndex = insertionIndex; if (sourceTabControl.Items.Count != 0) { return; } sourceWindow.Close(); this._shellViewFactory.Release(sourceWindow); }
void ITabTearOffHandler.HandleReorder(object item, TabControl tabControl, int sourceIndex, int insertionIndex) { int tabIndex = insertionIndex - (insertionIndex > sourceIndex ? 1 : 0); if (tabIndex == sourceIndex) { return; } ShellView window = Window.GetWindow(tabControl) as ShellView; if (window == null) { return; } using (window.CreateIgnoreSelectionChangedScope()) { tabControl.Items.RemoveAt(sourceIndex); tabControl.Items.Insert(tabIndex, item); tabControl.SelectedIndex = tabIndex; } }
private static void CreateFirmSummaryViewCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = !ShellView.IsFirmSummaryTabOpen(); }
public IgnoreSelectionChangedScope(ShellView shellView) { this._shellView = shellView; Interlocked.Increment(ref this._shellView._ignoreSelectionChangedCounter); }
private static bool IsTabOpen(PortfolioModel portfolio) { return(ShellView.GetOpenTabs <PositionsViewModel>().Any(viewModel => viewModel.Portfolio.Id == portfolio.Id)); }
private static bool IsFirmSummaryTabOpen() { return(ShellView.GetOpenTabs <FirmSummaryViewModel>().Any()); }
private static void CreateViewCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e) { e.CanExecute = !ShellView.IsTabOpen((PortfolioModel)e.Parameter); }