protected override void OnActivated(EventArgs e) { if (Manager != null) { lastActiveContent = Manager.ActiveContent; Manager.ActiveContent = HostedPane.SelectedItem as ManagedContent; } base.OnActivated(e); }
protected override void OnSelectionChanged(SelectionChangedEventArgs e) { ManagedContent selectedContent = this.SelectedItem as ManagedContent; if (selectedContent != null && GetManager() != null) { GetManager().ActiveDocument = selectedContent; } base.OnSelectionChanged(e); }
protected override void OnSelectionChanged(SelectionChangedEventArgs e) { if (e.RemovedItems != null && e.RemovedItems.Count > 0 && e.AddedItems != null && e.AddedItems.Count > 0) { _lastSelectedContent = e.RemovedItems[0] as ManagedContent; } base.OnSelectionChanged(e); }
/// <summary> /// Move focus to pane content and activate it /// </summary> protected void FocusContent() { ManagedContent selectedContent = SelectedItem as ManagedContent; if (selectedContent != null)// && selectedContent.Content is UIElement) { //UIElement internalContent = selectedContent.Content as UIElement; //bool res = Focus(); //Keyboard.Focus(internalContent); selectedContent.Activate(); } }
protected override void OnVisualChildrenChanged(DependencyObject visualAdded, DependencyObject visualRemoved) { base.OnVisualChildrenChanged(visualAdded, visualRemoved); ManagedContent mc = visualAdded as ManagedContent; if (mc != null) { mc.Style = TabItemStyle; mc.ApplyTemplate(); } }
protected void OnLoaded(object sender, EventArgs e) { WindowInteropWrapper wih = new WindowInteropWrapper(this); //wih.WindowActivating += (s, ce) => ce.Cancel = true;//prevent window activating wih.FilterMessage += new EventHandler <FilterMessageEventArgs>(FilterMessage); if (HostedPane.Items.Count > 0) { ManagedContent cntHosted = HostedPane.Items[0] as ManagedContent; if (!cntHosted.IsCloseable) { DisableXButton(); } } }
internal override ManagedContent RemoveContent(int index) { ManagedContent content = base.RemoveContent(index); DockableContent dockableContent = content as DockableContent; if (((dockableContent == null) || (dockableContent != null && dockableContent.SavedStateAndPosition == null) || (dockableContent != null && dockableContent.SavedStateAndPosition.ContainerPane != this)) && Items.Count == 0) { ResizingPanel containerPanel = Parent as ResizingPanel; if (containerPanel != null) { containerPanel.RemoveChild(this); } } return(content); }
void CloseThis(ManagedContent contentToClose) { if (GetManager() == null) { return; } if (contentToClose == null) { contentToClose = SelectedItem as ManagedContent; } DockableContent dockableContent = contentToClose as DockableContent; if (dockableContent != null) { dockableContent.Close(); } else { DocumentContent documentContent = contentToClose as DocumentContent; documentContent.Close(); } }
protected override void OnItemsChanged(System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { DockingManager dockManager = GetManager(); if (dockManager != null) { dockManager.RefreshContents(); } if (e.NewItems != null) { CheckItems(e.NewItems); } HasSingleItem = (Items.Count == 1); if (_lastSelectedContent != null && !Items.Contains(_lastSelectedContent)) { _lastSelectedContent = null; } if ((e.NewItems == null || e.NewItems.Count == 0) && (e.OldItems != null && e.OldItems.Count > 0)) { if (_lastSelectedContent != null && Items.Contains(_lastSelectedContent)) { SelectedItem = _lastSelectedContent; } } //let base class handle SelectedIndex/Item value base.OnItemsChanged(e); if (Items.Count > 0) { int currentIndex = SelectedIndex; if (currentIndex < 0 || currentIndex >= Items.Count) { currentIndex = Items.Count - 1; } SelectedItem = Items.GetItemAt(currentIndex); } RefreshContainsActiveContentProperty(); if (Items.Count > 0) { var parentPanel = Parent as ResizingPanel; while (parentPanel != null && parentPanel.IsLoaded) { parentPanel.UpdateLayout(); parentPanel.InvalidateMeasure(); parentPanel = parentPanel.Parent as ResizingPanel; } } }
internal virtual ManagedContent RemoveContent(int index) { ManagedContent contentToRemove = Items[index] as ManagedContent; return(RemoveContent(contentToRemove)); }
internal virtual ManagedContent RemoveContent(ManagedContent contentToRemove) { Items.Remove(contentToRemove); return(contentToRemove); }
internal NavigatorWindowItem(ManagedContent content) { _title = content.Title; _icon = content.Icon; _content = content; }
protected virtual void OnDragMouseLeave(object sender, MouseEventArgs e) { if (!e.Handled && isMouseDown && e.LeftButton == MouseButtonState.Pressed && Manager != null) { if (!IsMouseCaptured) { Point ptMouseMove = e.GetPosition((IInputElement)System.Windows.Media.VisualTreeHelper.GetParent(this)); ManagedContent contentToSwap = null; if (ContainerPane != null) { foreach (ManagedContent content in ContainerPane.Items) { if (content == this) { continue; } HitTestResult res = VisualTreeHelper.HitTest(content, e.GetPosition(content)); if (res != null) { contentToSwap = content; break; } } } if (contentToSwap != null && contentToSwap != this) { Pane containerPane = ContainerPane; int myIndex = containerPane.Items.IndexOf(this); ContainerPane.Items.RemoveAt(myIndex); int otherIndex = containerPane.Items.IndexOf(contentToSwap); containerPane.Items.RemoveAt(otherIndex); containerPane.Items.Insert(otherIndex, this); containerPane.Items.Insert(myIndex, contentToSwap); containerPane.SelectedItem = this; e.Handled = false; //avoid ismouseDown = false call return; } else if (Math.Abs(ptMouseMove.X - StartDragPoint.X) > SystemParameters.MinimumHorizontalDragDistance || Math.Abs(ptMouseMove.Y - StartDragPoint.Y) > SystemParameters.MinimumVerticalDragDistance) { ptRelativePosition = e.GetPosition(DragEnabledArea); ResetIsMouseDownFlag(); OnDragStart(StartDragPoint, ptRelativePosition); e.Handled = true; } } } ResetIsMouseDownFlag(); }
protected override void OnInitialized(EventArgs e) { if (_paneToTransfer != null) { //setup window size ManagedContent selectedContent = _paneToTransfer.SelectedItem as ManagedContent; if (selectedContent is DockableContent) { _floatingWindow.SizeToContent = (selectedContent as DockableContent).FloatingWindowSizeToContent; } if (selectedContent != null && selectedContent.FloatingWindowSize.IsEmpty) { selectedContent.FloatingWindowSize = new Size(_paneToTransfer.ActualWidth, _paneToTransfer.ActualHeight); } if (selectedContent != null) { _floatingWindow.Width = selectedContent.FloatingWindowSize.Width; _floatingWindow.Height = selectedContent.FloatingWindowSize.Height; } else { _floatingWindow.Width = _paneToTransfer.ActualWidth; _floatingWindow.Height = _paneToTransfer.ActualHeight; } int selectedIndex = _paneToTransfer.SelectedIndex; //remove contents from container pane and insert in hosted pane while (_paneToTransfer.Items.Count > 0) { DockableContent contentToTranser = _paneToTransfer.Items[0] as DockableContent; contentToTranser.SaveCurrentStateAndPosition(); _paneToTransfer.RemoveContent(0); //add content to my temporary pane Items.Add(contentToTranser); contentToTranser.SetStateToDockableWindow(); } SelectedIndex = selectedIndex; //transfer the style from the original dockablepane //Style = _paneToTransfer.Style; AttachStyleFromPane(_paneToTransfer); ApplyTemplate(); LayoutTransform = (MatrixTransform)_paneToTransfer.TansformToAncestor(); } else if (_contentToTransfer != null) { //setup window size if (_contentToTransfer.FloatingWindowSize.IsEmpty) { _contentToTransfer.FloatingWindowSize = new Size(_contentToTransfer.ContainerPane.ActualWidth, _contentToTransfer.ContainerPane.ActualHeight); } _floatingWindow.Width = _contentToTransfer.FloatingWindowSize.Width; _floatingWindow.Height = _contentToTransfer.FloatingWindowSize.Height; //save current content position in container pane _previousPane = _contentToTransfer.ContainerPane; _arrayIndexPreviousPane = _previousPane.Items.IndexOf(_contentToTransfer); _contentToTransfer.SaveCurrentStateAndPosition(); //remove content from container pane _contentToTransfer.ContainerPane.RemoveContent(_arrayIndexPreviousPane); //add content to this pane Items.Add(_contentToTransfer); SelectedIndex = 0; AttachStyleFromPane(_previousPane as DockablePane); DocumentPane originalDocumentPane = _previousPane as DocumentPane; if (originalDocumentPane != null) { originalDocumentPane.CheckContentsEmpty(); } _contentToTransfer.SetStateToDockableWindow(); LayoutTransform = (MatrixTransform)_contentToTransfer.TansformToAncestor(); } base.OnInitialized(e); }