Esempio n. 1
0
        public void Initialize(ViewElement view)
        {
            this.sibling = DraggedTabInfo.FindFirstSibling(view);
            ViewGroup parent = view.Parent;

            this.nestedGroup         = (ViewElement)null;
            this.groupPosition       = -1;
            this.groupFloatingHeight = 0.0;
            this.groupFloatingWidth  = 0.0;
            this.groupContainer      = (DocumentGroupContainer)null;
            if (parent == null)
            {
                return;
            }
            if (parent.Parent != null)
            {
                this.groupPosition = parent.Parent.Children.IndexOf((ViewElement)parent);
                if (parent != null && parent.Children.Count == 1 && parent.Parent.Children.Count == 1)
                {
                    this.nestedGroup = (ViewElement)parent;
                }
            }
            this.groupDockedWidth    = parent.DockedWidth;
            this.groupDockedHeight   = parent.DockedHeight;
            this.groupFloatingWidth  = parent.FloatingWidth;
            this.groupFloatingHeight = parent.FloatingHeight;
            this.groupContainer      = parent.Parent as DocumentGroupContainer;
        }
Esempio n. 2
0
        internal static string GetAutomationPeerCaption(this ViewElement viewElement)
        {
            string str   = string.Empty;
            View   view1 = viewElement as View;

            if (view1 != null)
            {
                str = view1.Title.ToString();
            }
            else
            {
                TabGroup tabGroup = viewElement as TabGroup;
                if (tabGroup != null)
                {
                    View view2 = tabGroup.SelectedElement as View;
                    if (view2 != null)
                    {
                        str = view2.Title.ToString();
                    }
                }
                else
                {
                    DockGroup dockGroup = viewElement as DockGroup;
                    if (dockGroup != null && dockGroup.VisibleChildren.Count == 1)
                    {
                        str = ExtensionMethods.GetAutomationPeerCaption(dockGroup.VisibleChildren[0]);
                    }
                }
            }
            return(str ?? string.Empty);
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        private bool ShouldHideTabGroup(ViewElement element, bool hideOnlyActiveView)
        {
            FloatSite floatSite = ViewElement.FindRootElement(element) as FloatSite;
            bool      flag      = floatSite != null && !floatSite.HasMultipleOnScreenViews;

            return(element.Parent is TabGroup && (flag && this.Preferences.AlwaysHideAllViewInFloatingTabGroup || !hideOnlyActiveView));
        }
Esempio n. 5
0
        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;
        }
Esempio n. 6
0
        private void CreateDocumentGroup(ViewElement view, Orientation orientation)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            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");
            }
            DocumentGroup documentGroup2 = DocumentGroup.Create();

            documentGroup2.FloatingHeight = 200.0;
            documentGroup2.FloatingWidth  = 300.0;
            documentGroup2.IsVisible      = true;
            documentGroup1.Children.Remove(view);
            documentGroup2.Children.Add(view);
            if (documentGroupContainer.VisibleChildren.Count <= 1)
            {
                documentGroupContainer.Orientation = orientation;
            }
            int num = documentGroupContainer.Children.IndexOf((ViewElement)documentGroup1);

            documentGroupContainer.Children.Insert(num + 1, (ViewElement)documentGroup2);
            documentGroup2.SelectedElement = view;
        }
        public void Validate(WindowProfile profile)
        {
            List <MainSite> mainSites = new List <MainSite>();

            for (int index = 0; index < profile.Children.Count; ++index)
            {
                ViewElement element = profile.Children[index];
                if (element is MainSite)
                {
                    mainSites.Add(element as MainSite);
                }
                if (!(!(element is ViewGroup) ? this.ValidateElement(element) : this.ValidateGroup(element as ViewGroup)))
                {
                    profile.Children.Remove(element);
                    --index;
                }
            }
            if (mainSites.Count == 0)
            {
                MainSite mainSite = MainSite.Create();
                mainSite.Child = WindowProfile.CreateDefaultMainSiteContent();
                profile.Children.Add((ViewElement)mainSite);
            }
            else
            {
                if (mainSites.Count > 1)
                {
                    this.DeleteExtraMainSites(mainSites, profile);
                }
                foreach (MainSite site in mainSites)
                {
                    this.PostValidation(site);
                }
            }
        }
        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);
        }
Esempio n. 9
0
        private static void OnChildChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            ViewSite    viewSite    = (ViewSite)obj;
            ViewElement viewElement = args.NewValue as ViewElement;

            if (viewElement == null)
            {
                if (viewSite.Children.Count <= 0)
                {
                    return;
                }
                viewSite.Children.Clear();
            }
            else if (viewSite.Children.Count == 0)
            {
                viewSite.Children.Add(viewElement);
            }
            else
            {
                if (viewSite.Children[0] == viewElement)
                {
                    return;
                }
                viewSite.Children[0] = viewElement;
            }
        }
Esempio n. 10
0
        private static void OnDockedHeightChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
        {
            ViewElement viewElement = (ViewElement)obj;

            viewElement.ValidateDockedHeight((SplitterLength)args.NewValue);
            viewElement.OnDockedHeightChanged();
        }
Esempio n. 11
0
 public static bool GetIsAutoHideCenter(ViewElement element)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     return((bool)element.GetValue(AutoHideRoot.IsAutoHideCenterProperty));
 }
Esempio n. 12
0
 public static void SetIsAutoHideCenter(ViewElement element, bool center)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     element.SetValue(AutoHideRoot.IsAutoHideCenterProperty, center);
 }
Esempio n. 13
0
 public override bool IsChildAllowed(ViewElement element)
 {
     if (!(element is View))
     {
         return(element is ViewBookmark);
     }
     return(true);
 }
Esempio n. 14
0
 private void OnChildrenChanged(object sender, NotifyCollectionChangedEventArgs args)
 {
     if (this.Children.Count > 1)
     {
         throw new InvalidOperationException("ViewSite does not support multiple children");
     }
     this.Child = this.Children.Count > 0 ? this.Children[0] : (ViewElement)null;
 }
Esempio n. 15
0
 public override bool IsChildAllowed(ViewElement element)
 {
     if (element is AutoHideChannel)
     {
         return(true);
     }
     return(element is DockRoot);
 }
Esempio n. 16
0
 private bool IsOwnedVisibleChild(ViewElement element)
 {
     if (this.Children.Contains(element))
     {
         return(element.IsVisible);
     }
     return(false);
 }
Esempio n. 17
0
 public override bool IsChildAllowed(ViewElement element)
 {
     if (!(element is DockGroup) && !(element is View) && !(element is ViewBookmark))
     {
         return(element is TabGroup);
     }
     return(true);
 }
Esempio n. 18
0
 public static bool IsAutoHidden(ViewElement element)
 {
     return(Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <AutoHideChannel, ViewElement>(element, (Func <ViewElement, ViewElement>)(e =>
     {
         if (e == null)
         {
             return (ViewElement)null;
         }
         return (ViewElement)e.Parent;
     })) != null);
 }
Esempio n. 19
0
 private void OnHideViewCore(ViewElement closingViewElement, bool hideOnlyActiveView)
 {
     if (this.ShouldHideTabGroup(closingViewElement, hideOnlyActiveView))
     {
         closingViewElement = (ViewElement)closingViewElement.Parent;
     }
     foreach (View view in closingViewElement.FindAll((Predicate <ViewElement>)(e => e is View)))
     {
         view.Hide();
     }
 }
Esempio n. 20
0
        private bool ValidateElement(ViewElement element)
        {
            if (!this.IsFiniteSizeInValidRange(element.MinimumHeight))
            {
                element.MinimumHeight = (double)ViewElement.MinimumHeightProperty.DefaultMetadata.DefaultValue;
            }
            if (!this.IsFiniteSizeInValidRange(element.MinimumWidth))
            {
                element.MinimumWidth = (double)ViewElement.MinimumWidthProperty.DefaultMetadata.DefaultValue;
            }
            if (!this.IsFiniteSizeInValidRange(element.AutoHideHeight))
            {
                element.AutoHideHeight = (double)ViewElement.AutoHideHeightProperty.DefaultMetadata.DefaultValue;
            }
            if (!this.IsFiniteSizeInValidRange(element.AutoHideWidth))
            {
                element.AutoHideWidth = (double)ViewElement.AutoHideWidthProperty.DefaultMetadata.DefaultValue;
            }
            if (!this.IsFiniteSizeInValidRange(element.FloatingHeight))
            {
                element.FloatingHeight = (double)ViewElement.FloatingHeightProperty.DefaultMetadata.DefaultValue;
            }
            if (!this.IsFiniteSizeInValidRange(element.FloatingWidth))
            {
                element.FloatingWidth = (double)ViewElement.FloatingWidthProperty.DefaultMetadata.DefaultValue;
            }
            if (!this.IsValueInValidRange(element.FloatingLeft, double.NegativeInfinity, double.PositiveInfinity, false, false))
            {
                element.FloatingLeft = (double)ViewElement.FloatingLeftProperty.DefaultMetadata.DefaultValue;
            }
            if (!this.IsValueInValidRange(element.FloatingTop, double.NegativeInfinity, double.PositiveInfinity, false, false))
            {
                element.FloatingTop = (double)ViewElement.FloatingTopProperty.DefaultMetadata.DefaultValue;
            }
            MainSite site1 = element as MainSite;

            if (site1 != null)
            {
                return(this.ValidateElement(site1));
            }
            FloatSite site2 = element as FloatSite;

            if (site2 != null)
            {
                return(this.ValidateElement(site2));
            }
            DocumentGroupContainer container = element as DocumentGroupContainer;

            if (container != null)
            {
                return(this.ValidateElement(container));
            }
            return(true);
        }
Esempio n. 21
0
        internal static void InsertNewParent(this ViewElement oldView, ViewGroup parent)
        {
            ViewGroup parent1 = oldView.Parent;

            if (parent1 != null)
            {
                int index = parent1.Children.IndexOf(oldView);
                parent.IsVisible        = oldView.IsVisible;
                parent1.Children[index] = (ViewElement)parent;
            }
            parent.Children.Add(oldView);
        }
Esempio n. 22
0
 public static ViewElement FindRootElement(ViewElement element)
 {
     if (element == null)
     {
         throw new ArgumentNullException("element");
     }
     while (element.Parent != null)
     {
         element = (ViewElement)element.Parent;
     }
     return(element);
 }
Esempio n. 23
0
        internal static ViewBookmarkType GetBookmarkType(this ViewElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            ViewBookmarkType viewBookmarkType = ViewBookmarkType.Default;

            if (element is DocumentGroup || element is DocumentGroupContainer || element.Parent != null && element.Parent is DocumentGroup)
            {
                viewBookmarkType = ViewBookmarkType.DocumentWell;
            }
            return(viewBookmarkType);
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        public void ActivateFloatingControl(ViewElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            FloatSite      key = ViewElement.FindRootElement(element) as FloatSite;
            FloatingWindow floatingWindow;

            if (key == null || !this.floatingWindows.TryGetValue(key, out floatingWindow))
            {
                return;
            }
            floatingWindow.Activate();
        }
Esempio n. 26
0
 public ViewElement Find(Predicate <ViewElement> predicate)
 {
     if (predicate == null)
     {
         return((ViewElement)null);
     }
     foreach (ViewElement viewElement1 in (IEnumerable <ViewElement>) this.Children)
     {
         ViewElement viewElement2 = viewElement1.Find(predicate);
         if (viewElement2 != null)
         {
             return(viewElement2);
         }
     }
     return((ViewElement)null);
 }
Esempio n. 27
0
        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();
        }
Esempio n. 28
0
        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);
            }
        }
Esempio n. 29
0
        private static ViewElement FindFirstSibling(ViewElement element)
        {
            ViewElement viewElement1 = (ViewElement)null;

            if (element.Parent != null)
            {
                foreach (ViewElement viewElement2 in (IEnumerable <ViewElement>)element.Parent.Children)
                {
                    if (viewElement2 != element && !(viewElement2 is ViewBookmark))
                    {
                        viewElement1 = viewElement2;
                        break;
                    }
                }
            }
            return(viewElement1);
        }
Esempio n. 30
0
        private void EnsureVisibleChildAtIndex(int visibleChildIndex, ViewElement child)
        {
            if (object.ReferenceEquals((object)this.visibleChildren[visibleChildIndex], (object)child))
            {
                return;
            }
            int oldIndex = this.visibleChildren.IndexOf(child);

            if (oldIndex < 0)
            {
                this.visibleChildren.Insert(visibleChildIndex, child);
            }
            else
            {
                this.visibleChildren.Move(oldIndex, visibleChildIndex);
            }
        }