Example #1
0
 internal PageViewStyle(PageView ownerPageView)
     : base(ownerPageView.Guid, "PageViewStyle")
 {
     // PageViewStyle must exist with its owner.
     Debug.Assert(ownerPageView != null);
     _ownerPageView = ownerPageView;
 }
Example #2
0
        public IMasterPage CreateMasterPage(ISerializeWriter writer, string pageName, Stream thumbnail)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            CheckOpen();

            IMasterPage newMasterPage = CreateMasterPage(pageName);

            newMasterPage.Open();

            PageView         baseView  = newMasterPage.PageViews[AdaptiveViewSet.Base.Guid] as PageView;
            IObjectContainer container = baseView.AddObjects(writer.WriteToStream());

            // Adjust widgets position from coordinate (0,0);
            baseView.PageViewStyle.X = 0;
            baseView.PageViewStyle.Y = 0;

            if (thumbnail != null)
            {
                newMasterPage.Thumbnail = thumbnail;
            }

            newMasterPage.Close();

            return(newMasterPage);
        }
Example #3
0
        public IObjectContainer AddMasterPageObject(Guid masterPageGuid, Guid viewGuid, double x = 0, double y = 0)
        {
            IObjectContainer container = ParentPage.AddMasterPageObject(masterPageGuid, viewGuid);

            IMasterPage masterPage = ParentDocument.MasterPages[masterPageGuid];

            masterPage.Open();

            PageView masterPageView = masterPage.PageViews[viewGuid] as PageView;

            if (masterPageView == null)
            {
                masterPageView = masterPage.PageViews[ParentDocument.AdaptiveViewSet.Base.Guid] as PageView;
            }

            double xDelta = masterPageView.PageViewStyle.X - x;
            double yDelta = masterPageView.PageViewStyle.Y - y;

            foreach (Widget widget in container.WidgetList)
            {
                // Set the created view as the current view because this is the first time when the widget
                // is added in the current document.
                widget.CreatedViewGuid = _viewGuid;

                // Set this flag to false. PlaceWidgetInternal method will set this flag base on checking
                // if this is base view.
                widget.HasBeenPlacedInBaseView = false;

                // Get widget style in this view.
                IWidgetStyle widgetViewStyle = widget.GetWidgetStyle(_viewGuid);

                // Widgets in master page should have same relative location, so make them have the same delta.
                widgetViewStyle.X -= xDelta;
                widgetViewStyle.Y -= yDelta;

                if (widget is IHamburgerMenu)
                {
                    IHamburgerMenu       menu   = widget as IHamburgerMenu;
                    IHamburgerMenuButton button = menu.MenuButton;

                    IWidgetStyle buttonViewStyle = button.GetWidgetStyle(_viewGuid);
                    buttonViewStyle.X -= xDelta;
                    buttonViewStyle.Y -= yDelta;
                }

                PlaceWidgetInternal(widget, true);
            }

            // Master Page doesn't contain masters, so we don't handle container.MasterList.

            return(container);
        }
Example #4
0
        internal static CustomObjectPage CreateCustomObject(Document document, ISerializeWriter writer,
                                                            string objectName, Stream icon, Stream thumbnail)
        {
            CustomObjectPage objectPage = document.CreatePage(objectName) as CustomObjectPage;

            // Create a new node in the page tree.
            ITreeNode node = document.DocumentSettings.LayoutSetting.PageTree.AddChild(TreeNodeType.Page);

            node.AttachedObject = objectPage;

            objectPage.Open();

            // Add to base view.
            PageView         baseView  = objectPage.PageViews[document.AdaptiveViewSet.Base.Guid] as PageView;
            IObjectContainer container = baseView.AddObjects(writer.WriteToStream());

            // Adjust widgets position from coordinate (0,0);
            baseView.PageViewStyle.X = 0;
            baseView.PageViewStyle.Y = 0;

            if (icon != null)
            {
                objectPage.Icon = icon;
            }

            if (thumbnail != null)
            {
                objectPage.Thumbnail = thumbnail;
            }

            // Page must be closed after setting icon and thumbnail, so that they can be saved into the file.
            // Document.save() only call save() on opened pages.
            objectPage.Close();

            document.UpdateLastAccessTime();

            return(objectPage);
        }
Example #5
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);
                            }
                        }
                    }
                }
            }
        }
Example #6
0
        internal void PlaceWidgetInternal(Widget widget, bool placeToChild)
        {
            if (widget != null && !_widgetGuidList.Contains(widget.Guid) &&
                ParentDocument != null && ParentDocument.IsOpened)
            {
                _widgetGuidList.Add(widget.Guid);

                if (_widgets != null)
                {
                    _widgets.Add(widget.Guid, widget as Widget);
                }

                // If this widget is never placed in base view before.
                if (widget.HasBeenPlacedInBaseView == false)
                {
                    // If this view is base view, set the flag
                    if (_viewGuid == ParentDocument.AdaptiveViewSet.Base.Guid)
                    {
                        widget.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 (widget.CreatedViewGuid != ParentDocument.AdaptiveViewSet.Base.Guid)
                        {
                            WidgetStyle createdViewStyle = widget.GetWidgetStyle(widget.CreatedViewGuid) as WidgetStyle;
                            WidgetStyle baseViewStyle    = widget.WidgetStyle as WidgetStyle;
                            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.PlaceWidgetInternal(widget, true);
                            }
                        }
                    }
                }
            }
        }