Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        protected override void AppendSpecificTypeProperties(StringBuilder builder)
        {
            IHamburgerMenu menu = _widget as IHamburgerMenu;
            builder.AppendFormat("\"direction\":\"{0}\",", menu.HiddenOn.ToString().ToLower());

            bool isClosedPage = false;
            if (!menu.MenuPage.IsOpened)
            {
                isClosedPage = true;
                menu.MenuPage.Open();
            }


            if (IsSetMD5 == true)
            {
                builder.AppendFormat("\"Content\":\"{0}\",", menu.MenuPage.MD5);
            }
            builder.Append("\"menuWidgets\":[");
            foreach (IWidget widget in menu.MenuPage.Widgets)
            {
                JsWidget jsWidget = JsWidgetFactory.CreateJsWidget(_service, widget, IsSetMD5);
                builder.Append(jsWidget.ToString());
                builder.Append(",");
            }

            if (isClosedPage)
            {
                menu.MenuPage.Close();
            }

            JsHelper.RemoveLastComma(builder);
            builder.Append("],");

            // menu button
            IHamburgerMenuButton button = menu.MenuButton;
            JsHamburgerMenuButton jsButton = new JsHamburgerMenuButton(_service, button);
            builder.Append("\"buttonWidget\":");
            builder.Append(jsButton.ToString());
            builder.Append(",");
        }
Exemplo n.º 3
0
        public IObjectContainer AddCustomObject(ICustomObject customObject, double x = 0, double y = 0)
        {
            IObjectContainer container = ParentPage.AddCustomObject(customObject);

            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 library should have same relative location, so make them have the same delta.
                widgetViewStyle.X += x;
                widgetViewStyle.Y += y;

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

                    IWidgetStyle buttonViewStyle = button.GetWidgetStyle(_viewGuid);
                    buttonViewStyle.X += x;
                    buttonViewStyle.Y += y;
                }

                PlaceWidgetInternal(widget, true);
            }

            // Custom object doesn't contain masters, so we don't handle container.MasterList.

            return(container);
        }