Exemplo n.º 1
0
        private ICollection <DockAdornerWindow> AddAdorners(DockManager.DockSite site, Visual ownerVisual, IList <DockSiteType> types, ViewElement floatingElement)
        {
            SortedList <DockDirection, DockTarget> targets = new SortedList <DockDirection, DockTarget>();

            for (DependencyObject sourceElement = (DependencyObject)ownerVisual; sourceElement != null; sourceElement = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.GetVisualOrLogicalParent(sourceElement))
            {
                DockTarget target = sourceElement as DockTarget;
                if (this.IsValidDockTarget(target, types, floatingElement))
                {
                    if (target.DockTargetType == DockTargetType.Outside)
                    {
                        targets[DockDirection.Left]       = target;
                        targets[DockDirection.Right]      = target;
                        targets[DockDirection.FirstValue] = target;
                        targets[DockDirection.Bottom]     = target;
                    }
                    else
                    {
                        DockTarget dockTarget;
                        if ((target.DockTargetType == DockTargetType.Inside || target.DockTargetType == DockTargetType.SidesOnly || target.DockTargetType == DockTargetType.CenterOnly) && !targets.TryGetValue(DockDirection.Fill, out dockTarget))
                        {
                            targets[DockDirection.Fill] = target;
                        }
                    }
                }
            }
            return(this.PrepareAndShowAdornerLayers(targets, site, floatingElement));
        }
Exemplo n.º 2
0
 public void RegisterSite(Visual visual, IntPtr hwnd)
 {
     if (this.visualToSite.ContainsKey(visual))
     {
         if (this.visualToSite[visual].Handle != hwnd)
         {
             throw new InvalidOperationException("Visual cannot be used in RegisterSite with two different window handles");
         }
     }
     else
     {
         DockManager.DockSite dockSite = new DockManager.DockSite()
         {
             Handle = hwnd,
             Visual = visual
         };
         this.visualToSite[visual] = dockSite;
         this.hwndToSite[hwnd]     = dockSite;
     }
 }
Exemplo n.º 3
0
        private IEnumerable <DockManager.DockSiteHitTestResult> FindHitElements(Point point, Predicate <DockManager.DockSite> includedSites)
        {
            List <DockManager.DockSite> sortedDockSites      = this.GetSortedDockSites();
            List <DockManager.DockSiteHitTestResult> results = new List <DockManager.DockSiteHitTestResult>();

            using (IEnumerator <DockManager.DockSite> enumerator = Enumerable.Where <DockManager.DockSite>((IEnumerable <DockManager.DockSite>)sortedDockSites, (Func <DockManager.DockSite, bool>)(w => includedSites(w))).GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    DockManager.DockSite site = enumerator.Current;
                    if (PresentationSource.FromDependencyObject((DependencyObject)site.Visual) != null)
                    {
                        VisualTreeHelper.HitTest(site.Visual, new HitTestFilterCallback(this.ExcludeNonVisualElements), (HitTestResultCallback)(result =>
                        {
                            results.Add(new DockManager.DockSiteHitTestResult(site, (Visual)result.VisualHit));
                            return(HitTestResultBehavior.Stop);
                        }), (HitTestParameters) new PointHitTestParameters(site.Visual.PointFromScreen(point)));
                    }
                }
            }
            return((IEnumerable <DockManager.DockSiteHitTestResult>)results);
        }
Exemplo n.º 4
0
 public DockSiteHitTestResult(DockManager.DockSite site, Visual visualHit)
 {
     this.DockSite  = site;
     this.VisualHit = visualHit;
 }
Exemplo n.º 5
0
        protected virtual ICollection <DockAdornerWindow> PrepareAndShowAdornerLayers(SortedList <DockDirection, DockTarget> targets, DockManager.DockSite site, ViewElement floatingElement)
        {
            HashSet <DockAdornerWindow> hashSet     = new HashSet <DockAdornerWindow>();
            DockAdornerWindow           insertAfter = (DockAdornerWindow)null;

            foreach (KeyValuePair <DockDirection, DockTarget> keyValuePair in targets)
            {
                DockAdornerWindow adornerLayer = site.GetAdornerLayer(keyValuePair.Key);
                hashSet.Add(adornerLayer);
                adornerLayer.AdornedElement             = (FrameworkElement)keyValuePair.Value;
                adornerLayer.DockDirection              = keyValuePair.Key;
                adornerLayer.Orientation                = this.GetTargetOrientation(keyValuePair.Value);
                adornerLayer.AreOuterTargetsEnabled     = floatingElement.DockRestriction == DockRestrictionType.None;
                adornerLayer.AreInnerTargetsEnabled     = !this.IsDocumentGroupContainerTarget(keyValuePair.Value);
                adornerLayer.IsInnerCenterTargetEnabled = keyValuePair.Value.DockTargetType != DockTargetType.SidesOnly;
                adornerLayer.AreInnerSideTargetsEnabled = keyValuePair.Value.DockTargetType != DockTargetType.CenterOnly;
                this.PrepareAdornerLayer(adornerLayer, floatingElement);
                adornerLayer.PrepareAndShow(insertAfter);
                insertAfter = adornerLayer;
            }
            return((ICollection <DockAdornerWindow>)hashSet);
        }