Esempio 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;
        }
Esempio n. 2
0
        public void Validate(Dictionary <IViewModel, List <string> > viewModelUrlDictionary)
        {
            CloseUnpinnedToolPane();

            foreach (KeyValuePair <WindowLocation, List <UnpinnedToolData> > keyValuePair in _dictUnpinnedToolData)
            {
                Controls.IToolListBox toolListBox = IUnpinnedToolHost.GetToolListBox(keyValuePair.Key);

                foreach (UnpinnedToolData unpinnedToolData in keyValuePair.Value)
                {
                    for (int index = unpinnedToolData.Items.Count - 1; index > -1; --index)
                    {
                        IViewModel iViewModel = unpinnedToolData.Items[index].IViewModel;
                        if (viewModelUrlDictionary.ContainsKey(iViewModel))
                        {
                            viewModelUrlDictionary.Remove(iViewModel);
                        }
                        else
                        {
                            ToolListBoxItem toolListBoxItem = unpinnedToolData.Items[index];
                            toolListBox.ItemsSource.Remove(toolListBoxItem);
                            unpinnedToolData.Items.RemoveAt(index);
                        }
                    }
                }
            }
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio 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);
        }
Esempio n. 6
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);
            }
        }