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; }
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); }
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); } } } } }
private void ToolListBox_ItemClick(object sender, Events.ItemClickEventArgs e) { ToolListBoxItem toolListBoxItem = (sender as ToolListBoxItem); System.Diagnostics.Trace.Assert(toolListBoxItem != null); System.Diagnostics.Trace.Assert((e != null) && (e.ToolListBox != null)); IUnpinnedToolManager.ShowUnpinnedToolPane(toolListBoxItem, e.ToolListBox); }
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); }
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); } }
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); }