예제 #1
0
        public LayoutInstance(IServiceProvider serviceProvider, IActivationSite parentSite, LayoutDefinition layoutDefinition, bool isInEditMode)
        {
            this.LayoutDefinition = layoutDefinition;
            this.LayoutDefinition.SlotDefinition.Changed        += OnRootSlotChanged;
            this.LayoutDefinition.ViewSources.CollectionChanged += OnLayoutDefinitionViewSourcesChanged;
            this.ParentSite   = parentSite;
            this.IsInEditMode = isInEditMode;

            this.serviceContainer = new ServiceContainer(serviceProvider);
            this.serviceContainer.AddService(typeof(IViewBindingService), this);

            this.ServiceProvider = serviceContainer;

            this.LayoutControl = new LayoutControl(this);
            this.LayoutControl.SlotDefinition = isInEditMode ? this.LayoutDefinition.SlotDefinition : this.LayoutDefinition.SlotDefinition.Clone();

            this.singleViewContentTemplate = this.LayoutControl.FindResource(isInEditMode ? "EditModeSingleViewContentTemplate" : "SingleViewContentTemplate") as DataTemplate;
            this.tabbedViewContentTemplate = this.LayoutControl.FindResource(isInEditMode ? "EditModeTabbedViewContentTemplate" : "TabbedViewContentTemplate") as DataTemplate;

            this.ourWindow = serviceProvider.GetService(typeof(ToolsUIWindow)) as ToolsUIWindow;

            object stateObject;

            // We do this trick (storing our activation state in our window per layout definition) so that
            // the layout editor can create an instance that matches the "real" layout states.
            if (!this.ourWindow.StateTable.TryGetValue(this.LayoutDefinition, out stateObject))
            {
                stateObject = new LayoutInstanceState();
                this.ourWindow.StateTable[this.LayoutDefinition] = stateObject;
            }

            this.state = (LayoutInstanceState)stateObject;

            EnsureSlotContentPopulation();
        }
예제 #2
0
        void IActivationSite.NotifyActivation(object child)
        {
            var site = child as ViewSite;

            if (site != null)
            {
                this.lastActiveChildSite = site;
                this.ParentSite.NotifyActivation(this);
            }
        }
예제 #3
0
        void IActivationSite.NotifyActivation(object child)
        {
            var slotContent = child as SlotContent;

            if (slotContent != null)
            {
                this.lastActiveChildSite = slotContent;
                this.ActivationIndex     = ++nextActivationIndex;
                this.ParentSite.NotifyActivation(this);
            }
        }
예제 #4
0
        public static T FindParentSite <T>(this IActivationSite site) where T : class, IActivationSite
        {
            for (var p = site; p != null; p = p.ParentSite)
            {
                if (p is T)
                {
                    return((T)p);
                }
            }

            return(null);
        }
예제 #5
0
        void IActivationSite.TunnelActivation()
        {
            if (this.lastActiveChildSite == null)
            {
                // We need to pick one... at random
                this.lastActiveChildSite = this.existingSlotContents.Values.FirstOrDefault();
                this.ActivationIndex     = ++nextActivationIndex;
            }

            if (this.lastActiveChildSite != null)
            {
                this.lastActiveChildSite.TunnelActivation();
            }
        }
예제 #6
0
        void IActivationSite.TunnelActivation()
        {
            if (this.lastActiveChildSite == null)
            {
                // We need to pick one...
                var tabControl = this.slotPanelChild as ViewTabControl;

                if (tabControl != null)
                {
                    this.lastActiveChildSite = tabControl.SelectedItem as ViewSite;
                }
            }

            if (this.lastActiveChildSite != null)
            {
                this.lastActiveChildSite.TunnelActivation();
            }
        }
예제 #7
0
        void IActivationSite.BubbleActivation(object child)
        {
            var site = child as ViewSite;

            if (site != null)
            {
                // Must set last active site before bubbling -- the bubble may cause an immediate tunnel.
                this.lastActiveChildSite = site;
                this.ParentSite.BubbleActivation(this);

                var tabControl = this.slotPanelChild as ViewTabControl;

                if (tabControl != null && tabControl.Items.Contains(site))
                {
                    tabControl.SelectedIndex = tabControl.Items.IndexOf(site);
                }
            }
        }
예제 #8
0
        public ViewSite(IActivationSite parentSite, ViewSource viewSource, DataTemplate template, bool editMode, IServiceProvider serviceProvider)
        {
            this.ParentSite = parentSite;
            this.ViewSource = viewSource;
            this.Template   = template;

            if (!editMode)
            {
                this.View = viewSource.ViewCreator.CreateView(serviceProvider);
                this.View.DocumentAffinity = this.ViewSource.Parent.DocumentFactoryName;
                this.View.Site             = this;

                // This binding allows views to control the view source title by simply changing their View.Title property.
                BindingOperations.SetBinding(this.View, View.TitleProperty, new Binding
                {
                    Source = this.ViewSource,
                    Path   = new PropertyPath(ViewSource.TitleProperty),
                    Mode   = BindingMode.TwoWay
                });
            }
        }
예제 #9
0
        public ViewSite(IActivationSite parentSite, ViewSource viewSource, DataTemplate template, bool editMode, IServiceProvider serviceProvider)
        {
            this.ParentSite = parentSite;
            this.ViewSource = viewSource;
            this.Template = template;

            if (!editMode)
            {
                this.View = viewSource.ViewCreator.CreateView(serviceProvider);
                this.View.DocumentAffinity = this.ViewSource.Parent.DocumentFactoryName;
                this.View.Site = this;

                // This binding allows views to control the view source title by simply changing their View.Title property.
                BindingOperations.SetBinding(this.View, View.TitleProperty, new Binding
                {
                    Source = this.ViewSource,
                    Path = new PropertyPath(ViewSource.TitleProperty),
                    Mode = BindingMode.TwoWay
                });
            }
        }
        void IActivationSite.NotifyActivation(object child)
        {
            var site = child as ViewSite;

            if (site != null)
            {
                this.lastActiveChildSite = site;
                this.ParentSite.NotifyActivation(this);
            }
        }
        void IActivationSite.TunnelActivation()
        {
            if (this.lastActiveChildSite == null)
            {
                // We need to pick one... 
                var tabControl = this.slotPanelChild as ViewTabControl;

                if (tabControl != null)
                {
                    this.lastActiveChildSite = tabControl.SelectedItem as ViewSite;
                }
            }

            if (this.lastActiveChildSite != null)
            {
                this.lastActiveChildSite.TunnelActivation();
            }
        }
        void IActivationSite.BubbleActivation(object child)
        {
            var site = child as ViewSite;

            if (site != null)
            {
                // Must set last active site before bubbling -- the bubble may cause an immediate tunnel.
                this.lastActiveChildSite = site;
                this.ParentSite.BubbleActivation(this);

                var tabControl = this.slotPanelChild as ViewTabControl;

                if (tabControl != null && tabControl.Items.Contains(site))
                {
                    tabControl.SelectedIndex = tabControl.Items.IndexOf(site);
                }
            }
        }