private void OnViewHeaderDragStarted(object sender, DragAbsoluteEventArgs args) { DragUndockHeader dragUndockHeader = (DragUndockHeader)args.OriginalSource; if (dragUndockHeader.ViewElement != null && DockManager.Instance.DraggedViewElements.Count == 0) { DockManager.Instance.SetDraggedViewElements(dragUndockHeader.ViewElement); } if (!dragUndockHeader.IsWindowTitleBar && dragUndockHeader.ViewElement != null) { dragUndockHeader.CancelDrag(); if (DockManager.Instance.DraggedTabInfo != null && this.IsAutoDockAllowed(DockManager.Instance.DraggedTabInfo.TabStrip)) { if (-1 != DockManager.Instance.DraggedTabInfo.DraggedTabPosition) { DockManager.Instance.DraggedTabInfo.RemoveTabRect(DockManager.Instance.DraggedTabInfo.DraggedTabPosition); } DockManager.Instance.DraggedTabInfo.Initialize(dragUndockHeader.ViewElement); DockManager.Instance.DraggedTabInfo.DraggedTabPosition = -1; } else { DockManager.Instance.DraggedTabInfo = (DraggedTabInfo)null; } Rect currentUndockingRect = Rect.Empty; if (dragUndockHeader.ViewFrameworkElement != null && ExtensionMethods.IsConnectedToPresentationSource((DependencyObject)dragUndockHeader.ViewFrameworkElement)) { currentUndockingRect = new Rect(dragUndockHeader.ViewFrameworkElement.PointToScreen(new Point(0.0, 0.0)), DpiHelper.LogicalToDeviceUnits(dragUndockHeader.ViewFrameworkElement.RenderSize)); } DockOperations.Undock(dragUndockHeader.ViewElement, dragUndockHeader.ViewElement.WindowProfile, args.ScreenPoint, currentUndockingRect); } DockManager.Instance.IsDragging = true; }
private void HidePalettes() { List <ViewElement> list = Enumerable.ToList <ViewElement>(this.HideableViews); if (!Enumerable.Any <ViewElement>((IEnumerable <ViewElement>)list)) { return; } PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.TogglePalettes); Microsoft.VisualStudio.PlatformUI.Shell.View activeView = ViewManager.Instance.ActiveView; if (list.Contains((ViewElement)activeView)) { this.SavedActiveView = activeView; } foreach (ViewElement viewElement in list) { ExpressionView expressionView = viewElement as ExpressionView; if (expressionView != null) { expressionView.WasSelectedBeforeAutoHide = expressionView.IsSelected; } } foreach (ViewElement viewElement in list) { DockOperations.AutoHide(viewElement); } }
private void MoveToTabGroup(ViewElement view, int tabGroupOffset) { DocumentGroup documentGroup1 = view.Parent as DocumentGroup; if (documentGroup1 == null) { throw new InvalidOperationException("View that is being moved must be child of a DocumentGroup."); } DocumentGroupContainer documentGroupContainer = documentGroup1.Parent as DocumentGroupContainer; if (documentGroupContainer == null) { throw new InvalidOperationException("DocumentGroup must be child of a DocumentGroupContainer"); } List <ViewElement> list = new List <ViewElement>(documentGroupContainer.FindAll((Predicate <ViewElement>)(v => v is DocumentGroup))); int num = list.IndexOf((ViewElement)documentGroup1); if (num + tabGroupOffset < 0 || num + tabGroupOffset >= list.Count) { return; } DocumentGroup documentGroup2 = list[num + tabGroupOffset] as DocumentGroup; view.Detach(); DockOperations.Dock((ViewElement)documentGroup2, view, DockDirection.Fill); documentGroup2.SelectedElement = view; }
private bool ValidateGroup(ViewGroup group) { bool flag = false; DockOperations.TryCollapse((ViewElement)group); if (group.Parent != null || group is ViewSite) { flag = this.ValidateElement((ViewElement)group); if (flag) { for (int index = 0; index < group.Children.Count; ++index) { ViewElement element = group.Children[index]; if (element is AutoHideGroup) { ((ViewGroup)element).SelectedElement = (ViewElement)null; } if (!(!(element is ViewGroup) ? this.ValidateElement(element) : this.ValidateGroup(element as ViewGroup))) { group.Children.Remove(element); --index; } } } } return(flag); }
private void HandleDragAbsoluteMoveTabInPlace(DragUndockHeader header, DragAbsoluteEventArgs args) { DraggedTabInfo draggedTabInfo = DockManager.Instance.DraggedTabInfo; bool flag = draggedTabInfo.GetTabIndexAt(args.ScreenPoint) == draggedTabInfo.DraggedTabPosition; if (flag) { draggedTabInfo.ClearVirtualTabRect(); } if (header.ViewElement == null && draggedTabInfo.DraggedViewElement == null) { return; } ViewElement tab = header.ViewElement ?? draggedTabInfo.DraggedViewElement; if (!draggedTabInfo.TabStripRect.Contains(args.ScreenPoint) || flag || draggedTabInfo.VirtualTabRect.Contains(args.ScreenPoint)) { return; } int tabIndexAt = draggedTabInfo.GetTabIndexAt(args.ScreenPoint); if (-1 == tabIndexAt) { return; } DockOperations.MoveTab(tab, tabIndexAt); draggedTabInfo.SetVirtualTabRect(tabIndexAt); draggedTabInfo.MoveTabRect(draggedTabInfo.DraggedTabPosition, tabIndexAt); draggedTabInfo.DraggedTabPosition = tabIndexAt; }
private void RestorePalettes() { List <ViewElement> list = Enumerable.ToList <ViewElement>(this.AutoHiddenViews); if (!Enumerable.Any <ViewElement>((IEnumerable <ViewElement>)list)) { return; } PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.TogglePalettes); foreach (ViewElement element in list) { DockOperations.SnapToBookmark(element); } foreach (ViewElement viewElement in list) { ExpressionView expressionView = viewElement as ExpressionView; if (expressionView != null) { expressionView.IsSelected = expressionView.WasSelectedBeforeAutoHide; } } if (this.SavedActiveView != null && this.SavedActiveView.WindowProfile == ViewManager.Instance.WindowProfile) { ViewManager.Instance.ActiveView = this.SavedActiveView; } this.SavedActiveView = (Microsoft.VisualStudio.PlatformUI.Shell.View)null; }
protected virtual bool IsValidDockTarget(DockTarget target, IList <DockSiteType> types, ViewElement floatingElement) { if (target != null && (target.TargetElement == null || target.TargetElement.AreDockTargetsEnabled) && types.Contains(target.DockSiteType)) { return(DockOperations.AreDockRestrictionsFulfilled(floatingElement.DockRestriction, target.TargetElement)); } return(false); }
protected override void ClearItems() { base.ClearItems(); if (this.Owner == null) { return; } DockOperations.TryCollapse((ViewElement)this.Owner); }
protected override void RemoveItem(int index) { base.RemoveItem(index); if (this.Owner == null) { return; } DockOperations.TryCollapse((ViewElement)this.Owner); }
private void ReleaseCollapseScope() { --this.preventCollapseReferences; if (this.preventCollapseReferences != 0) { return; } DockOperations.TryCollapse(this); }
private void ViewService_ViewOpened(object sender, ViewEventArgs e) { ViewBridge.LinkedView linkedView = (ViewBridge.LinkedView)Microsoft.VisualStudio.PlatformUI.Shell.View.Create(this.ActiveWindowProfile, "Document", typeof(ViewBridge.LinkedView)); linkedView.ViewReference = e.View; linkedView.Initialize(e.View); linkedView.Title = (object)e.View.Caption; linkedView.Content = (object)((IElementProvider)e.View).Element; linkedView.Hiding += new CancelEventHandler(this.View_Hiding); linkedView.IsSelectedChanged += new EventHandler(this.View_IsSelectedChanged); DockOperations.DockAt((ViewElement)this.documentGroup, (ViewElement)linkedView, -1); linkedView.Show(); }
private bool CanAutoHideView(ExecutedRoutedEventArgs args) { ViewElement element = args.Parameter as ViewElement; if (element == null) { return(false); } if (!(element.Parent is AutoHideGroup)) { return(DockOperations.CanAutoHide(element)); } return(true); }
private void HandleDockIntoTabStrip(DraggedTabInfo tabInfo, DragUndockHeader header, DragAbsoluteEventArgs args) { int dockPosition = tabInfo.GetClosestTabIndexAt(args.ScreenPoint); if (-1 == dockPosition) { return; } ViewElement viewElement = tabInfo.TargetElement; if (viewElement == null && tabInfo.GroupContainer != null) { viewElement = (ViewElement)DockOperations.CreateDocumentGroupAt(tabInfo.GroupContainer, tabInfo.GroupPosition); viewElement.DockedHeight = tabInfo.GroupDockedHeight; viewElement.DockedWidth = tabInfo.GroupDockedWidth; viewElement.FloatingHeight = tabInfo.GroupFloatingHeight; viewElement.FloatingWidth = tabInfo.GroupFloatingWidth; } if (!DockOperations.AreDockRestrictionsFulfilled(header.ViewElement, viewElement)) { return; } bool flag = false; ViewGroup viewGroup = tabInfo.NestedGroup as ViewGroup; if (viewGroup != null) { flag = viewGroup.Children.Contains(header.ViewElement); } if (!flag && tabInfo.TabRects.Count > 0 && args.ScreenPoint.X > tabInfo.TabRects[tabInfo.TabRects.Count - 1].Right) { dockPosition = tabInfo.TabRects.Count; } if (tabInfo.TabRects.Count == 0) { dockPosition = 0; } if (DockManager.Instance.DraggedTabInfo != null && -1 != DockManager.Instance.DraggedTabInfo.DraggedTabPosition) { DockManager.Instance.DraggedTabInfo.RemoveTabRect(DockManager.Instance.DraggedTabInfo.DraggedTabPosition); } DockOperations.DockAt(viewElement, header.ViewElement, dockPosition); tabInfo.TabStrip.IsNotificationNeeded = true; tabInfo.DraggedTabPosition = dockPosition; tabInfo.ClearVirtualTabRect(); DockManager.Instance.ClearAdorners(); }
private void OnSelectedItemHidden(object sender, SelectedItemHiddenEventArgs args) { GroupControl groupControl = args.OriginalSource as GroupControl; if (groupControl == null) { return; } NestedGroup nestedGroup = groupControl.DataContext as NestedGroup; int position = 0; if (ViewManager.Instance.Preferences.DocumentDockPreference == DockPreference.DockAtEnd) { position = args.LastVisiblePosition; } DockOperations.MoveTab(nestedGroup.SelectedElement, position); }
private void OnToggleDocked(object sender, ExecutedRoutedEventArgs args) { if (!this.CanToggleDocked(args)) { return; } ViewElement element = (ViewElement)args.Parameter; if (FloatSite.IsFloating(element)) { DockOperations.SnapToBookmark(element); } else { DockOperations.Float(element, element.WindowProfile); } }
protected virtual void OnAutoHideViewCore(ViewElement autoHidingElement, bool autoHideOnlyActiveView) { if (autoHidingElement.Parent is AutoHideGroup) { DockOperations.DockViewElementOrGroup(autoHidingElement, autoHideOnlyActiveView); } else { if (autoHideOnlyActiveView) { TabGroup tabGroup = autoHidingElement as TabGroup; if (tabGroup != null) { autoHidingElement = tabGroup.SelectedElement; } } DockOperations.AutoHide(autoHidingElement); } }
private void OnViewHeaderDragCompleted(object sender, DragAbsoluteCompletedEventArgs args) { if (((DragUndockHeader)args.OriginalSource).IsWindowTitleBar && args.IsCompleted) { DockManager.Instance.PerformDrop((DragAbsoluteEventArgs)args); } else { DockManager.Instance.ClearAdorners(); } if (!args.IsCompleted) { return; } DockOperations.ClearViewBookmarks(DockManager.Instance.DraggedViewElements); DockManager.Instance.DraggedTabInfo = (DraggedTabInfo)null; DockManager.Instance.IsDragging = false; DockManager.Instance.DraggedViewElements.Clear(); }
private bool IsDocked(WindowFrame frame) { if (!(frame.FrameView is ViewElement viewElement)) { return(false); } //verifying whether there is viewElement's ancestor type of DockRoot if (!DockOperations.CanAutoHide(viewElement)) { return(false); } if (OrientationOfDocked(viewElement) == _dockDirection) { return(true); } return(false); }
public void PerformDrop(DragAbsoluteEventArgs args) { DragUndockHeader dragUndockHeader = args.OriginalSource as DragUndockHeader; FloatingWindow floatingWindow = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <FloatingWindow>((Visual)dragUndockHeader); DockManager.DockSiteHitTestResult hitElement = this.FindHitElement(args.ScreenPoint, (Predicate <DockManager.DockSite>)(s => s.Visual != floatingWindow)); if (hitElement != null) { DockSiteAdorner ancestorOrSelf1 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockSiteAdorner>(hitElement.VisualHit); DockAdornerWindow ancestorOrSelf2 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockAdornerWindow>(hitElement.VisualHit); DockTarget dockTarget = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockTarget>(hitElement.VisualHit); DockDirection dockDirection = DockDirection.Fill; bool flag = false; bool createDocumentGroup = false; if (floatingWindow != null && this.IsValidFillPreviewOperation(dockTarget, dragUndockHeader.ViewElement)) { dockDirection = DockDirection.Fill; flag = true; } if (ancestorOrSelf1 != null && ancestorOrSelf2 != null && ancestorOrSelf2.AdornedElement != null) { dockDirection = ancestorOrSelf1.DockDirection; dockTarget = ancestorOrSelf2.AdornedElement as DockTarget; if (DockOperations.AreDockRestrictionsFulfilled(dragUndockHeader.ViewElement, dockTarget.TargetElement)) { flag = true; createDocumentGroup = ancestorOrSelf1.CreatesDocumentGroup; } } if (flag) { PerformanceUtility.MeasurePerformanceUntilRender(PerformanceEvent.DockPalette); dockTarget.RaiseEvent((RoutedEventArgs) new FloatingElementDockedEventArgs(DockManager.FloatingElementDockedEvent, dragUndockHeader.ViewElement, dockDirection, createDocumentGroup)); } } this.ClearAdorners(); }
protected bool ValidateOrReplaceViewGroup(ref ViewGroup viewGroup, WindowProfileValidationContext context) { DockOperations.TryCollapse((ViewElement)viewGroup); DockGroup dockGroup = viewGroup as DockGroup; if (dockGroup != null) { bool flag = this.ValidateOrReplaceDockGroup(ref dockGroup, context); viewGroup = (ViewGroup)dockGroup; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } NestedGroup nestedGroup = viewGroup as NestedGroup; if (nestedGroup != null) { bool flag = this.ValidateOrReplaceNestedGroup(ref nestedGroup, context); viewGroup = (ViewGroup)nestedGroup; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } AutoHideGroup autoHideGroup = viewGroup as AutoHideGroup; if (autoHideGroup != null) { autoHideGroup.SelectedElement = (ViewElement)null; bool flag = this.ValidateOrReplaceAutoHideGroup(ref autoHideGroup, context); viewGroup = (ViewGroup)autoHideGroup; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } AutoHideChannel autoHideChannel = viewGroup as AutoHideChannel; if (autoHideChannel != null) { bool flag = this.ValidateOrReplaceAutoHideChannel(ref autoHideChannel, context); viewGroup = (ViewGroup)autoHideChannel; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } ViewSite viewSite = viewGroup as ViewSite; if (viewSite != null) { bool flag = this.ValidateOrReplaceViewSite(ref viewSite, context); viewGroup = (ViewGroup)viewSite; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } AutoHideRoot autoHideRoot = viewGroup as AutoHideRoot; if (autoHideRoot != null) { bool flag = this.ValidateOrReplaceAutoHideRoot(ref autoHideRoot, context); viewGroup = (ViewGroup)autoHideRoot; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag); } DockRoot dockRoot = viewGroup as DockRoot; if (dockRoot == null) { return(this.ValidateOrReplaceCustomViewGroup(ref viewGroup, context)); } bool flag1 = this.ValidateOrReplaceDockRoot(ref dockRoot, context); viewGroup = (ViewGroup)dockRoot; this.ValidateOrReplaceViewElementCollection(viewGroup.Children, context); return(flag1); }
private static void Initialize(View view, WindowProfile owningProfile, string name) { view.Name = name; DockOperations.Float((ViewElement)view, owningProfile); }
protected virtual bool IsValidFillPreviewOperation(DockTarget dockTarget, ViewElement dockingView) { bool flag = false; if (dockTarget != null && dockTarget.DockTargetType == DockTargetType.FillPreview && (DockOperations.AreDockRestrictionsFulfilled(dockingView, dockTarget.TargetElement) && dockTarget.TargetElement.AreDockTargetsEnabled)) { flag = true; } return(flag); }
private void OnFloatingElementDocked(object sender, FloatingElementDockedEventArgs args) { if (args.Content == null) { return; } DockTarget dockTarget = (DockTarget)sender; if (args.CreateDocumentGroup) { DocumentGroup documentGroup = dockTarget.DataContext as DocumentGroup; DocumentGroupContainer container = dockTarget.DataContext as DocumentGroupContainer; if (documentGroup == null) { documentGroup = container.Children[0] as DocumentGroup; } if (container == null) { container = documentGroup.Parent as DocumentGroupContainer; } Orientation orientation = container.Orientation; int position = container.Children.IndexOf((ViewElement)documentGroup); switch (args.DockDirection) { case DockDirection.FirstValue: orientation = Orientation.Vertical; break; case DockDirection.Bottom: orientation = Orientation.Vertical; ++position; break; case DockDirection.Left: orientation = Orientation.Horizontal; break; case DockDirection.Right: orientation = Orientation.Horizontal; ++position; break; } container.Orientation = orientation; ViewElement viewElement = container.Children[0]; DockOperations.Dock((ViewElement)DockOperations.CreateDocumentGroupAt(container, position), args.Content, DockDirection.Fill); } else if (dockTarget.DockTargetType == DockTargetType.Inside || dockTarget.DockTargetType == DockTargetType.CenterOnly || (dockTarget.DockTargetType == DockTargetType.SidesOnly || dockTarget.DockTargetType == DockTargetType.FillPreview)) { ViewElement targetView = dockTarget.DataContext as ViewElement; DocumentGroup documentGroup = targetView as DocumentGroup; if (documentGroup != null && args.DockDirection != DockDirection.Fill) { targetView = (ViewElement)documentGroup.Parent; } DockOperations.Dock(targetView, args.Content, args.DockDirection); } else { DockOperations.DockOutside(dockTarget.DataContext as ViewGroup, args.Content, args.DockDirection); } }