private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { //here's your view model: var viewModel = args.DragablzItem.DataContext as HeaderedItemViewModel; Debug.Assert(viewModel != null); }
private void CloseFloatingItemExecuted(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) { if (!(executedRoutedEventArgs.Parameter is DragablzItem dragablzItem)) { throw new ApplicationException("Parameter must be a DragablzItem"); } var cancel = false; if (ClosingFloatingItemCallback != null) { var callbackArgs = new ItemActionCallbackArgs <Layout>(Window.GetWindow(this), this, dragablzItem); ClosingFloatingItemCallback(callbackArgs); cancel = callbackArgs.IsCancelled; } if (cancel) { return; } //TODO ...need a similar tp manual inter tab controlller here for the extra hook var item = _floatingItems.ItemContainerGenerator.ItemFromContainer(dragablzItem); if (CollectionTeaser.TryCreate(_floatingItems.ItemsSource, out CollectionTeaser? collectionTeaser)) { collectionTeaser.Remove(item); } else { _floatingItems.Items.Remove(item); } }
private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { if (args.DragablzItem.DataContext is TabVm tab) { tab.Close(); } }
private static void CloseTab(ItemActionCallbackArgs <TabablzControl> args) { if (!((TabBase)args.DragablzItem.Content).Cancel()) { args.Cancel(); } }
private void CloseFloatingItemExecuted(object _) { var dockItem = _ as DockItem; if (dockItem == null) { return; } var cancel = false; if (ClosingFloatingItemCallback != null) { var window = this.GetVisualAncestors().OfType <Window>().FirstOrDefault(); if (window == null) { throw new ApplicationException("Unable to ascertain window."); } var callbackArgs = new ItemActionCallbackArgs <Layout>(window, this, dockItem); ClosingFloatingItemCallback(callbackArgs); cancel = callbackArgs.IsCancelled; } if (cancel) { return; } var index = _floatingItems.ItemContainerGenerator.IndexFromContainer(dockItem); ((IList)_floatingItems.Items).RemoveAt(index); }
/// <summary> /// Callback to handle tab closing. /// </summary> private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { //in here you can dispose stuff or cancel the close //here's your view model: var view = args.DragablzItem.DataContext as UserControl; if (view != null) { var viewModel = view.DataContext; Type viewModelType = viewModel.GetType(); MethodInfo methodInfo = viewModelType.GetMethod("DisposeEvents"); if (methodInfo != null) { methodInfo.Invoke(viewModel, null); } } var tabItem = args.DragablzItem; var tabControl = FindParent <TabControl>(tabItem); if (tabControl == null) { return; } IRegion region = RegionManager.GetObservableRegion(tabControl).Value; if (region == null) { return; } IViewsCollection collection = region.ActiveViews; object currentView = null; foreach (var v in collection) { currentView = v; } if (currentView != null) { PropertyInfo parameterInfo = currentView.GetType().GetProperty("Header"); if (parameterInfo != null) { string headerName = parameterInfo.GetValue(currentView, null) as string; string name = args.DragablzItem.Content as string; if (name != null) { if (headerName == args.DragablzItem.Content.ToString()) { RemoveItemFromRegion(currentView, region); } } } } //here's how you can cancel stuff: //args.Cancel(); }
private void MainTabControl_ClosingItem(ItemActionCallbackArgs <TabablzControl> args) { RemoteTabItem tabItem = args.DragablzItem.Content as RemoteTabItem; if (tabItem != null) { tabItem.Closed?.Invoke(tabItem); } }
private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs<TabablzControl> args) { var container = (ViewContainer)args.DragablzItem.DataContext;//.DataContext; if (container.Equals(Selected)) { Selected = _data.FirstOrDefault(vc => vc != container); } var disposable = container.Content as IDisposable; if (disposable != null) disposable.Dispose(); }
private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { //in here you can dispose stuff or cancel the close //here's your view model: var viewModel = args.DragablzItem.DataContext as DirectoryTabItemViewModel; //here's how you can cancel stuff: //args.Cancel(); }
/// <summary> /// Callback to handle floating toolbar/MDI window closing. /// </summary> private static void ClosingFloatingItemHandlerImpl(ItemActionCallbackArgs <Layout> args) { //here's your view model: var disposable = args.DragablzItem.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } }
private void OnTabClosing(ItemActionCallbackArgs <TabablzControl> args) { DragablzItem item = args.DragablzItem; if (item.Content is FrameworkElement v) { Actor actor = v.DataContext as Actor; actor.Dispose(); } }
// パブリックメソッド /// <summary> /// クリックでタブを閉じるときに呼ばれるメソッド /// </summary> public void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> itemActionCallbackArgs) { var tabData = (TabData)itemActionCallbackArgs.DragablzItem.DataContext; var tabRemovedEventArgs = new TabRemovedEventArgs { TabId = tabData.TabId }; _eventAggregator.GetEvent <TabRemovedEvent>().Publish(tabRemovedEventArgs); }
/// <summary> /// Callback to handle tab closing. /// </summary> private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs<TabablzControl> args) { //in here you can dispose stuff or cancel the close //here's your view model: var viewModel = args.DragablzItem.DataContext as HeaderedItemViewModel; Debug.Assert(viewModel != null); //here's how you can cancel stuff: //args.Cancel(); }
private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { var container = (ViewContainer)args.DragablzItem.DataContext;//.DataContext; if (container.Equals(Selected)) { Selected = Views.FirstOrDefault(vc => vc != container); } var disposable = container.Content as IDisposable; disposable?.Dispose(); }
/// <summary> /// Callback to handle floating toolbar/MDI window closing. /// </summary> private static void ClosingFloatingItemHandlerImpl(ItemActionCallbackArgs<Layout> args) { //in here you can dispose stuff or cancel the close //here's your view model: var disposable = args.DragablzItem.DataContext as IDisposable; if (disposable != null) disposable.Dispose(); //here's how you can cancel stuff: //args.Cancel(); }
private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { _logger.Info("Tab is closing. {0} view to close", Views.Count); var container = (ViewContainer)args.DragablzItem.DataContext; _windowsController.Remove(container); if (container.Equals(Selected)) { Selected = Views.FirstOrDefault(vc => vc != container); } var disposable = container.Content as IDisposable; disposable?.Dispose(); }
//[Obsolete("This is old the code from the MetroTabControl")] //private void TabControl_TabItemClosing(object sender, BaseMetroTabControl.TabItemClosingEventArgs e) //{ // var tab = e.ClosingTabItem as TabItem; // if (tab == null) // return; // e.Cancel = !CloseTab(tab); //} private void TabControlDragablz_TabItemClosing(ItemActionCallbackArgs <TabablzControl> e) { var tab = e.DragablzItem.DataContext as TabItem; if (tab == null) { return; } if (!CloseTab(tab)) { e.Cancel(); } }
/// <summary> /// Callback to handle floating toolbar/MDI window closing. /// </summary> private static void ClosingFloatingItemHandlerImpl(ItemActionCallbackArgs <Layout> args) { //in here you can dispose stuff or cancel the close //here's your view model: var disposable = args.DragablzItem.DataContext as IDisposable; if (disposable != null) { disposable.Dispose(); } //here's how you can cancel stuff: //args.Cancel(); }
private async void TabClosing(ItemActionCallbackArgs <TabablzControl> args) { var headerModel = args.DragablzItem?.DataContext as HeaderedItemViewModel; _app.Log.Info($"Closing Tab: {headerModel.Header.ToString()}"); var viewInTab = headerModel.Content as UserControl; Guid moduleId = Guid.Empty; if (viewInTab.Tag != null) { moduleId = Guid.Parse(viewInTab?.Tag.ToString()); } if (viewInTab.DataContext is IDisposable viewModel) { _app.Log.Info($"Dispose called for: {viewInTab.DataContext.GetType().FullName}"); viewModel.Dispose(); } viewInTab.DataContext = null; if (viewInTab is IHaveCloseTask taskView) { if (taskView.CanExecuteAsync) { await Task.Run(taskView.ClosingTask); } else { taskView.ClosingTask.Invoke(); } } if (viewInTab is IDisposable view) { _app.Log.Info($"Dispose called for: {viewInTab.GetType().FullName}"); view.Dispose(); } viewInTab = null; if (moduleId != Guid.Empty) { _app.TabManager.ModuleClosed(moduleId); } GC.WaitForPendingFinalizers(); GC.Collect(); }
private void CloseItemAction(ItemActionCallbackArgs <TabablzControl> args) { // Switch between application identifiert... switch (_applicationName) { case ApplicationViewManager.Name.IPScanner: ((args.DragablzItem.Content as DragablzTabItem).View as IPScannerView).CloseTab(); break; case ApplicationViewManager.Name.PortScanner: ((args.DragablzItem.Content as DragablzTabItem).View as PortScannerView).CloseTab(); break; case ApplicationViewManager.Name.Ping: ((args.DragablzItem.Content as DragablzTabItem).View as PingView).CloseTab(); break; case ApplicationViewManager.Name.Traceroute: ((args.DragablzItem.Content as DragablzTabItem).View as TracerouteView).CloseTab(); break; case ApplicationViewManager.Name.DNSLookup: ((args.DragablzItem.Content as DragablzTabItem).View as DNSLookupView).CloseTab(); break; case ApplicationViewManager.Name.RemoteDesktop: ((args.DragablzItem.Content as DragablzTabItem).View as RemoteDesktopControl).CloseTab(); break; case ApplicationViewManager.Name.PuTTY: ((args.DragablzItem.Content as DragablzTabItem).View as PuTTYControl).CloseTab(); break; case ApplicationViewManager.Name.SNMP: ((args.DragablzItem.Content as DragablzTabItem).View as TracerouteView).CloseTab(); break; case ApplicationViewManager.Name.HTTPHeaders: ((args.DragablzItem.Content as DragablzTabItem).View as HTTPHeadersView).CloseTab(); break; } }
/// <summary> /// Callback to handle tab closing. /// </summary> private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { //in here you can dispose stuff or cancel the close //here's your view model: var viewModel = args.DragablzItem.DataContext as TabContent; if (viewModel != null) { string title = Container?.Resolve <ILocalizerService>(ServiceNames.LocalizerService)?.GetLocalizedString("OverviewPageTitle"); if (viewModel.Header.Equals(title)) { args.Cancel(); } } //Debug.Assert(viewModel != null); //here's how you can cancel stuff: //args.Cancel(); }
private void CloseFloatingItemExecuted(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) { var dragablzItem = executedRoutedEventArgs.Parameter as DragablzItem; if (dragablzItem == null) throw new ApplicationException("Parameter must be a DragablzItem"); var cancel = false; if (ClosingFloatingItemCallback != null) { var callbackArgs = new ItemActionCallbackArgs<Layout>(Window.GetWindow(this), this, dragablzItem); ClosingFloatingItemCallback(callbackArgs); cancel = callbackArgs.IsCancelled; } if (cancel) return; //TODO ...need a similar tp manual inter tab controlller here for the extra hook var item = _floatingItems.ItemContainerGenerator.ItemFromContainer(dragablzItem); CollectionTeaser collectionTeaser; if (CollectionTeaser.TryCreate(_floatingItems.ItemsSource, out collectionTeaser)) collectionTeaser.Remove(item); else _floatingItems.Items.Remove(item); }
private void CloseItemHandler(object sender, ExecutedRoutedEventArgs executedRoutedEventArgs) { var dragablzItem = executedRoutedEventArgs.Parameter as DragablzItem; if (dragablzItem == null) { var dependencyObject = executedRoutedEventArgs.OriginalSource as DependencyObject; dragablzItem = dependencyObject.VisualTreeAncestory().OfType<DragablzItem>().FirstOrDefault(); } if (dragablzItem == null) throw new ApplicationException("Unable to ascertain DragablzItem to close."); var cancel = false; if (ClosingItemCallback != null) { var callbackArgs = new ItemActionCallbackArgs<TabablzControl>(Window.GetWindow(this), this, dragablzItem); ClosingItemCallback(callbackArgs); cancel = callbackArgs.IsCancelled; } if (!cancel) RemoveItem(dragablzItem); }
private void WindowOnClosing(object sender, CancelEventArgs cancelEventArgs) { _windowSubscription.Disposable = Disposable.Empty; if (!ConsolidateOrphanedItems || InterTabController == null) return; var window = (Window)sender; var orphanedItems = _dragablzItemsControl.DragablzItems(); if (ConsolidatingOrphanedItemCallback != null) { orphanedItems = orphanedItems.Where( di => { var args = new ItemActionCallbackArgs<TabablzControl>(window, this, di); ConsolidatingOrphanedItemCallback(args); return !args.IsCancelled; }).ToList(); } var target = LoadedInstances.Except(this) .FirstOrDefault( other => other.InterTabController != null && other.InterTabController.Partition == InterTabController.Partition); if (target == null) return; foreach (var item in orphanedItems.Select(orphanedItem => _dragablzItemsControl.ItemContainerGenerator.ItemFromContainer(orphanedItem))) { RemoveFromSource(item); target.AddToSource(item); } }
private void CloseItemAction(ItemActionCallbackArgs <TabablzControl> args) { ((args.DragablzItem.Content as DragablzTabItem).View as PuTTYControl).OnClose(); }
private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { }
public void OnTabClosing(ItemActionCallbackArgs <TabablzControl> args) { (args.DragablzItem.DataContext as TabViewModelBase)?.Dispose(); }
private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs<TabablzControl> args) { _logger.Info("Tab is closing. {0} view to close", Views.Count); var container = (HeaderedView)args.DragablzItem.DataContext; _windowsController.Remove(container); if (container.Equals(Selected)) { Selected = Views.FirstOrDefault(vc => vc != container); } var disposable = container.Content as IDisposable; disposable?.Dispose(); }
private static void CloseItemClassHandler(object sender, ExecutedRoutedEventArgs e) { var owner = FindOwner(e.Parameter, e.OriginalSource); if (owner == null) throw new ApplicationException("Unable to ascertain DragablzItem to close."); var cancel = false; if (owner.Item2.ClosingItemCallback != null) { var callbackArgs = new ItemActionCallbackArgs<TabablzControl>(Window.GetWindow(owner.Item2), owner.Item2, owner.Item1); owner.Item2.ClosingItemCallback(callbackArgs); cancel = callbackArgs.IsCancelled; } if (!cancel) owner.Item2.RemoveItem(owner.Item1); }
private static void OnItemClosingHandler(ItemActionCallbackArgs <TabablzControl> args) { (args.DragablzItem.DataContext as TabItemContainer)?.TabContentLifetimeHost.Cleanup(TabCloseReason.TabClosed); }
private void tables_ClosingItemCallback(ItemActionCallbackArgs <TabablzControl> args) { var tab = args.DragablzItem.Content as TableView; Controller.CloseCommand.Execute(tab?.Controller); }
/// <summary> /// Callback to handle tab closing. /// </summary> private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args) { var viewModel = args.DragablzItem.DataContext as HeaderedItemViewModel; Debug.Log(viewModel); }
private void ClosingItemCallback(ItemActionCallbackArgs<TabablzControl> args) { // remove from region this.Region.Remove(((TabClientProxy)args.DragablzItem.DataContext).Content); }
private static void ClosingFloatingItemHandlerImpl(ItemActionCallbackArgs <Layout> args) { var disposable = args.DragablzItem.DataContext as IDisposable; disposable?.Dispose(); }
private void OnTabClosing(ItemActionCallbackArgs <TabablzControl> args) { }
private void OnItemClosed(ItemActionCallbackArgs <TabablzControl> args) { var closeable = args.DragablzItem.Content as ICloseable; closeable?.Close(); }
private void CloseItemAction(ItemActionCallbackArgs <TabablzControl> args) { ((args.DragablzItem.Content as DragablzRemoteDesktopTabItem).View as RemoteDesktopControl).CloseTab(); }
private void CloseItemAction(ItemActionCallbackArgs <TabablzControl> args) { ((args.DragablzItem.Content as DragablzTabItem).View as HTTPHeadersView).CloseTab(); }
private void ClosingItemCallback(ItemActionCallbackArgs <TabablzControl> args) { // remove from region this.Region.Remove(((TabClientProxy)args.DragablzItem.DataContext).Content); }