Exemplo n.º 1
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;
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
 public void CloseUnpinnedToolPane()
 {
     if (_activeUnpinnedToolPane != null)
     {
         FrameworkElement userControl = _activeUnpinnedToolPane.ToolPane.IViewContainer.ExtractUserControl(0);
         _activeToolListBoxItem.IViewContainer.InsertUserControl(_activeToolListBoxItem.Index, userControl);
         _activeUnpinnedToolPane.Close();
         _activeUnpinnedToolPane = null;
         _activeToolListBoxItem  = null;
     }
 }
        private UnpinnedToolPane CreateUnpinnedToolPane(ToolListBoxItem toolListBoxItem, WindowLocation windowLocation)
        {
            UnpinnedToolPane unpinnedToolPane = new UnpinnedToolPane();

            UserControl userControl = toolListBoxItem.IViewContainer.ExtractUserControl(toolListBoxItem.Index);

            unpinnedToolPane.ToolPane.IViewContainer.AddUserControl(userControl);
            unpinnedToolPane.ToolPane.HideCommandsButton();
            Point topLeftPoint = IUnpinnedToolHost.RootPane.PointToScreen(new Point(0, 0));

            unpinnedToolPane.Left = topLeftPoint.X;
            unpinnedToolPane.Top  = topLeftPoint.Y;
            if ((windowLocation == WindowLocation.TopSide) || (windowLocation == WindowLocation.BottomSide))
            {
                unpinnedToolPane.Width = IUnpinnedToolHost.RootPane.ActualWidth;
                double height = toolListBoxItem.Height;
                if (height == 0.0)
                {
                    height = IUnpinnedToolHost.RootPane.ActualHeight / 3;
                }
                unpinnedToolPane.Height = height;
                if (windowLocation == WindowLocation.BottomSide)
                {
                    unpinnedToolPane.Top += IUnpinnedToolHost.RootPane.ActualHeight - height;
                }
            }
            else
            {
                unpinnedToolPane.Height = IUnpinnedToolHost.RootPane.ActualHeight;
                double width = toolListBoxItem.Width;
                if (width == 0.0)
                {
                    width = IUnpinnedToolHost.RootPane.ActualWidth / 3;
                }
                unpinnedToolPane.Width = width;
                if (windowLocation == WindowLocation.RightSide)
                {
                    unpinnedToolPane.Left += IUnpinnedToolHost.RootPane.ActualWidth - width;
                }
            }
            unpinnedToolPane.CloseRequest  += UnpinnedToolPane_CloseRequest;
            unpinnedToolPane.Closed        += UnpinnedToolPane_Closed;
            unpinnedToolPane.PinClick      += UnpinnedToolPane_PinClick;
            unpinnedToolPane.WindowLocation = windowLocation;
            unpinnedToolPane.Owner          = Application.Current.MainWindow;

            unpinnedToolPane.Show();

            return(unpinnedToolPane);
        }
Exemplo n.º 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);
        }