Пример #1
0
 // TODO: make a helper static method or something, dont pollute mainwindow!
 /// <summary>
 /// DFS through TreeView the TreeViewItem which has Tab target
 /// </summary>
 /// <param name="source">TreeView/TreeViewItem in which to search for Tab</param>
 /// <param name="target">Target Tab</param>
 /// <returns>TreeViewItem which contains Tab</returns>
 private TreeViewItem getTreeViewItem(dynamic source, Tab target)
 {
     for (int i = 0; i < source.Items.Count; ++i)
     {
         TreeViewItem child = source.ItemContainerGenerator.ContainerFromIndex(i) as TreeViewItem;
         if (child.HasItems)
         {
             TreeViewItem result = getTreeViewItem(child, target);
             if (result != null) return result;
         }
         else
             if (child.DataContext == target)
                 return child;
     }
     return null;
 }
Пример #2
0
        /// <summary>
        /// Create a new tab
        /// </summary>
        private void NewTabCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            // TODO: When watching this shouldn't work
            if (ClientStatus.IsBroadcasting)
            {
                Connection.AddTab (new Infrastructure.Tab ());
            }
            else
            {
                TabNext = new PrivateTab ();
                System.Windows.Threading.DispatcherOperation op = App.Current.Dispatcher.BeginInvoke
                    (
                    new Action<Tab> (tab => tabsPanel.PrivateSession.Add (tab)), TabNext
                    );

                op.Completed +=new EventHandler(op_Completed);
            }
        }
Пример #3
0
        /// <summary>
        /// Close current tab
        /// </summary>
        private void CloseTabCommand_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (ClientStatus.IsBroadcasting)
            {
                Tab target = tabsPanel.TabsTreeView.SelectedItem as Tab;
                if (target != null)
                    Connection.CloseTab(target.TabData);
            }
            else if (dockingManager.ActiveDocument != null)
            {
                int index = dockingManager.Documents.IndexOf(dockingManager.ActiveDocument as Tab);
                if (index == 0)
                    if (dockingManager.Documents.Count > 1)
                        TabNext = dockingManager.Documents[1] as Tab;
                    else
                        TabNext = null;
                else
                    TabNext = dockingManager.Documents[index - 1] as Tab;

                System.Windows.Threading.DispatcherOperation op = App.Current.Dispatcher.BeginInvoke
                (
                    new Action(() => dockingManager.ActiveDocument.Close())
                );

                op.Completed += new EventHandler(op_Completed);
            }
        }