예제 #1
0
            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);
                }
            }
예제 #2
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();
            }
        }