Ejemplo n.º 1
0
        internal void PlaceMasterInternal(Master master, bool placeToChild)
        {
            if (master != null && !_masterGuidList.Contains(master.Guid) &&
                ParentDocument != null && ParentDocument.IsOpened)
            {
                _masterGuidList.Add(master.Guid);

                if (_masters != null)
                {
                    _masters.Add(master.Guid, master as Master);
                }

                // If this master is never placed in base view before.
                if (master.HasBeenPlacedInBaseView == false)
                {
                    // If this view is base view, set the flag
                    if (_viewGuid == ParentDocument.AdaptiveViewSet.Base.Guid)
                    {
                        master.HasBeenPlacedInBaseView = true;

                        // If the widget is not created in base view, set the create view style as the base view style.
                        // If the widget is IPageEmbeddedWidget, we don't update the child widgets style.
                        if (master.CreatedViewGuid != ParentDocument.AdaptiveViewSet.Base.Guid)
                        {
                            MasterStyle createdViewStyle = master.GetMasterStyle(master.CreatedViewGuid) as MasterStyle;
                            MasterStyle baseViewStyle    = master.MasterStyle as MasterStyle;
                            if (createdViewStyle != null)
                            {
                                Style.CopyStyle(createdViewStyle, baseViewStyle, null, null);
                            }
                        }
                    }
                }

                // Place to child page view.
                if (placeToChild)
                {
                    IAdaptiveView view = null;
                    if (_viewGuid == ParentDocument.AdaptiveViewSet.Base.Guid)
                    {
                        view = ParentDocument.AdaptiveViewSet.Base;
                    }
                    else
                    {
                        view = ParentDocument.AdaptiveViewSet.AdaptiveViews[_viewGuid];
                    }

                    if (view != null)
                    {
                        foreach (AdaptiveView childView in view.ChildViews)
                        {
                            PageView childPageView = ParentPage.PageViews[childView.Guid] as PageView;
                            if (childPageView != null)
                            {
                                childPageView.PlaceMasterInternal(master, true);
                            }
                        }
                    }
                }
            }
        }