Exemplo n.º 1
0
        protected override void AppendSpecificTypeProperties(StringBuilder builder)
        {
            IToast toast        = _widget as IToast;
            bool   bTouchClose  = false;
            int    exposureTime = 0;

            switch (toast.CloseSetting)
            {
            case ToastCloseSetting.ExposureTime:
                exposureTime = toast.ExposureTime * 1000;      // ExposureTime is in milliseconds in js.
                bTouchClose  = false;
                break;

            case ToastCloseSetting.CloseButton:
                exposureTime = 0;
                bTouchClose  = false;
                break;

            case ToastCloseSetting.AreaTouch:
                exposureTime = 0;
                bTouchClose  = true;
                break;

            default:
                break;
            }

            builder.AppendFormat("\"exposureTime\":{0},", exposureTime);
            builder.AppendFormat("\"bTouchClose\":{0},", bTouchClose.ToString().ToLower());

            bool isClosedPage = false;

            if (!toast.ToastPage.IsOpened)
            {
                isClosedPage = true;
                toast.ToastPage.Open();
            }

            if (IsSetMD5 == true)
            {
                builder.AppendFormat("\"Content\":\"{0}\",", toast.ToastPage.MD5);
            }

            builder.Append("\"toastWidgets\":[");
            foreach (IWidget widget in toast.ToastPage.Widgets)
            {
                JsWidget jsWidget = JsWidgetFactory.CreateJsWidget(_service, widget, IsSetMD5);
                builder.Append(jsWidget.ToString());
                builder.Append(",");
            }

            if (isClosedPage)
            {
                toast.ToastPage.Close();
            }

            JsHelper.RemoveLastComma(builder);
            builder.Append("],");
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("[");

            foreach (IWidget widget in _page.Widgets)
            {
                JsWidget jsWidget = JsWidgetFactory.CreateJsWidget(_service, widget, _IsSetMD5);
                builder.Append(jsWidget.ToString());
                builder.Append(",");
            }

            JsHelper.RemoveLastComma(builder);

            builder.Append("]");

            return(builder.ToString());
        }
Exemplo n.º 3
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.º 4
0
        public override string ToString()
        {
            StringBuilder content = new StringBuilder();

            if (_page is IMasterPage)
            {
                content.Append("var master_data={");
            }
            else
            {
                content.Append("var page_data={");
            }

            content.AppendFormat("\"pageName\":\"{0}\",", JsHelper.EscapeDoubleQuote(_page.Name));
            content.AppendFormat("\"pageID\":\"{0}\",", _page.Guid.ToString());
            if (_byMD5 == true)
            {
                content.AppendFormat("\"MD5\":\"{0}\",", _page.MD5);
            }


            JsPageNotes pageNotes = new JsPageNotes(_service, _page);

            content.Append(pageNotes.ToString());
            content.Append(",");

            // adaptiveViews - This array must be sorted by width value. from small width to great width
            List <IAdaptiveView> viewList        = new List <IAdaptiveView>(_service.RenderingDocument.AdaptiveViewSet.AdaptiveViews.OfType <IAdaptiveView>());
            List <IAdaptiveView> orderedViewList = viewList.OrderBy(x => x.Width).ToList();

            content.Append("\"adaptiveView\":[");
            foreach (IAdaptiveView view in orderedViewList)
            {
                JsAdaptiveView jsAdaptiveView = new JsAdaptiveView(_service, view);
                content.Append(jsAdaptiveView.ToString());
                content.Append(",");
            }
            JsHelper.RemoveLastComma(content);
            content.Append("],");

            // widgets
            content.Append("\"widgets\":[");
            foreach (IWidget widget in _page.Widgets)
            {
                JsWidget jsWidget = JsWidgetFactory.CreateJsWidget(_service, widget, _byMD5);
                content.Append(jsWidget.ToString());
                content.Append(",");
            }
            JsHelper.RemoveLastComma(content);
            content.Append("],");

            // masters
            content.Append("\"masters\":[");
            foreach (IMaster master in _page.Masters)
            {
                JsMaster jsMaster = new JsMaster(_service, master, _byMD5);
                content.Append(jsMaster.ToString());
                content.Append(",");
            }
            JsHelper.RemoveLastComma(content);
            content.Append("],");

            // groups
            content.Append("\"groups\":[");
            foreach (IGroup group in _page.Groups)
            {
                JsGroup jsGroup = new JsGroup(_service, group);
                content.Append(jsGroup.ToString());
                content.Append(",");
            }
            JsHelper.RemoveLastComma(content);
            content.Append("]");

            content.Append("};");

            string sz = content.ToString();;

            return(content.ToString());
        }