예제 #1
0
        private void UnpinnedToolPane_CloseRequest(object sender, EventArgs e)
        {
            System.Diagnostics.Trace.Assert(sender is UnpinnedToolPane);
            System.Diagnostics.Trace.Assert(sender == _activeUnpinnedToolPane);

            FrameworkElement userControl = _activeUnpinnedToolPane.ToolPane.IViewContainer.ExtractUserControl(0);
            IViewModel       iViewModel  = userControl.DataContext as IViewModel;

            System.Diagnostics.Trace.Assert(iViewModel != null);

            /*
             * Remove the tool list items from the side bar
             */

            _activeToolListBox.ItemsSource.Remove(_activeToolListBoxItem);
            if (_activeToolListBox.ItemsSource.Count == 0)
            {
                _dictUnpinnedToolData[_activeToolListBox.WindowLocation].Remove(_activeUnpinnedToolData);
            }
            _activeUnpinnedToolPane.Close();
            _activeUnpinnedToolPane = null;
            _activeToolListBoxItem  = null;
            _activeToolListBox      = null;
            _activeUnpinnedToolData = null;

            IUnpinnedToolHost.ViewModelRemoved(iViewModel);
        }
예제 #2
0
        private void UnpinnedToolPane_PinClick(object sender, EventArgs e)
        {
            System.Diagnostics.Trace.Assert(_activeUnpinnedToolPane == sender);
            System.Diagnostics.Trace.Assert(_activeUnpinnedToolData != null);

            /*
             * Put the view back into its ToolPane
             */

            FrameworkElement userControl = _activeUnpinnedToolPane.ToolPane.IViewContainer.ExtractUserControl(0);

            _activeToolListBoxItem.IViewContainer.InsertUserControl(_activeToolListBoxItem.Index, userControl);

            /*
             * Restore the pane in the view tree
             */

            IUnpinnedToolHost.PinToolPane(_activeUnpinnedToolData, _activeToolListBox.WindowLocation);

            /*
             * Remove the tool list items from the side bar
             */

            List <ToolListBoxItem> toolListBoxItems             = _activeUnpinnedToolData.Items;
            IEnumerable <Controls.IToolListBoxItem> iEnumerable = _activeToolListBox.ItemsSource.Except(toolListBoxItems);

            _activeToolListBox.ItemsSource = new System.Collections.ObjectModel.ObservableCollection <Controls.IToolListBoxItem>(iEnumerable);

            _dictUnpinnedToolData[_activeToolListBox.WindowLocation].Remove(_activeUnpinnedToolData);
            _activeUnpinnedToolPane.Close();
            _activeUnpinnedToolPane = null;
            _activeToolListBoxItem  = null;
            _activeToolListBox      = null;
            _activeUnpinnedToolData = null;
        }
예제 #3
0
        public void MakeUnpinnedToolPaneGroup(WindowLocation windowLocation, ToolPaneGroup toolPaneGroup, string siblingGuid, bool isHorizontal, bool isFirst)
        {
            Controls.IToolListBox iToolListBox = IUnpinnedToolHost.GetToolListBox(windowLocation);

            System.Diagnostics.Trace.Assert(iToolListBox != null);
            System.Diagnostics.Trace.Assert(toolPaneGroup != null);

            UnpinnedToolData unpinnedToolData = new UnpinnedToolData();

            unpinnedToolData.ToolPaneGroup = toolPaneGroup;
            unpinnedToolData.SiblingGuid   = new Guid(siblingGuid);
            unpinnedToolData.IsFirst       = isFirst;
            unpinnedToolData.IsHorizontal  = isHorizontal;

            AddUnpinnedToolData(unpinnedToolData, windowLocation, iToolListBox);
        }
예제 #4
0
        private void AddUnpinnedToolData(UnpinnedToolData unpinnedToolData, WindowLocation windowLocation, Controls.IToolListBox toolListBox)
        {
            _dictUnpinnedToolData[windowLocation].Add(unpinnedToolData);

            int count = unpinnedToolData.ToolPaneGroup.IViewContainer.GetUserControlCount();

            for (int i = 0; i < count; ++i)
            {
                ToolListBoxItem toolListBoxItem = new ToolListBoxItem()
                {
                    IViewContainer = unpinnedToolData.ToolPaneGroup.IViewContainer,
                    Index          = i,
                };
                (toolListBox.ItemsSource as System.Collections.ObjectModel.ObservableCollection <Controls.IToolListBoxItem>).Add(toolListBoxItem);
                unpinnedToolData.Items.Add(toolListBoxItem);
            }
        }
예제 #5
0
        public ToolPaneGroup ShowUnpinnedToolPane(ToolListBoxItem toolListBoxItem, Controls.IToolListBox iToolListBox)
        {
            System.Diagnostics.Trace.Assert(toolListBoxItem != null);
            System.Diagnostics.Trace.Assert(iToolListBox != null);

            ToolListBoxItem activeToolListBoxItem = _activeToolListBoxItem;

            CloseUnpinnedToolPane();

            if (activeToolListBoxItem == toolListBoxItem)
            {
                return(null);
            }

            _activeToolListBox      = iToolListBox;
            _activeToolListBoxItem  = toolListBoxItem;
            _activeUnpinnedToolData = _dictUnpinnedToolData[iToolListBox.WindowLocation].Where(n => n.Items.Contains(_activeToolListBoxItem)).First();
            _activeUnpinnedToolPane = CreateUnpinnedToolPane(toolListBoxItem, iToolListBox.WindowLocation);
            return(_activeUnpinnedToolPane.ToolPane);
        }
예제 #6
0
 void IUnpinnedToolHost.UnpinToolPane(ToolPaneGroup toolPaneGroup, out UnpinnedToolData unpinnedToolData, out WindowLocation toolListBoxLocation)
 {
     IDockPaneManager.UnpinToolPane(toolPaneGroup, out unpinnedToolData, out toolListBoxLocation);
 }
예제 #7
0
 void IUnpinnedToolHost.PinToolPane(UnpinnedToolData unpinnedToolData, WindowLocation defaultWindowLocation)
 {
     IDockPaneManager.PinToolPane(unpinnedToolData, defaultWindowLocation);
 }
예제 #8
0
        public void UnpinToolPane(ToolPaneGroup toolPaneGroup, out UnpinnedToolData unpinnedToolData, out WindowLocation toolListBoxLocation)
        {
            System.Diagnostics.Trace.Assert(toolPaneGroup != null);

            DocumentPanel documentPanel = FindElementOfType(typeof(DocumentPanel), IDockPaneHost.RootPane) as DocumentPanel;

            System.Diagnostics.Trace.Assert(documentPanel != null);

            List <Grid> documentPanelAncestors = new List <Grid>();
            Grid        grid = documentPanel;

            while (grid.Parent != IDockPaneHost)
            {
                grid = grid.Parent as SplitterPane;
                documentPanelAncestors.Add(grid);
            }

            /*
             * Find the first common ancestor for the document panel and the tool pane group
             */

            FrameworkElement frameworkElement = toolPaneGroup;

            while (true)
            {
                if (documentPanelAncestors.Contains(frameworkElement.Parent as Grid))
                {
                    break;
                }

                frameworkElement = frameworkElement.Parent as FrameworkElement;
            }

            toolListBoxLocation = WindowLocation.None;
            bool isFirst      = (Grid.GetRow(frameworkElement) == 0) && (Grid.GetColumn(frameworkElement) == 0);
            bool isHorizontal = (frameworkElement.Parent as SplitterPane).IsHorizontal;

            if (isHorizontal)
            {
                if (isFirst)
                {
                    toolListBoxLocation = WindowLocation.TopSide;
                }
                else
                {
                    toolListBoxLocation = WindowLocation.BottomSide;
                }
            }
            else
            {
                if (isFirst)
                {
                    toolListBoxLocation = WindowLocation.LeftSide;
                }
                else
                {
                    toolListBoxLocation = WindowLocation.RightSide;
                }
            }

            unpinnedToolData = new UnpinnedToolData();
            unpinnedToolData.ToolPaneGroup = toolPaneGroup;
            Grid parentGrid = toolPaneGroup.Parent as Grid;

            unpinnedToolData.IsFirst      = (Grid.GetRow(toolPaneGroup) == 0) && (Grid.GetColumn(toolPaneGroup) == 0);
            unpinnedToolData.IsHorizontal = (parentGrid as SplitterPane).IsHorizontal;

            ExtractDockPane(toolPaneGroup, out frameworkElement);
            System.Diagnostics.Trace.Assert(frameworkElement != null);

            unpinnedToolData.SiblingGuid = (Guid)((frameworkElement as Grid).Tag);
        }
예제 #9
0
        public void PinToolPane(UnpinnedToolData unpinnedToolData, WindowLocation defaultWindowLocation)
        {
            Grid sibling = null;

            if (unpinnedToolData.SiblingGuid == (Guid)IDockPaneHost.RootGrid.Tag)
            {
                sibling = IDockPaneHost.RootGrid;
            }
            else
            {
                sibling = FindElement(unpinnedToolData.SiblingGuid, IDockPaneHost.RootGrid);
            }

            // This can happen when loading a layout
            bool isHorizontal = unpinnedToolData.IsHorizontal;
            bool isFirst      = unpinnedToolData.IsFirst;

            if (sibling == null)
            {
                sibling      = IDockPaneHost as Grid;
                isHorizontal = (defaultWindowLocation == WindowLocation.TopSide) || (defaultWindowLocation == WindowLocation.BottomSide);
                isFirst      = (defaultWindowLocation == WindowLocation.TopSide) || (defaultWindowLocation == WindowLocation.LeftSide);
            }

            SplitterPane newSplitterPane = ILayoutFactory.MakeSplitterPane(isHorizontal);

            if (sibling == IDockPaneHost)
            {
                IEnumerable <SplitterPane> enumerableSplitterPanes = IDockPaneHost.Children.OfType <SplitterPane>();
                if (enumerableSplitterPanes.Count() == 1)
                {
                    SplitterPane splitterPane = enumerableSplitterPanes.First();

                    IDockPaneHost.RootPane = newSplitterPane;
                    newSplitterPane.AddChild(splitterPane, !isFirst);
                    newSplitterPane.AddChild(unpinnedToolData.ToolPaneGroup, isFirst);
                }
                else
                {
                    IEnumerable <DocumentPanel> enumerableDocumentPanels = IDockPaneHost.Children.OfType <DocumentPanel>();
                    System.Diagnostics.Trace.Assert(enumerableDocumentPanels.Count() == 1);

                    DocumentPanel documentPanel = enumerableDocumentPanels.First();

                    IDockPaneHost.RootPane = newSplitterPane;
                    newSplitterPane.AddChild(documentPanel, !isFirst);
                    newSplitterPane.AddChild(unpinnedToolData.ToolPaneGroup, isFirst);
                }
            }
            else if (sibling.Parent == IDockPaneHost)
            {
                IDockPaneHost.RootPane = newSplitterPane;
                newSplitterPane.AddChild(sibling, !isFirst);
                newSplitterPane.AddChild(unpinnedToolData.ToolPaneGroup, isFirst);
            }
            else
            {
                SplitterPane parentSplitterPane = sibling.Parent as SplitterPane;
                int          row    = Grid.GetRow(sibling);
                int          column = Grid.GetColumn(sibling);
                isFirst = (parentSplitterPane.IsHorizontal && (row == 0)) || (!parentSplitterPane.IsHorizontal && (column == 0));
                parentSplitterPane.Children.Remove(sibling);

                parentSplitterPane.AddChild(newSplitterPane, isFirst);

                newSplitterPane.AddChild(sibling, !unpinnedToolData.IsFirst);
                newSplitterPane.AddChild(unpinnedToolData.ToolPaneGroup, unpinnedToolData.IsFirst);
            }
        }