protected bool ValidateOrReplaceViewSite(ref ViewSite viewSite, WindowProfileValidationContext context)
        {
            if (viewSite.Parent != null)
            {
                return(false);
            }
            FloatSite floatSite = viewSite as FloatSite;

            if (floatSite != null)
            {
                if (floatSite.Children.Count == 0)
                {
                    return(false);
                }
                bool flag = this.ValidateOrReplaceFloatSite(ref floatSite, context);
                viewSite = (ViewSite)floatSite;
                return(flag);
            }
            MainSite mainSite = viewSite as MainSite;

            if (mainSite == null)
            {
                return(this.ValidateOrReplaceCustomViewSite(ref viewSite, context));
            }
            context.MainSites.Add(mainSite);
            bool flag1 = this.ValidateOrReplaceMainSite(ref mainSite, context);

            viewSite = (ViewSite)mainSite;
            return(flag1);
        }
Esempio n. 2
0
 private void UpdateDockPreview(DragAbsoluteEventArgs args, FloatingElement floatingElement)
 {
     DockManager.DockSiteHitTestResult hitElement = this.FindHitElement(args.ScreenPoint, (Predicate <DockManager.DockSite>)(s => s.Visual != floatingElement));
     if (hitElement != null)
     {
         DockSiteAdorner   ancestorOrSelf1 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockSiteAdorner>(hitElement.VisualHit);
         DockAdornerWindow ancestorOrSelf2 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockAdornerWindow>(hitElement.VisualHit);
         DockTarget        ancestorOrSelf3 = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestorOrSelf <DockTarget>(hitElement.VisualHit);
         FloatSite         floatSite       = floatingElement.Content as FloatSite;
         DockDirection     dockDirection   = DockDirection.Fill;
         FrameworkElement  adornedElement  = (FrameworkElement)null;
         if (floatSite == null)
         {
             throw new InvalidOperationException("Dragging element must be a FloatSite");
         }
         if (floatSite.Child == null)
         {
             throw new InvalidOperationException("floatSite must have at least one child.");
         }
         ViewElement child = floatSite.Child;
         if (this.IsValidFillPreviewOperation(ancestorOrSelf3, child))
         {
             dockDirection  = DockDirection.Fill;
             adornedElement = ancestorOrSelf3.AdornmentTarget == null ? (FrameworkElement)ancestorOrSelf3 : ancestorOrSelf3.AdornmentTarget;
         }
         if (ancestorOrSelf1 != null && ancestorOrSelf2 != null && ancestorOrSelf2.AdornedElement != null)
         {
             dockDirection  = ancestorOrSelf1.DockDirection;
             adornedElement = ancestorOrSelf2.AdornedElement;
             if (!ancestorOrSelf1.CreatesDocumentGroup && dockDirection != DockDirection.Fill && adornedElement.DataContext is DocumentGroup)
             {
                 adornedElement = (FrameworkElement)Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <DocumentGroupContainerControl>((Visual)adornedElement);
             }
         }
         if (adornedElement != null)
         {
             Rect dockPreviewRect = this.GetDockPreviewRect(dockDirection, adornedElement, child);
             this.DockPreviewWindow.Left   = dockPreviewRect.Left;
             this.DockPreviewWindow.Top    = dockPreviewRect.Top;
             this.DockPreviewWindow.Width  = dockPreviewRect.Width;
             this.DockPreviewWindow.Height = dockPreviewRect.Height;
             this.OnDockPreviewWindowShowing(this.DockPreviewWindow, dockDirection);
             this.DockPreviewWindow.Show();
         }
         else
         {
             this.HideDockPreview();
         }
     }
     else
     {
         this.HideDockPreview();
     }
 }
        protected override FloatingWindow CreateFloatingWindow(FloatSite floatSite)
        {
            bool           isSizable      = (bool)ExpressionView.IsSizableWhenFloatingProperty.DefaultMetadata.DefaultValue;
            ExpressionView expressionView = floatSite.Child as ExpressionView;

            if (expressionView != null)
            {
                isSizable = expressionView.IsSizableWhenFloating;
            }
            return((FloatingWindow) new ExpressionFloatingWindow(isSizable));
        }
Esempio n. 4
0
        internal override DraggedTabInfo GetAutodockTarget(DragAbsoluteEventArgs args)
        {
            FloatingElement ancestor = Microsoft.VisualStudio.PlatformUI.ExtensionMethods.FindAncestor <FloatingElement>((Visual)(args.OriginalSource as DragUndockHeader));

            if (ancestor != null)
            {
                FloatSite floatSite = ancestor.DataContext as FloatSite;
                if (floatSite != null)
                {
                    ConstrainedView constrainedView = floatSite.Child as ConstrainedView;
                    if (constrainedView != null && !constrainedView.CanAutoDock())
                    {
                        return((DraggedTabInfo)null);
                    }
                }
            }
            return(base.GetAutodockTarget(args));
        }
Esempio n. 5
0
        private void UpdateAdorners(DragAbsoluteEventArgs args, FloatingWindow floatingWindow)
        {
            List <DockSiteType> list = new List <DockSiteType>();

            list.Add(DockSiteType.Default);
            list.Add(DockSiteType.NonDraggable);
            FloatSite floatSite = floatingWindow.DataContext as FloatSite;

            if (floatSite == null)
            {
                return;
            }
            ViewElement child = floatSite.Child;

            if (child == null)
            {
                return;
            }
            this.UpdateAdorners(args, (FloatingElement)floatingWindow, (IList <DockSiteType>)list, child);
        }
 protected virtual bool ValidateOrReplaceFloatSite(ref FloatSite floatSite, WindowProfileValidationContext context)
 {
     return(true);
 }
Esempio n. 7
0
        private void AttachPalettes(Workspace newWorkspace)
        {
            Workspace workspace = this.ActiveWorkspace as Workspace;

            if (workspace != null)
            {
                foreach (Microsoft.VisualStudio.PlatformUI.Shell.View view in workspace.WindowProfile.FindAll((Predicate <ViewElement>)(v => v is Microsoft.VisualStudio.PlatformUI.Shell.View)))
                {
                    if (this.paletteRegistry[view.Name] != null)
                    {
                        view.Content = (object)null;
                    }
                }
            }
            using (ViewManager.Instance.DeferActiveViewChanges())
            {
                foreach (PaletteRegistryEntry paletteRegistryEntry in (IEnumerable <PaletteRegistryEntry>) this.paletteRegistry.PaletteRegistryEntries)
                {
                    Microsoft.VisualStudio.PlatformUI.Shell.View view = newWorkspace.FindPalette(paletteRegistryEntry.Name) ?? Microsoft.VisualStudio.PlatformUI.Shell.View.Create(newWorkspace.WindowProfile, paletteRegistryEntry.Name, paletteRegistryEntry.ViewProperties.ViewType);
                    ExpressionView expressionView = view as ExpressionView;
                    if (expressionView == null || !paletteRegistryEntry.ViewProperties.ViewType.IsAssignableFrom(view.GetType()))
                    {
                        expressionView = Microsoft.VisualStudio.PlatformUI.Shell.View.Create(newWorkspace.WindowProfile, paletteRegistryEntry.Name, paletteRegistryEntry.ViewProperties.ViewType) as ExpressionView;
                        foreach (PropertyInfo propertyInfo in view.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
                        {
                            PropertyInfo property = expressionView.GetType().GetProperty(propertyInfo.Name, BindingFlags.Instance | BindingFlags.Public);
                            if (property != (PropertyInfo)null && property.CanWrite && property.Name != "Parent")
                            {
                                object obj = propertyInfo.GetValue((object)view, (object[])null);
                                property.SetValue((object)expressionView, obj, (object[])null);
                            }
                        }
                        expressionView.Detach();
                        expressionView.IsDesiredVisible = view.IsVisible;
                        IList <ViewElement> list = (IList <ViewElement>)view.Parent.Children;
                        int index = list.IndexOf((ViewElement)view);
                        list[index] = (ViewElement)expressionView;
                    }
                    expressionView.Content = (object)paletteRegistryEntry.Content;
                    expressionView.Title   = (object)paletteRegistryEntry.Caption;
                    if (double.IsNaN(expressionView.FloatingLeft) || double.IsNaN(expressionView.FloatingTop))
                    {
                        Size?defaultFloatSize = paletteRegistryEntry.ViewProperties.DefaultFloatSize;
                        if (defaultFloatSize.HasValue && defaultFloatSize.HasValue)
                        {
                            expressionView.FloatingWidth  = defaultFloatSize.Value.Width;
                            expressionView.FloatingHeight = defaultFloatSize.Value.Height;
                            FloatSite ancestor = ExtensionMethods.FindAncestor <FloatSite>((ViewElement)expressionView);
                            if (ancestor != null)
                            {
                                bool flag = true;
                                foreach (ViewElement viewElement in ancestor.FindAll((Predicate <ViewElement>)(value => value != expressionView)))
                                {
                                    if (!double.IsNaN(viewElement.FloatingLeft) && !double.IsNaN(viewElement.FloatingTop))
                                    {
                                        flag = false;
                                        break;
                                    }
                                }
                                if (flag)
                                {
                                    ancestor.FloatingWidth  = expressionView.FloatingWidth;
                                    ancestor.FloatingHeight = expressionView.FloatingHeight;
                                }
                            }
                        }
                    }
                    paletteRegistryEntry.ViewProperties.Apply(expressionView);
                }
            }
            foreach (ViewElement viewElement in Enumerable.ToArray <ViewElement>(newWorkspace.WindowProfile.FindAll((Predicate <ViewElement>)(v =>
            {
                Microsoft.VisualStudio.PlatformUI.Shell.View view = v as Microsoft.VisualStudio.PlatformUI.Shell.View;
                if (view != null)
                {
                    return(view.Content == null);
                }
                return(false);
            }))))
            {
                viewElement.Detach();
            }
        }