Exemple #1
0
        public override string ToString()
        {
            StringBuilder content = new StringBuilder();

            content.Append("var htDocumentData={");

            // Document file version which format is x.x.x.x, see VersionHistory.txt in details.
            content.AppendFormat("\"fileVersion\":\"{0}\",", _service.RenderingDocument.FileVersion);

            JsSitemap site = new JsSitemap(_service);

            content.Append(site.ToString());

            content.Append(",");

            JsViewport view     = new JsViewport(_service);
            string     viewport = view.ToString();

            if (!String.IsNullOrEmpty(viewport))
            {
                content.Append(viewport);
                content.Append(",");
            }

            content.AppendFormat("\"protoNowVer\":\"{0}\",", _service.ProductVersionInfo);

            JsHelper.RemoveLastComma(content);

            content.Append("};");

            return(content.ToString());
        }
Exemple #2
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("\"notes\":{");

            foreach (IAnnotationField field in _service.RenderingDocument.WidgetAnnotationFieldSet.AnnotationFields)
            {
                string text = _widget.Annotation.GetextValue(field.Name);
                if (String.IsNullOrEmpty(text))
                {
                    continue;
                }

                text = JsHelper.ReplaceSpecialCharacters(text);
                text = JsHelper.ReplaceNewLineWithBRTag(text);

                builder.AppendFormat("\"{0}\":\"{1}\",", field.Name, text);
            }

            JsHelper.RemoveLastComma(builder);

            builder.Append("}");

            return(builder.ToString());
        }
Exemple #3
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("\"" + GetJsEventName(_event.Name) + "\":[ ");

            //foreach (IInteractionCase iCase in _event.Cases)
            //{
            //    JsCase jsCase = new JsCase(_service, iCase);
            //    builder.Append(jsCase.ToString());
            //    builder.Append(@",");
            //}

            // Note: currently, we only support one case, uncomments above codes when we support multiple case.
            foreach (IInteractionCase iCase in _event.Cases)
            {
                foreach (IInteractionAction action in iCase.Actions)
                {
                    JsAction jsAction     = new JsAction(_service, action);
                    string   actionString = jsAction.ToString();
                    if (String.IsNullOrEmpty(actionString) == false)
                    {
                        builder.Append(actionString);
                        builder.Append(",");
                    }
                }
            }

            JsHelper.RemoveLastComma(builder);

            builder.Append("]");

            return(builder.ToString());
        }
Exemple #4
0
        protected override void AppendSpecificTypeProperties(StringBuilder builder)
        {
            string text = JsHelper.ReplaceSpecialCharacters(_widget.Text);

            text = JsHelper.ReplaceNewLineWithBRTag(text);
            builder.AppendFormat("\"text\":\"{0}\",", text);
        }
Exemple #5
0
        protected override void AppendSpecificTypeProperties(StringBuilder builder)
        {
            base.AppendSpecificTypeProperties(builder);

            ITextBase textBase = _widget as ITextBase;

            builder.AppendFormat("\"hintText\":\"{0}\",", JsHelper.ReplaceSpecialCharacters(textBase.HintText));
            builder.AppendFormat("\"hideBorder\":{0},", textBase.HideBorder.ToString().ToLower());
            builder.AppendFormat("\"readOnly\":{0},", textBase.ReadOnly.ToString().ToLower());

            if (textBase.MaxLength >= 0)
            {
                builder.AppendFormat("\"maxLength\":{0},", textBase.MaxLength);
            }
            else
            {
                // Negative value means unlimited.
                builder.AppendFormat("\"maxLength\": ,");
            }

            if (_widget.WidgetType == WidgetType.TextField)
            {
                ITextField textField = _widget as ITextField;
                builder.AppendFormat("\"textFieldType\":\"{0}\",", textField.TextFieldType.ToString().ToLower());
            }
        }
Exemple #6
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("\"pageNotes\":");

            string text = "";

            foreach (IAnnotationField field in _service.RenderingDocument.PageAnnotationFieldSet.AnnotationFields)
            {
                text += _page.Annotation.GetextValue(field.Name);
                if (String.IsNullOrEmpty(text))
                {
                    continue;
                }
                text += Environment.NewLine;
            }

            //remove last NewLine by viewer's request
            if (text.EndsWith(Environment.NewLine))
            {
                text = text.Remove(text.LastIndexOf(Environment.NewLine), Environment.NewLine.Count());
            }

            text = JsHelper.ReplaceSpecialCharacters(text);
            text = JsHelper.ReplaceNewLineWithBRTag(text);

            builder.AppendFormat("\"{0}\"", text);

            return(builder.ToString());
        }
Exemple #7
0
        protected override void AppendSpecificTypeProperties(StringBuilder builder)
        {
            if (_widget.WidgetType == WidgetType.ListBox)
            {
                IListBox listBox = _widget as IListBox;
                builder.AppendFormat("\"allowMultiple\":{0},", listBox.AllowMultiple.ToString().ToLower());
            }

            IListBase listBase = _widget as IListBase;

            builder.Append("\"items\":[");

            foreach (IListItem item in listBase.Items)
            {
                builder.Append("{");

                builder.AppendFormat("\"textValue\":\"{0}\",", JsHelper.ReplaceSpecialCharacters(item.TextValue));
                builder.AppendFormat("\"isSelected\":{0},", item.IsSelected.ToString().ToLower());

                builder.Append("},");
            }

            JsHelper.RemoveLastComma(builder);

            builder.Append("],");
        }
Exemple #8
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("],");
        }
Exemple #9
0
        public override string ToString()
        {
            StringBuilder content = new StringBuilder();

            content.Append(@"var PNComparingData={""projects"":[");

            for (int i = 0; i < _documents.Count; i++)
            {
                //head
                content.Append(@"{");

                _service.RenderingDocument = _documents[i];
                content.AppendFormat("\"id\":\"{0}\",", i);
                content.AppendFormat("\"name\":\"{0}\",", Path.GetFileNameWithoutExtension(_service.RenderingDocument.Name));
                if (_service.RenderingDocument.TimeStamp.StartsWith("2000-01-01"))
                {
                    content.AppendFormat("\"timestamp\":\"\",");
                }
                else
                {
                    content.AppendFormat("\"timestamp\":\"{0}\",", _service.RenderingDocument.TimeStamp);
                }

                content.AppendFormat("\"fileVersion\":\"{0}\",", _service.RenderingDocument.FileVersion);

                JsSitemap site = new JsSitemap(_service);
                content.Append(site.ToString());
                content.Append(",");

                JsViewport view     = new JsViewport(_service);
                string     viewport = view.ToString();
                if (!String.IsNullOrEmpty(viewport))
                {
                    content.Append(viewport);
                    content.Append(",");
                }

                content.AppendFormat("\"protoNowVer\":\"{0}\",", _service.ProductVersionInfo);
                JsHelper.RemoveLastComma(content);

                //tail
                if (i < _documents.Count - 1)
                {
                    content.Append(@"},");
                }
                else
                {
                    content.Append(@"}");
                }
            }


            content.Append(@"]};");
            return(content.ToString());
        }
Exemple #10
0
        public override string ToString()
        {
            //this is just for debug test, delete it later
            if (_master.ParentPage is IDocumentPage)
            {
                // System.Diagnostics.Debug.WriteLine("====Master md5:" + _master.MD5 + "  ===========================");
            }


            StringBuilder builder = new StringBuilder();

            builder.Append("{");

            builder.AppendFormat("\"id\":\"{0}\",", _master.Guid.ToString());
            if (IsSetMD5 == true)
            {
                builder.AppendFormat("\"MD5\":\"{0}\",", _master.MD5);
            }

            builder.AppendFormat("\"masterPageID\":\"{0}\",", _master.MasterPageGuid.ToString());

            if (_master.ParentGroup != null)
            {
                builder.AppendFormat("\"parentGroupID\":\"{0}\",", _master.ParentGroup.Guid.ToString());
            }

            builder.Append("\"style\":");
            IPageView     basePageView = _master.ParentPage.PageViews[_master.ParentDocument.AdaptiveViewSet.Base.Guid];
            JsMasterStyle masterStyle  = new JsMasterStyle(_master, _master.MasterStyle, basePageView, IsSetMD5, _master.ParentDocument.AdaptiveViewSet.Base.Guid);

            builder.Append(masterStyle.ToString());
            builder.Append(",");

            builder.Append("\"adaptiveViewStyles\":[");
            foreach (IAdaptiveView view in _master.ParentDocument.AdaptiveViewSet.AdaptiveViews)
            {
                IMasterStyle masterViewStyle = _master.GetMasterStyle(view.Guid);
                IPageView    pageView        = _master.ParentPage.PageViews[view.Guid];
                if (masterViewStyle != null && pageView != null)
                {
                    masterStyle = new JsMasterStyle(_master, masterViewStyle, pageView, IsSetMD5, view.Guid);
                    builder.Append(masterStyle.ToString());
                    builder.Append(",");
                }
            }

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

            builder.Append("}");

            return(builder.ToString());
        }
Exemple #11
0
        public override void AppendSpecificTypeStyle(StringBuilder builder, IWidgetStyle widgetStyle)
        {
            base.AppendSpecificTypeStyle(builder, widgetStyle);

            ITextBase textBase = widgetStyle.OwnerWidget as ITextBase;

            if (textBase.HideBorder)
            {
                builder.Append("\"border-color\":\"transparent\",");
            }

            builder.AppendFormat("\"background-color\":\"{0}\",", JsHelper.GetRGBAColor(widgetStyle.FillColor));
        }
Exemple #12
0
        protected override void AppendSpecificTypeProperties(StringBuilder builder)
        {
            base.AppendSpecificTypeProperties(builder);

            ISelectionButton select = _widget as ISelectionButton;

            builder.AppendFormat("\"isSelected\":{0},", select.IsSelected.ToString().ToLower());
            builder.AppendFormat("\"alignButton\":\"{0}\",", select.AlignButton.ToString().ToLower());

            if (_widget.WidgetType == WidgetType.RadioButton)
            {
                IRadioButton radio = _widget as IRadioButton;
                builder.AppendFormat("\"radioGroup\":\"{0}\",", JsHelper.ReplaceSpecialCharacters(radio.RadioGroup));
            }
        }
Exemple #13
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("\"sitemap\":{");

            Guid startPageGuid = _service.RenderingDocument.GeneratorConfigurationSet.DefaultHtmlConfiguration.StartPage;

            if (startPageGuid != Guid.Empty)
            {
                builder.AppendFormat("\"startPage\": \"{0}\",", startPageGuid.ToString());
            }

            builder.Append("\"rootNodes\":[");

            Guid currentPageGuid = _service.RenderingDocument.GeneratorConfigurationSet.DefaultHtmlConfiguration.CurrentPage;

            if (currentPageGuid != Guid.Empty)
            {
                // Only generate current page
                IPage currentPage = _service.RenderingDocument.Pages[currentPageGuid];
                if (currentPage != null)
                {
                    builder.Append("{");
                    builder.AppendFormat("\"pageName\":\"{0}\",", JsHelper.EscapeDoubleQuote(currentPage.Name));
                    builder.Append("\"type\":\"Page\",");
                    builder.AppendFormat("\"url\":\"{0}\"", currentPage.Guid.ToString());
                    builder.Append("}");
                }
            }
            else
            {
                // Generate first level nodes
                foreach (ITreeNode node in _service.RenderingDocument.DocumentSettings.LayoutSetting.PageTree.ChildNodes)
                {
                    JsNode jsNode = new JsNode(_service, node);
                    builder.Append(jsNode.ToString());
                }
            }

            JsHelper.RemoveLastComma(builder);

            builder.Append("]");
            builder.Append("}");

            return(builder.ToString());
        }
Exemple #14
0
        public static void AppendBorderStyle(StringBuilder builder, IWidgetStyle widgetStyle)
        {
            // There is no border
            if (widgetStyle.LineWidth < 1)
            {
                return;
            }

            builder.AppendFormat("\"width\":\"{0}px\",", Math.Round(widgetStyle.LineWidth));

            switch (widgetStyle.LineStyle)
            {
            case LineStyle.Solid:
            {
                builder.Append("\"type\":\"1\",");
                break;
            }

            case LineStyle.Dot:
            {
                builder.Append("\"type\":\"2\",");
                break;
            }

            case LineStyle.DashDot:
            {
                builder.Append("\"type\":\"3\",");
                break;
            }

            case LineStyle.DashDotDot:
            {
                builder.Append("\"type\":\"4\",");
                break;
            }

            default:
            {
                builder.Append("\"type\":\"0\",");
                break;
            }
            }

            builder.AppendFormat("\"color\":\"{0}\",", JsHelper.GetRGBAColor(widgetStyle.LineColor));
        }
Exemple #15
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("\"actions\":{");

            foreach (IInteractionEvent iEvent in _events)
            {
                JsEvent jsEvent = new JsEvent(_service, iEvent);
                builder.Append(jsEvent.ToString());
                builder.Append(",");
            }

            JsHelper.RemoveLastComma(builder);

            builder.Append("}");

            return(builder.ToString());
        }
Exemple #16
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());
        }
Exemple #17
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(",");
        }
Exemple #18
0
        public override string ToString()
        {
            IViewport viewport = _service.RenderingDocument.GeneratorConfigurationSet.DefaultHtmlConfiguration.Viewport;

            // Do not generate viewport if width is less than 0.
            if (viewport.IncludeViewportTag == false || viewport.Width <= 0)
            {
                return("");
            }

            // Build adaptive view which width has value.
            StringBuilder builder = new StringBuilder();

            builder.Append("\"mobileViewport\":{");

            builder.AppendFormat("\"name\":\"{0}\",", JsHelper.ReplaceSpecialCharacters(viewport.Name));
            builder.AppendFormat("\"width\":{0},", viewport.Width);
            builder.AppendFormat("\"height\":{0}", viewport.Height);

            builder.Append("}");

            return(builder.ToString());
        }
Exemple #19
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");
            builder.AppendFormat("\"id\":\"{0}\",", _view.Guid);
            builder.AppendFormat("\"name\":\"{0}\",", JsHelper.ReplaceSpecialCharacters(_view.Name));
            builder.AppendFormat("\"width\":{0},", _view.Width);

            if (_view.Condition == AdaptiveViewCondition.LessOrEqual)
            {
                builder.AppendFormat("\"condition\":\"lessThan\",");
            }
            else
            {
                builder.AppendFormat("\"condition\":\"greaterThan\",");
            }
            builder.AppendFormat("\"className\":\"adaptive_{0}\"", _view.Guid);

            builder.Append("}");

            return(builder.ToString());
        }
Exemple #20
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");
            builder.AppendFormat("\"pageName\":\"{0}\",", JsHelper.EscapeDoubleQuote(_node.Name));

            if (_node.NodeType == TreeNodeType.Folder)
            {
                builder.Append("\"type\":\"Folder\"");
            }
            else
            {
                builder.Append("\"type\":\"Page\",");
                builder.AppendFormat("\"url\":\"{0}\"", _node.Guid.ToString());
            }

            if (_node.ChildNodesCount > 0)
            {
                builder.Append(",");
                builder.Append("\"children\":[");

                foreach (ITreeNode node in _node.ChildNodes)
                {
                    JsNode jsNode = new JsNode(_service, node);
                    builder.Append(jsNode.ToString());
                }

                JsHelper.RemoveLastComma(builder);

                builder.Append("]");
            }

            builder.Append("},");

            return(builder.ToString());
        }
Exemple #21
0
        public static void AppendFillStyle(StringBuilder builder, IWidgetStyle widgetStyle)
        {
            switch (widgetStyle.FillColor.FillType)
            {
            case ColorFillType.Solid:
            {
                builder.Append("\"type\":\"solid\",");
                builder.AppendFormat("\"color\":\"{0}\",", GetRGBAColor(widgetStyle.FillColor));
                break;
            }

            case ColorFillType.Gradient:
            {
                builder.Append("\"type\":\"linearGradient\",");
                builder.AppendFormat("\"gradientRotate\":\"{0}\",", Math.Round(widgetStyle.FillColor.Angle));

                builder.Append("\"gradientColors\": [");
                foreach (KeyValuePair <double, int> frame in widgetStyle.FillColor.Frames.OrderBy(x => x.Key))
                {
                    builder.Append("{");
                    builder.AppendFormat("\"offset\":\"{0}%\",", Math.Round(frame.Key * 100));
                    builder.AppendFormat("\"color\":\"{0}\"", GetRGBAColor(frame.Value));
                    builder.Append("},");
                }
                JsHelper.RemoveLastComma(builder);
                builder.Append("],");

                break;
            }

            default:
            {
                return;
            }
            }
        }
Exemple #22
0
        public override void AppendSpecificTypeStyle(StringBuilder builder, IWidgetStyle widgetStyle)
        {
            // Shape style only works when we export to a svg file.
            if (_service.RenderingDocument.GeneratorConfigurationSet.DefaultHtmlConfiguration.ExportType == ExportType.Data)
            {
                base.AppendSpecificTypeStyle(builder, widgetStyle);

                builder.Append("\"fill\": {");
                JsHelper.AppendFillStyle(builder, widgetStyle);
                JsHelper.RemoveLastComma(builder);
                builder.Append("},");

                builder.Append("\"stroke\": {");
                JsHelper.AppendBorderStyle(builder, widgetStyle);
                JsHelper.RemoveLastComma(builder);
                builder.Append("},");

                builder.AppendFormat("\"border-radius\":{0},", widgetStyle.CornerRadius);
            }
            else
            {
                // Set the image file hash value for styles
                string hash = _service.ImagesStreamManager.GetConsumerStreamHash(_widget.Guid, widgetStyle.ViewGuid);
                if (String.IsNullOrEmpty(hash) &&
                    widgetStyle.ViewGuid == _widget.ParentDocument.AdaptiveViewSet.Base.Guid)
                {
                    // If not find and it is base view, try to load again with empty view guid.
                    hash = _service.ImagesStreamManager.GetConsumerStreamHash(_widget.Guid, Guid.Empty);
                }

                if (!String.IsNullOrEmpty(hash))
                {
                    builder.AppendFormat("\"hash\":\"{0}\",", hash);
                }
            }
        }
Exemple #23
0
        public override void AppendSpecificTypeStyle(StringBuilder builder, IWidgetStyle widgetStyle)
        {
            base.AppendSpecificTypeStyle(builder, widgetStyle);

            builder.AppendFormat("\"background-color\":\"{0}\",", JsHelper.GetRGBAColor(widgetStyle.FillColor));
        }
Exemple #24
0
 public override void AppendSpecificTypeStyle(StringBuilder builder, IWidgetStyle widgetStyle)
 {
     JsHelper.AppendFontStyle(builder, widgetStyle);
     JsHelper.AppendSimpleTextStyle(builder, widgetStyle);
 }
Exemple #25
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            switch (_action.ActionType)
            {
            case ActionType.OpenAction:
            {
                IInteractionOpenAction openAction = _action as IInteractionOpenAction;
                if (openAction == null || openAction.LinkType == LinkType.None)
                {
                    return("");
                }

                builder.Append("{");
                builder.AppendFormat("\"action\":\"{0}\",", GetJsAction(_action.ActionType));

                if (openAction.LinkType == LinkType.LinkToPage)
                {
                    // http://bts1.navercorp.com/nhnbts/browse/DSTUDIO-2061
                    // If action is "Link to a page", I will always set "target" to  "openCurrentWindow" in js action.
                    builder.AppendFormat("\"target\":\"{0}\",", GetJsTarget(ActionOpenIn.CurrentWindow));

                    if (_service.RenderingDocument.Pages.Contains(openAction.LinkPageGuid))
                    {
                        builder.AppendFormat("\"url\":\"{0}\",", openAction.LinkPageGuid.ToString());
                    }
                }
                else if (openAction.LinkType == LinkType.LinkToUrl)
                {
                    builder.AppendFormat("\"target\":\"{0}\",", GetJsTarget(openAction.OpenIn));

                    if (!String.IsNullOrEmpty(openAction.ExternalUrl))
                    {
                        // Add http so that browser could know this is a external url
                        string url = openAction.ExternalUrl;
                        if (!url.StartsWith(@"http://"))
                        {
                            url = @"http://" + url;
                        }
                        builder.AppendFormat("\"url\":\"{0}\",", url);
                    }
                }

                JsHelper.RemoveLastComma(builder);
                builder.Append("}");
                break;
            }

            case ActionType.ShowHideAction:
            {
                IInteractionShowHideAction showHideAction = _action as IInteractionShowHideAction;
                if (showHideAction == null || showHideAction.TargetObjects.Count <= 0)
                {
                    return("");
                }

                // If all target objects VisibilityType is none, we don't issue action as well
                IShowHideActionTarget firstTarget = showHideAction.TargetObjects.FirstOrDefault <IShowHideActionTarget>(x => x.VisibilityType != VisibilityType.None);
                if (firstTarget == null)
                {
                    return("");
                }

                builder.Append("{");

                builder.AppendFormat("\"action\":\"{0}\",", GetJsAction(_action.ActionType));

                builder.Append("\"objectList\":[");
                foreach (IShowHideActionTarget target in showHideAction.TargetObjects)
                {
                    builder.Append("{");

                    builder.AppendFormat("\"id\":\"{0}\",", target.Guid.ToString());
                    builder.AppendFormat("\"type\":\"{0}\",", target.VisibilityType.ToString());
                    builder.AppendFormat("\"animateType\":\"{0}\",", target.AnimateType.ToString());
                    builder.AppendFormat("\"animateTime\":{0},", target.AnimateTime);

                    builder.Append("},");
                }

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

                builder.Append("}");
                break;
            }

            default:
                return("");
            }

            return(builder.ToString());
        }
Exemple #26
0
        protected override void AppendSpecificTypeProperties(StringBuilder builder)
        {
            // Following uncommented codes are not supported in current HTML export.
            IDynamicPanel panel = _widget as IDynamicPanel;

            //builder.AppendFormat("\"bUseCircular\":{0},", panel.IsCircular.ToString().ToLower());
            builder.AppendFormat("\"bAutomatic\":{0},", panel.IsAutomatic.ToString().ToLower());
            builder.AppendFormat("\"automaticIntervalTime\":{0},", panel.AutomaticIntervalTime.ToString());
            builder.AppendFormat("\"durationTime\":{0},", panel.DurationTime.ToString());
            //builder.AppendFormat("\"navigationType\":\"{0}\",", panel.NavigationType.ToString());
            if (panel.NavigationType == NavigationType.Dot)
            {
                builder.AppendFormat("\"bUseNavigation\":true,");
            }
            else
            {
                builder.AppendFormat("\"bUseNavigation\":false,");
            }
            //builder.AppendFormat("\"bShowAffordanceArrow\":{0},", panel.ShowAffordanceArrow.ToString().ToLower());

            // Confirmed with Eunyoung, if it is full mode. the value is "100%": "panelWidth" : "100%".
            // And if it is other mode and user set panel width as 80%, the value is "80%" : "panelWidth" : "80%".
            // Must append "%" after the value in js.
            builder.AppendFormat("\"viewMode\":\"{0}\",", panel.ViewMode.ToString());
            switch (panel.ViewMode)
            {
            case DynamicPanelViewMode.Card:
            case DynamicPanelViewMode.Preview:
            case DynamicPanelViewMode.Scroll:
                builder.AppendFormat("\"panelWidth\":\"{0}%\",", panel.PanelWidth);
                builder.AppendFormat("\"panelSpacing\":\"{0}px\",", panel.LineWith);
                break;

            default:     //Default is Full mode
                builder.AppendFormat("\"panelWidth\":\"100%\",");
                builder.AppendFormat("\"panelSpacing\":\"0px\",");
                break;
            }

            builder.AppendFormat("\"panelCount\":{0},", panel.PanelStatePages.Count.ToString());
            //int startPage = panel.PanelStatePages.IndexOf(panel.StartPanelStatePage);
            //startPage += 1; // startPage index is 1 based.
            //builder.AppendFormat("\"startPage\":" + startPage + ",");



            if (IsSetMD5 == true)
            {
                string conttenMd5 = string.Empty;
                foreach (IPanelStatePage page in panel.PanelStatePages)
                {
                    conttenMd5 += page.MD5 + ",";
                }
                conttenMd5.TrimEnd(new char[] { ',' });
                builder.AppendFormat("\"Content\":\"{0}\",", conttenMd5);
            }


            builder.Append("\"panelWidgets\":[");
            foreach (IPanelStatePage page in panel.PanelStatePages)
            {
                bool isClosedPage = false;
                if (!page.IsOpened)
                {
                    isClosedPage = true;
                    page.Open();
                }

                JsDynamicPanelState jsState = new JsDynamicPanelState(_service, page, IsSetMD5);
                builder.Append(jsState.ToString());
                builder.Append(",");

                if (isClosedPage)
                {
                    page.Close();
                }
            }

            JsHelper.RemoveLastComma(builder);
            builder.Append("],");
        }
Exemple #27
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");

            if (_adaptiveView != _group.ParentDocument.AdaptiveViewSet.Base)
            {
                builder.AppendFormat("\"adaptiveViewID\":\"{0}\",", _adaptiveView.Guid);
            }

            IRegionStyle groupStyle = _group.GetRegionStyle(_adaptiveView.Guid);

            if (groupStyle != null)
            {
                builder.AppendFormat("\"width\":\"{0}px\",", Math.Round(groupStyle.Width));
                builder.AppendFormat("\"height\":\"{0}px\",", Math.Round(groupStyle.Height));
            }

            // If this is top group, generate absolute location value.
            if (_group.ParentGroup == null)
            {
                builder.AppendFormat("\"top\":\"{0}px\",", Math.Round(groupStyle.Y));
                builder.AppendFormat("\"left\":\"{0}px\",", Math.Round(groupStyle.X));
            }
            else
            {
                // Child group, generate relative location value, relative to top level parent group.
                IGroup       topLevelParentGroup      = GetTopLevelParentGroup(_group);
                IRegionStyle topLevelParentGroupStyle = topLevelParentGroup.GetRegionStyle(_adaptiveView.Guid);

                builder.AppendFormat("\"top\":\"{0}px\",", Math.Round(groupStyle.Y - topLevelParentGroupStyle.Y));
                builder.AppendFormat("\"left\":\"{0}px\",", Math.Round(groupStyle.X - topLevelParentGroupStyle.X));
            }

            // In current design, Z-Order doesn't support adaptive view.
            //builder.AppendFormat("\"z-index\":{0},", groupStyle.Z);
            IRegionStyle groupBaseViewStyle = _group.RegionStyle;

            builder.AppendFormat("\"z-index\":{0},", groupBaseViewStyle.Z);

            // http://bts1.navercorp.com/nhnbts/browse/DSTUDIO-1357
            // The "display" of group is none only if all child widgets is hidden.
            string visibility = "block";

            if (HasVisibleChildWidget(_group, _adaptiveView, true) == false)
            {
                visibility = "none";
            }
            builder.AppendFormat("\"display\":\"{0}\",", visibility);

            string position = "absolute";

            if (HasUnfixedChildWidget(_group, _adaptiveView, true) == false)
            {
                position = "fixed";
            }
            builder.AppendFormat("\"position\":\"{0}\",", position);

            JsHelper.RemoveLastComma(builder);

            builder.Append("}");

            return(builder.ToString());
        }
Exemple #28
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");

            // Don't add adaptiveViewID if it is style in base.
            if (_pageView.Guid != _widgetStyle.OwnerWidget.ParentDocument.AdaptiveViewSet.Base.Guid)
            {
                builder.AppendFormat("\"adaptiveViewID\":\"{0}\",", _pageView.Guid);
            }
            if (IsSetMD5 == true)
            {
                builder.AppendFormat("\"MD5\":\"{0}\",", _widgetStyle.MD5);
            }
            builder.AppendFormat("\"width\":\"{0}px\",", Math.Round(_widgetStyle.Width));
            builder.AppendFormat("\"height\":\"{0}px\",", Math.Round(_widgetStyle.Height));

            IToast toast = _widgetStyle.OwnerWidget as IToast;

            if (toast != null && toast.DisplayPosition == ToastDisplayPosition.Top)
            {
                builder.AppendFormat("\"top\":\"0px\",");
            }
            else
            {
                builder.AppendFormat("\"top\":\"{0}px\",", Math.Round(_widgetStyle.Y));
            }

            builder.AppendFormat("\"left\":\"{0}px\",", Math.Round(_widgetStyle.X));
            builder.AppendFormat("\"rotate\":\"{0}deg\",", Math.Round(_widgetStyle.WidgetRotate));
            builder.AppendFormat("\"textrot\":\"{0}deg\",", Math.Round(_widgetStyle.TextRotate));

            //  In CSS(style) opacity, not use %. From 0.0 (fully transparent) to 1.0 (fully opaque)
            double opacity = _widgetStyle.Opacity;

            builder.AppendFormat("\"opacity\":{0},", opacity / 100);

            if (_widgetStyle.IsFixed)
            {
                builder.AppendFormat("\"position\":\"fixed\",");
            }
            else
            {
                if (toast != null && toast.DisplayPosition != ToastDisplayPosition.UserSetting)
                {
                    builder.AppendFormat("\"position\":\"fixed\",");
                }
                else
                {
                    builder.AppendFormat("\"position\":\"absolute\",");
                }
            }

            // isPlaced flag
            bool isPlaced = true;

            if (_pageView != null)
            {
                if (!_pageView.Widgets.Contains(_widgetStyle.OwnerWidget.Guid))
                {
                    isPlaced = false;
                }
            }
            else
            {
                // Check base vew
                Guid      baseViewGuid = _widgetStyle.OwnerWidget.ParentPage.ParentDocument.AdaptiveViewSet.Base.Guid;
                IPageView baseView     = _widgetStyle.OwnerWidget.ParentPage.PageViews[baseViewGuid];
                if (baseView != null && !baseView.Widgets.Contains(_widgetStyle.OwnerWidget.Guid))
                {
                    isPlaced = false;
                }
            }
            builder.AppendFormat("\"isPlaced\":{0},", isPlaced.ToString().ToLower());

            // CSS value : visible is "block" and hidden is "none".
            string visibility = "block";

            if (!_widgetStyle.IsVisible)
            {
                visibility = "none";
            }
            else
            {
                // If widget is not placed in this view, set to be hidden.
                if (!isPlaced)
                {
                    visibility = "none";
                }

                // The menu of hamburger are always invisible as it will show once button is clicked.
                if (_widgetStyle.OwnerWidget is IHamburgerMenu)
                {
                    visibility = "none";
                }
            }

            builder.AppendFormat("\"display\":\"{0}\",", visibility);

            // In current design, Z-Order doesn't support adaptive view.
            // All hamburger menu's z-index value is starting from 200000. menu button's z-index value is starting with 100000
            // because this menu should be on top.
            if (_widgetStyle.OwnerWidget is IHamburgerMenuButton)
            {
                builder.AppendFormat("\"z-index\":{0},", (_widgetStyle.OwnerWidget.WidgetStyle.Z + 100000));
            }
            else if (_widgetStyle.OwnerWidget is IHamburgerMenu)
            {
                builder.AppendFormat("\"z-index\":{0},", (_widgetStyle.OwnerWidget.WidgetStyle.Z + 200000));
            }
            else
            {
                builder.AppendFormat("\"z-index\":{0},", _widgetStyle.OwnerWidget.WidgetStyle.Z);
            }

            // Only following types have hand cursor when they have actions
            AppendActionCursor(builder);

            _parentJsWidget.AppendSpecificTypeStyle(builder, _widgetStyle);

            JsHelper.RemoveLastComma(builder);

            builder.Append("}");

            return(builder.ToString());
        }
Exemple #29
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");

            builder.AppendFormat("\"id\":\"{0}\",", _widget.Guid.ToString());
            if (IsSetMD5 == true)
            {
                builder.AppendFormat("\"MD5\":\"{0}\",", _widget.MD5);
            }

            // They js use "Flicking" if widget is DynamicPanel
            if (_widget.WidgetType == WidgetType.DynamicPanel)
            {
                builder.Append("\"type\":\"Flicking\",");
            }
            else
            {
                builder.AppendFormat("\"type\":\"{0}\",", _widget.WidgetType.ToString());
            }

            string name = JsHelper.ReplaceSpecialCharacters(_widget.Name);

            name = JsHelper.ReplaceNewLineWithBRTag(name);
            builder.AppendFormat("\"name\":\"{0}\",", name);

            string toolTip = JsHelper.ReplaceSpecialCharacters(_widget.Tooltip);

            toolTip = JsHelper.ReplaceNewLineWithBRTag(toolTip);
            builder.AppendFormat("\"toolTip\":\"{0}\",", toolTip);

            builder.AppendFormat("\"isDisabled\":{0},", _widget.IsDisabled.ToString().ToLower());

            AppendSpecificTypeProperties(builder);

            if (_widget.Annotation.IsEmpty == false)
            {
                JsWidgetNotes notes = new JsWidgetNotes(_service, _widget);
                builder.Append(notes.ToString());

                builder.Append(",");
            }

            builder.Append("\"style\":");
            IPageView     basePageView  = _widget.ParentPage.PageViews[_widget.ParentPage.ParentDocument.AdaptiveViewSet.Base.Guid];
            JsWidgetStyle jsWidgetStyle = new JsWidgetStyle(this, _widget.WidgetStyle, basePageView, IsSetMD5);

            builder.Append(jsWidgetStyle.ToString());
            builder.Append(",");

            //this is just for debug test, delete it later
            //string szhash =MD5HashManager.GetHash(_widget,true);
            if (_widget.ParentPage is IDocumentPage)
            {
                // System.Diagnostics.Debug.WriteLine("====widget md5:" + _widget.MD5 + "  ===========================");
            }

            builder.Append("\"adaptiveViewStyles\":[");
            foreach (IAdaptiveView view in _widget.ParentPage.ParentDocument.AdaptiveViewSet.AdaptiveViews)
            {
                IWidgetStyle widgetViewStyle = _widget.GetWidgetStyle(view.Guid);
                IPageView    pageView        = _widget.ParentPage.PageViews[view.Guid];
                if (widgetViewStyle != null && pageView != null)
                {
                    JsWidgetStyle jsWidgetViewStyle = new JsWidgetStyle(this, widgetViewStyle, pageView, IsSetMD5);
                    builder.Append(jsWidgetViewStyle.ToString());
                    builder.Append(",");
                }
            }
            JsHelper.RemoveLastComma(builder);
            builder.Append("],");

            JsEvents events = new JsEvents(_service, _widget.Events);

            builder.Append(events.ToString());

            JsHelper.RemoveLastComma(builder);

            builder.Append("}");

            return(builder.ToString());
        }
Exemple #30
0
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("{");

            if (_pageView.Guid != _master.ParentDocument.AdaptiveViewSet.Base.Guid)
            {
                builder.AppendFormat("\"adaptiveViewID\":\"{0}\",", _pageView.Guid);
            }
            if (IsSetMD5 == true)
            {
                builder.AppendFormat("\"MD5\":\"{0}\",", _masterStyle.MD5);
            }
            builder.AppendFormat("\"width\":\"{0}px\",", Math.Round(_masterStyle.Width));
            builder.AppendFormat("\"height\":\"{0}px\",", Math.Round(_masterStyle.Height));

            builder.AppendFormat("\"top\":\"{0}px\",", Math.Round(_masterStyle.Y));
            builder.AppendFormat("\"left\":\"{0}px\",", Math.Round(_masterStyle.X));


            builder.AppendFormat("\"offsetY\":\"{0}px\",", Math.Round(_childPageView.RegionStyle.Y));
            builder.AppendFormat("\"offsetX\":\"{0}px\",", Math.Round(_childPageView.RegionStyle.X));

            // In current design, Z-Order doesn't support adaptive view.
            builder.AppendFormat("\"z-index\":{0},", _master.MasterStyle.Z);

            if (_masterStyle.IsFixed)
            {
                builder.AppendFormat("\"position\":\"fixed\",");
            }
            else
            {
                builder.AppendFormat("\"position\":\"absolute\",");
            }

            // isPlaced flag
            bool isPlaced = true;

            if (_pageView != null)
            {
                if (!_pageView.Masters.Contains(_master.Guid))
                {
                    isPlaced = false;
                }
            }
            else
            {
                // Check base vew
                Guid      baseViewGuid = _master.ParentDocument.AdaptiveViewSet.Base.Guid;
                IPageView baseView     = _master.ParentPage.PageViews[baseViewGuid];
                if (baseView != null && !baseView.Masters.Contains(_master.Guid))
                {
                    isPlaced = false;
                }
            }
            builder.AppendFormat("\"isPlaced\":{0},", isPlaced.ToString().ToLower());

            string visibility = "block";

            if (!_masterStyle.IsVisible)
            {
                visibility = "none";
            }
            builder.AppendFormat("\"display\":\"{0}\",", visibility);

            JsHelper.RemoveLastComma(builder);

            builder.Append("}");

            return(builder.ToString());
        }