コード例 #1
0
        private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args)
        {
            //here's your view model:
            var viewModel = args.DragablzItem.DataContext as HeaderedItemViewModel;

            Debug.Assert(viewModel != null);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
 private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args)
 {
     if (args.DragablzItem.DataContext is TabVm tab)
     {
         tab.Close();
     }
 }
コード例 #4
0
 private static void CloseTab(ItemActionCallbackArgs <TabablzControl> args)
 {
     if (!((TabBase)args.DragablzItem.Content).Cancel())
     {
         args.Cancel();
     }
 }
コード例 #5
0
        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);
        }
コード例 #6
0
        /// <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();
        }
コード例 #7
0
ファイル: MainWindow.xaml.cs プロジェクト: zjamt/SimpleRemote
        private void MainTabControl_ClosingItem(ItemActionCallbackArgs <TabablzControl> args)
        {
            RemoteTabItem tabItem = args.DragablzItem.Content as RemoteTabItem;

            if (tabItem != null)
            {
                tabItem.Closed?.Invoke(tabItem);
            }
        }
コード例 #8
0
 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();
 }
コード例 #9
0
        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();
        }
コード例 #10
0
        /// <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();
            }
        }
コード例 #11
0
        private void OnTabClosing(ItemActionCallbackArgs <TabablzControl> args)
        {
            DragablzItem item = args.DragablzItem;

            if (item.Content is FrameworkElement v)
            {
                Actor actor = v.DataContext as Actor;
                actor.Dispose();
            }
        }
コード例 #12
0
        // パブリックメソッド

        /// <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);
        }
コード例 #13
0
        /// <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(); 
        }
コード例 #14
0
        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();
        }
コード例 #15
0
        /// <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(); 
        }
コード例 #16
0
        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();
        }
コード例 #17
0
        //[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();
            }
        }
コード例 #18
0
ファイル: BoundExampleModel.cs プロジェクト: th851dan/Savablz
        /// <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();
        }
コード例 #19
0
        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();
        }
コード例 #20
0
        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;
            }
        }
コード例 #21
0
        /// <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();
        }
コード例 #22
0
ファイル: Layout.cs プロジェクト: CensoredHF/Snappie
        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);
        }
コード例 #23
0
ファイル: TabablzControl.cs プロジェクト: tleviathan/Dragablz
        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);
        }
コード例 #24
0
ファイル: TabablzControl.cs プロジェクト: tleviathan/Dragablz
        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);
            }
        }
コード例 #25
0
 private void CloseItemAction(ItemActionCallbackArgs <TabablzControl> args)
 {
     ((args.DragablzItem.Content as DragablzTabItem).View as PuTTYControl).OnClose();
 }
コード例 #26
0
ファイル: WindowViewModel.cs プロジェクト: forki/Labs
 private void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args)
 {
 }
コード例 #27
0
 public void OnTabClosing(ItemActionCallbackArgs <TabablzControl> args)
 {
     (args.DragablzItem.DataContext as TabViewModelBase)?.Dispose();
 }
コード例 #28
0
 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();
 }
コード例 #29
0
        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);
        }
コード例 #30
0
 private static void OnItemClosingHandler(ItemActionCallbackArgs <TabablzControl> args)
 {
     (args.DragablzItem.DataContext as TabItemContainer)?.TabContentLifetimeHost.Cleanup(TabCloseReason.TabClosed);
 }
コード例 #31
0
        private void tables_ClosingItemCallback(ItemActionCallbackArgs <TabablzControl> args)
        {
            var tab = args.DragablzItem.Content as TableView;

            Controller.CloseCommand.Execute(tab?.Controller);
        }
コード例 #32
0
        /// <summary>
        /// Callback to handle tab closing.
        /// </summary>
        private static void ClosingTabItemHandlerImpl(ItemActionCallbackArgs <TabablzControl> args)
        {
            var viewModel = args.DragablzItem.DataContext as HeaderedItemViewModel;

            Debug.Log(viewModel);
        }
コード例 #33
0
 private void ClosingItemCallback(ItemActionCallbackArgs<TabablzControl> args)
 {
     // remove from region
     this.Region.Remove(((TabClientProxy)args.DragablzItem.DataContext).Content);
 }
コード例 #34
0
        private static void ClosingFloatingItemHandlerImpl(ItemActionCallbackArgs <Layout> args)
        {
            var disposable = args.DragablzItem.DataContext as IDisposable;

            disposable?.Dispose();
        }
コード例 #35
0
 private void OnTabClosing(ItemActionCallbackArgs <TabablzControl> args)
 {
 }
コード例 #36
0
ファイル: MainWindowVm.cs プロジェクト: jyardin/LogDigger
        private void OnItemClosed(ItemActionCallbackArgs <TabablzControl> args)
        {
            var closeable = args.DragablzItem.Content as ICloseable;

            closeable?.Close();
        }
コード例 #37
0
 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();
 }
コード例 #39
0
 private void ClosingItemCallback(ItemActionCallbackArgs <TabablzControl> args)
 {
     // remove from region
     this.Region.Remove(((TabClientProxy)args.DragablzItem.DataContext).Content);
 }