예제 #1
0
 public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
 {
     sbHtml.AppendFormat("<div style='position:absolute;{0};{1}'>\n", Area.HtmlLTRB(), Font.HtmlString());
     AnalyzeContents();
     FindFirstEmptyCell();
     if (p_xmax >= 1 || p_ymax >= 1)
     {
         float width  = 100 / p_xmax;
         float height = 100 / p_ymax;
         for (int y = 0; y < p_ymax; y++)
         {
             sbHtml.AppendFormat("  <div style='display:flex;flex-direction:row;height:{0}%;'>\n", height);
             for (int x = 0; x < p_xmax; x++)
             {
                 string eid = string.Format("tp{0}_{1}", x, y);
                 if (p_array[x, y, 1].Length == 0)
                 {
                     sbHtml.AppendFormat("    <div id=\"{1}\" style='width:{0}%;height:100%;border:1px solid white;margin:0px;'></div>\n", width, eid);
                 }
                 else
                 {
                     sbHtml.AppendFormat("    <div id=\"{1}\" style='width:{0}%;height:100%;border:1px solid black;margin:0px;display:flex;flex-direction:column;justify-content:center;' data-tag=\"{2}\">\n", width, eid, p_array[x, y, 1]);
                     sbHtml.AppendFormat("      <div style='{1};text-align:center;'>{0}</div>\n", p_array[x, y, 0], Font.HtmlString());
                     sbHtml.AppendFormat("    </div>\n");
                 }
             }
             sbHtml.AppendFormat("  </div>\n");
         }
     }
     sbHtml.Append("</div>\n");
 }
예제 #2
0
        public void ExportToHtml(MNExportContext ctx, string fileWoExt)
        {
            ctx.UsedControls.Clear();
            if (ctx.Files >= ctx.MaxFiles)
            {
                return;
            }
            ctx.DirCurrentBook = Path.Combine(ctx.DirAllBooks, fileWoExt);
            Directory.CreateDirectory(ctx.DirCurrentBook);
            string dirImages = Path.Combine(ctx.DirCurrentBook, "img");

            Directory.CreateDirectory(dirImages);

            for (int i = 0; i < Data.Pages.Count; i++)
            {
                ctx.Clear();
                ctx.CurrentPage     = Data.Pages[i];
                ctx.FileCurrentPage = Path.Combine(ctx.DirCurrentBook, ctx.CurrentPage.PageNameHtml());
                ctx.CurrentPage.ExportToHtml(ctx);
            }

            foreach (MNReferencedImage img in DefaultLanguage.Images)
            {
                string fileName = Path.Combine(dirImages, "image" + img.Id + ".png");
                if (!File.Exists(fileName))
                {
                    Bitmap bmp = new Bitmap(img.ImageData);
                    bmp.Save(fileName, ImageFormat.Png);
                }
            }
        }
예제 #3
0
 public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
 {
     sbHtml.Append("<div ");
     sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
     sbHtml.AppendFormat(" style ='position:absolute;z-index:{0};", zorder);
     sbHtml.Append(Area.HtmlLTRB());
     sbHtml.Append("'>");
     sbHtml.AppendFormat("<textarea style='width:100%;height:100%;font-family:{0};font-size:100%;background:lightyellow;border:1px solid black;'></textarea>",
                         Font.Name);
     //sbHtml.Append("<b>" + GetType().Name + "</b><br>" + this.Text);
     sbHtml.Append("</div>\n");
 }
예제 #4
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            sbHtml.Append("<div ");
            sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
            sbHtml.AppendFormat(" style ='overflow-y:auto;position:absolute;z-index:{0};", zorder);
            sbHtml.Append(Area.HtmlLTRB());
            sbHtml.Append(Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml());
            sbHtml.Append("'>");

            sbHtml.Append("<div style='display:flex;flex-direction:row;justify-content:center;flex-wrap:wrap;'>");
            SplitTextToWords(Text);
            foreach (SMTextContainerWord wb in drawWords)
            {
                sbHtml.AppendFormat("<div class=\"textContainerElem\" data-tag=\"{1}\">{0}</div>", wb.text, wb.tag);
            }
            sbHtml.Append("</div>");

            sbHtml.Append("</div>\n");
        }
예제 #5
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            if (p_alignedText.Length == 0 || !p_prevText.Equals(Text) || p_prevRowCol != Rows * Columns)
            {
                if (Rows < 3)
                {
                    Rows = 3;
                }
                if (Columns < 3)
                {
                    Columns = 3;
                }
                p_prevRowCol         = Rows * Columns;
                p_prevText           = Text;
                p_cellStatus         = new bool[Columns, Rows];
                p_cellExpectedStatus = new bool[Columns, Rows];
                p_alignedText        = AlignText(Text);
            }

            sbHtml.AppendFormat("<div style='position:absolute;{0};{1}'>\n", Area.HtmlLTRB(), Font.HtmlString());
            if (Columns >= 1 || Rows >= 1)
            {
                int   index  = 0;
                float width  = 100 / Columns;
                float height = 100 / Rows;
                for (int y = 0; y < Rows; y++)
                {
                    sbHtml.AppendFormat("  <div style='display:flex;flex-direction:row;height:{0}%;'>\n", height);
                    for (int x = 0; x < Columns; x++)
                    {
                        string s = p_alignedText.Substring(index, 1);
                        index++;
                        string eid = string.Format("tp{0}_{1}", x, y);

                        sbHtml.AppendFormat("    <div id=\"{1}\" style='width:{0}%;height:100%;border:1px solid black;margin:0px;display:flex;flex-direction:column;justify-content:center;' data-tag=\"{2}\">\n", width, eid, p_cellExpectedStatus[x, y]);
                        sbHtml.AppendFormat("      <div style='text-align:center;'>{0}</div>\n", s);
                        sbHtml.AppendFormat("    </div>\n");
                    }
                    sbHtml.AppendFormat("  </div>\n");
                }
            }
            sbHtml.Append("</div>\n");
        }
예제 #6
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            ctx.AppendToControlList("type", "checkbox", "id", Id.ToString(), "group", GroupName);
            string blockFormat = Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml() + "position:absolute;" + Area.HtmlLTRB();

            sbCss.AppendFormat(".c{0}n {{ {1} {2} cursor:pointer; }}\n", Id, HtmlTextColor(false), blockFormat);
            //sbCss.AppendFormat(".c{0}h {{ {1} {2} cursor:pointer; }}\n", Id, HtmlFormatColor(true), blockFormat);


            sbHtml.AppendFormat("<div class=\"c{0}n\" onclick=\"toogleCheckBox({0})\"", Id);
            sbHtml.Append(">");
            string align = CheckBoxAtEnd ? "right" : "left";

            sbHtml.AppendFormat("<img id=\"cbion{1}\" src=\"../rs/checkBoxOn.png\" style='display:none;object-fit:contain;float:{0};height:100%'>\n", align, Id);
            sbHtml.AppendFormat("<img id=\"cbioff{1}\" src=\"../rs/checkBoxOff.png\" style='display:block;object-fit:contain;float:{0};height:100%'>\n", align, Id);
            sbHtml.Append("<div class=\"vertCenter\" style='text-align:" + align + "'><div>" + Text);
            sbHtml.Append("</div></div>\n");

            sbHtml.Append("</div>");
        }
예제 #7
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            PrepareContent();
            bool   horz        = bHorizontal;
            string blockFormat = Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml();
            string dimensions  = string.Format("height:{0}%;width:{1}%", horz ? 100 : 100 / texts.Count, horz ? 100 / texts.Count : 100);

            sbHtml.Append("<div ");
            sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
            sbHtml.AppendFormat(" style ='display:flex;flex-direction:{1};position:absolute;z-index:{0};", zorder,
                                horz ? "row" : "column");
            SMRectangleArea area = this.Area;

            sbHtml.Append(area.HtmlLTRB());
            sbHtml.Append("'>\n");
            int i = 0;

            string[] radiustextH = { "15px 0px 0px 15px", "0px", "0px 15px 15px 0px" };
            string[] radiustextV = { "15px 15px 0px 0px", "0px", "0px 0px 15px 15px" };
            foreach (SelText si in texts)
            {
                int ridx = (i == 0 ? 0 : i == (texts.Count - 1) ? 2 : 1);
                sbHtml.AppendFormat("<div id=\"sel{0}_{2}\" class=\"csSelectN\" style='cursor:pointer;border-radius:{1};{3};' onclick=\"toogleSelectCtrl({0},{2})\">\n",
                                    Id, bHorizontal ? radiustextH[ridx] : radiustextV[ridx], i, dimensions);

                sbHtml.AppendFormat("<div class=\"vertCenter\" style='text-align:center'><div>\n");
                sbHtml.AppendFormat("{0}", si.text);
                sbHtml.AppendFormat("</div></div>");

                sbHtml.AppendFormat("</div>\n");
                i++;
            }
            //sbHtml.Append("background:lightyellow;border:1px solid black;'>");
            //sbHtml.Append("<b>" + GetType().Name + "</b><br>" + this.Text);
            sbHtml.Append("</div>\n");

            ctx.AppendToControlList("type", "select", "segments", texts.Count.ToString(), "correct", p_expectedSelection.ToString(),
                                    "id", Id.ToString(), "current", "0");
        }
예제 #8
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            ctx.AppendToResizeList("type", "canvaswh", "id", "can", "w", Area.RelativeArea.Width.ToString(), "h", Area.RelativeArea.Height.ToString());

            sbHtml.AppendFormat("<div style='position:absolute;z-index:{2};display:flex;flex-direction:row;left:{0}%;top:{1}%;'>\n", 25 * Area.RelativeArea.Left / 256, 25 * Area.RelativeArea.Top / 192, zorder);
            sbHtml.AppendFormat("<div style='display:flex;flex-direction:column'>\n");
            sbHtml.AppendFormat("    <div style=\"width:40px;height:30px;background:green;\" id=\"green\" onclick=\"freeDrawingColor(this)\"></div>\n");
            sbHtml.AppendFormat("    <div style=\"width:40px;height:30px;background:blue;\" id=\"blue\" onclick=\"freeDrawingColor(this)\"></div>\n");
            sbHtml.AppendFormat("    <div style=\"width:40px;height:30px;background:red;\" id=\"red\" onclick=\"freeDrawingColor(this)\"></div>\n");
            sbHtml.AppendFormat("    <div style=\"width:40px;height:30px;background:yellow;\" id=\"yellow\" onclick=\"freeDrawingColor(this)\"></div>\n");
            sbHtml.AppendFormat("    <div style=\"width:40px;height:30px;background:orange;\" id=\"orange\" onclick=\"freeDrawingColor(this)\"></div>\n");
            sbHtml.AppendFormat("    <div style=\"width:40px;height:30px;background:black;\" id=\"black\" onclick=\"freeDrawingColor(this)\"></div>\n");
            sbHtml.AppendFormat("    <div style=\"width:36px;height:30px;background:white;border:2px solid;\" id=\"white\" onclick=\"freeDrawingColor(this)\"></div>\n");
            sbHtml.AppendFormat("	<br>\n");
            sbHtml.AppendFormat("    <input type=\"button\" value=\"clear\" id=\"clr\" size=\"23\" onclick=\"freeDrawingErase()\" style=\"\">\n");
            sbHtml.AppendFormat("</div><div>\n");
            sbHtml.AppendFormat("    <canvas id=\"can\" width={1} height={2} style=\"z-index:{0};", zorder, Area.RelativeArea.Width, Area.RelativeArea.Height);
            if (BackgroundImage != null)
            {
                sbHtml.AppendFormat("background-size:contain;background-repeat:no-repeat;background-position:center;background-image:url('{0}');", ctx.GetFileNameFromImage(BackgroundImage));
            }
            sbHtml.AppendFormat("border:2px solid;\"></canvas></div></div>\n");
        }
예제 #9
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            bool   horz        = (Orientation == SMTextDirection.Horizontal);
            string blockFormat = Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml();

            sbCss.AppendFormat(".c{0}n {{ {1} {2} height:{3}%;width:{4}%; }}\n", Id, HtmlFormatColor(false), blockFormat,
                               horz ? 100 : 100 / Objects.Count, horz ? 100 / Objects.Count : 100);
//            sbCss.AppendFormat(".c{0}h {{ {1} {2} }}\n", Id, HtmlFormatColor(true), blockFormat);

            sbHtml.Append("<div ");
            sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
            sbHtml.AppendFormat(" style ='display:flex;flex-direction:{1};position:absolute;z-index:{0};", zorder,
                                horz ? "row" : "column");
            SMRectangleArea area = this.Area;

            sbHtml.Append(area.HtmlLTRB());
            sbHtml.Append("'>\n");
            foreach (StringItem si in Objects)
            {
                sbHtml.AppendFormat("<div class=\"c{0}n\">\n", Id);
                if (si.IsText)
                {
                    sbHtml.AppendFormat("<div class=\"vertCenter\"><div>\n");
                    sbHtml.AppendFormat("{0}", si.Text);
                    sbHtml.AppendFormat("</div></div>");
                }
                else if (si.IsImage)
                {
                    sbHtml.AppendFormat("<img src=\"{0}\" style='object-fit:contain;width:100%;height:100%;'>",
                                        ctx.GetFileNameFromImage(si.Image.Image));
                }
                sbHtml.AppendFormat("</div>\n");
            }
            //sbHtml.Append("background:lightyellow;border:1px solid black;'>");
            //sbHtml.Append("<b>" + GetType().Name + "</b><br>" + this.Text);
            sbHtml.Append("</div>\n");
        }
예제 #10
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            sbHtml.Append("<div ");
            sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
            sbHtml.AppendFormat(" style ='position:absolute;z-index:{0};", zorder);
            SMRectangleArea area = this.Area;

            sbHtml.Append(area.HtmlLTRB());
            sbHtml.Append("'>");

            DrawingContext dc = new DrawingContext();

            string[] lines = Drawings.Split('\r', '\n', ';');
            foreach (string line in lines)
            {
                string[] lp = line.Split(' ');
                if (lp.Length == 0)
                {
                    return;
                }
                if (lp[0] != "line")
                {
                    continue;
                }
                if (lp[1] == lp[3])
                {
                    sbHtml.AppendFormat("<div style='position:relative;top:{0}%;height:{1}%;left:{2}%;width:2;background:black;'></div>", lp[2], lp[4], lp[1]);
                }
                else if (lp[2] == lp[4])
                {
                    sbHtml.AppendFormat("<div style='position:relative;left:{0}%;width:{1}%;top:{2}%;height:2;background:black;'></div>", lp[1], lp[3], lp[2]);
                }
            }

            sbHtml.Append("</div>\n");
        }
예제 #11
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            sbHtml.Append("<div ");
            sbHtml.AppendFormat(" id=\"c{0}\" ", this.Id);
            sbHtml.AppendFormat(" style ='overflow-y:scroll;position:absolute;z-index:{0};", zorder);
            sbHtml.Append(Area.HtmlLTRB());
            sbHtml.Append(Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml());
            sbHtml.Append("'>");
            int tvid = 0;

            if (Text.IndexOf("<edit") >= 0 || Text.IndexOf("<drop") >= 0)
            {
                sbHtml.Append("<div style='display:flex;flex-direction:row;'>");
                drawWords = SMWordToken.WordListFromString(Text, this);
                int previousCount = 0;
                foreach (SMWordBase wb in drawWords)
                {
                    string elemId = string.Format("tv{0}_{1}", Id, tvid++);
                    if (previousCount > 0)
                    {
                        sbHtml.AppendFormat("<div class=\"textViewElem\">&nbsp;</div>");
                    }
                    if (wb is SMWordImage wbi)
                    {
                        sbHtml.AppendFormat("<div class=\"textViewElem\"><img src=\"{0}\" width={1} height={2}></div>", ctx.GetFileNameFromImage(wbi.image), wbi.imageSize.Width, wbi.imageSize.Height);
                        previousCount++;
                    }
                    else if (wb is SMWordSpecial wbs)
                    {
                        switch (wbs.Type)
                        {
                        case SMWordSpecialType.HorizontalLine:
                            sbHtml.Append("<hr>");
                            previousCount = 0;
                            break;

                        case SMWordSpecialType.Newline:
                            sbHtml.Append("</div>");
                            sbHtml.Append("<div style='display:flex;flex-direction:row;'>");
                            previousCount = 0;
                            break;

                        case SMWordSpecialType.NewPage:
                            sbHtml.Append("</div>");
                            sbHtml.Append("<div style='display:flex;flex-direction:row;margin-top:16pt;'>");
                            previousCount = 0;
                            break;

                        case SMWordSpecialType.NewColumn:
                            sbHtml.Append("</div>");
                            sbHtml.Append("<div style='display:flex;flex-direction:row;margin-top:16pt;'>");
                            previousCount = 0;
                            break;
                        }
                    }
                    else if (wb is SMWordText wbt)
                    {
                        sbHtml.AppendFormat("<div id=\"{1}\" class=\"textViewElem\">{0}</div>", wbt.text, elemId);
                        previousCount++;
                    }
                    else if (wb is SMWordToken wbk)
                    {
                        if (wbk.Editable)
                        {
                            sbHtml.AppendFormat("<div class=\"textViewElem\"><input id=\"{2}\" type=text size={1} style='background:LightYellow;font-family:{0};font-size:100%;'></div>", Font.Name, wbk.tag.Length, elemId);
                        }
                        else
                        {
                            sbHtml.AppendFormat("<div id=\"{2}\" class=\"textViewElem dropable\" data-tag=\"{1}\">{0}</div>", wbk.text.Length > 0 ? wbk.text : "__________", wbk.tag, elemId);
                        }
                        previousCount++;
                    }
                }
                sbHtml.Append("</div>");
            }
            else
            {
                sbHtml.Append(this.Text.Replace("\n", "<br>"));
            }

            sbHtml.Append("</div>\n");
        }
예제 #12
0
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            Rectangle rect = Area.RelativeArea;

            SMStatusLayout layout = PrepareBrushesAndPens();

            Rectangle           bounds  = ContentPadding.ApplyPadding(rect);
            SMContentArangement argm    = this.ContentArangement;
            Rectangle           imgRect = bounds;

            Image image = GetContentImage();

            if (string.IsNullOrEmpty(BuiltInImage))
            {
                argm = SMContentArangement.TextOnly;
            }



            string plainText = Text;


            string blockFormat = Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml() + "position:absolute;" + Area.HtmlLTRB();

            sbCss.AppendFormat(".c{0}n {{ {1} {2} cursor:pointer; }}\n", Id, HtmlFormatColor(false), blockFormat);
            sbCss.AppendFormat(".c{0}h {{ {1} {2} cursor:pointer; }}\n", Id, HtmlFormatColor(true), blockFormat);
            string imgText = "", textText = "";



            if (argm != SMContentArangement.TextOnly)
            {
                imgText = string.Format("<img src=\"../rs/{1}.png\" style='object-fit:contain;width:100%;height:100%'></td>\n", Id, BuiltInImage != null ? BuiltInImage : "default");
            }
            if (argm != SMContentArangement.ImageOnly)
            {
                // wrapping text into vertical/horizontal alignment DIV
                textText += plainText;
            }

            string onclick = GetOnclickHtml();

            sbHtml.AppendFormat("<div class=\"c{0}n\" onclick=\"{1}\"", Id, onclick);
            sbHtml.Append(">");

            switch (argm)
            {
            case SMContentArangement.ImageAbove:
                sbHtml.AppendFormat("  <table class=\"c{0}n\"", Id);
                if (onclick.Length > 0)
                {
                    sbHtml.AppendFormat(" onclick=\"{0}\"", onclick);
                }
                sbHtml.Append(">\n");
                sbHtml.Append("<tr><td>");
                sbHtml.Append(imgText);
                sbHtml.Append("<tr><td>");
                sbHtml.Append(textText);
                sbHtml.Append("</table>\n");
                break;

            case SMContentArangement.ImageBelow:
                sbHtml.AppendFormat("  <table class=\"c{0}n\"", Id);
                if (onclick.Length > 0)
                {
                    sbHtml.AppendFormat(" onclick=\"{0}\"", onclick);
                }
                sbHtml.Append(">\n");
                sbHtml.Append("<tr><td>");
                sbHtml.Append(textText);
                sbHtml.Append("<tr><td>");
                sbHtml.Append(imgText);
                sbHtml.Append("</table>\n");
                break;

            case SMContentArangement.ImageOnLeft:
                sbHtml.Append(string.Format("<img src=\"../rs/{1}.png\" style='object-fit:contain;float:left;height:100%'>\n", Id, BuiltInImage != null ? BuiltInImage : "default"));
                sbHtml.Append("<div class=\"vertCenter\"><div>" + textText);
                sbHtml.Append("</div></div>\n");
                break;

            case SMContentArangement.ImageOnRight:
                sbHtml.Append(string.Format("<img src=\"../rs/{1}.png\" style='object-fit:contain;float:right;height:100%'>\n", Id, BuiltInImage != null ? BuiltInImage : "default"));
                sbHtml.Append("<div class=\"vertCenter\"><div>" + textText);
                sbHtml.Append("</div></div>\n");
                break;

            case SMContentArangement.TextOnly:
                sbHtml.AppendFormat("  <div class=\"c{0}n\" style='display:flex;flex-direction:column;justify-content:center;'", Id);
                if (onclick.Length > 0)
                {
                    sbHtml.AppendFormat(" onclick=\"{0}\"", onclick);
                }
                sbHtml.Append("><div>\n");
                sbHtml.Append(textText);
                sbHtml.Append("</div></div>\n");
                break;

            case SMContentArangement.ImageOnly:
                sbHtml.AppendFormat("  <div class=\"c{0}n\" onclick=\"{1}\">\n", Id, onclick);
                sbHtml.Append(imgText);
                sbHtml.Append("</div>\n");
                break;
            }

            sbHtml.Append("</div>");
        }
예제 #13
0
 public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
 {
     //base.ExportToHtml(ctx, zorder, sbHtml, sbCss, sbJS);
 }
예제 #14
0
파일: SMImage.cs 프로젝트: gopa810/Rambha
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
            SMImage   pi   = this;
            Rectangle rect = Area.RelativeArea;

            SMStatusLayout layout = PrepareBrushesAndPens();

            Rectangle           bounds   = ContentPadding.ApplyPadding(rect);
            SMContentArangement argm     = this.ContentArangement;
            MNReferencedImage   refImage = null;
            Rectangle           imgRect  = bounds;

            Image image = GetContentImage(out refImage);

            if (image == null)
            {
                argm = SMContentArangement.TextOnly;
            }


            /*if (argm == SMContentArangement.ImageOnly)
             * {
             *  SMContentScaling scaling = ContentScaling;
             *  Rectangle rc = DrawImage(context, layout, bounds, image, scaling, SourceOffsetX, SourceOffsetY);
             *  if (ContentScaling == SMContentScaling.Fill)
             *  {
             *      showRect = bounds;
             *      sourceRect = rc;
             *  }
             *  else
             *  {
             *      showRect = rc;
             *      sourceRect = new Rectangle(0, 0, image.Width, image.Height);
             *  }
             * }
             * else
             * {*/
            /*Size textSize = Size.Empty;
             * Font usedFont = GetUsedFont();*/
            string plainText = Text.Length > 0 ? Text : DroppedText;

            if (plainText.IndexOf("_") >= 0 && DroppedTag.Length > 0)
            {
                plainText = plainText.Replace("_", DroppedTag);
            }

            /*if (plainText.Length != 0)
             * {
             *  textSize = rt.MeasureString(context, plainText, bounds.Width);
             * }
             *
             * Rectangle textRect = bounds;
             *
             *
             *
             * if (argm == SMContentArangement.ImageAbove)
             * {
             *  textRect.Height = textSize.Height;
             *  textRect.Y = bounds.Bottom - textRect.Height;
             *  textRect.X = (textRect.Left + textRect.Right) / 2 - textSize.Width / 2;
             *  textRect.Width = textSize.Width;
             *  imgRect.Height = bounds.Height - textRect.Height - ContentPadding.Top;
             * }
             * else if (argm == SMContentArangement.ImageBelow)
             * {
             *  textRect.Height = textSize.Height;
             *  textRect.X = (textRect.Left + textRect.Right) / 2 - textSize.Width / 2;
             *  textRect.Width = textSize.Width;
             *  imgRect.Y = textRect.Bottom + ContentPadding.Bottom;
             *  imgRect.Height = bounds.Height - textRect.Height - ContentPadding.Bottom;
             * }
             * else if (argm == SMContentArangement.ImageOnLeft)
             * {
             *  textRect.Width = textSize.Width;
             *  textRect.X = bounds.Right - textSize.Width;
             *  imgRect.Width = bounds.Width - textSize.Width - ContentPadding.Left;
             * }
             * else if (argm == SMContentArangement.ImageOnRight)
             * {
             *  textRect.Width = textSize.Width;
             *  imgRect.X = textRect.Right + ContentPadding.Right;
             *  imgRect.Width = bounds.Width - textSize.Width - ContentPadding.Right;
             * }
             * else if (argm == SMContentArangement.ImageOnly)
             * {
             *  textRect = Rectangle.Empty;
             * }
             * else if (argm == SMContentArangement.TextOnly)
             * {
             *  imgRect = Rectangle.Empty;
             * }
             *
             *
             * if (!imgRect.IsEmpty)
             * {
             *  Rectangle rc = DrawImage(context, layout, imgRect, image, ContentScaling, SourceOffsetX, SourceOffsetY);
             *  if (ContentScaling == SMContentScaling.Fill)
             *  {
             *      showRect = imgRect;
             *      sourceRect = rc;
             *  }
             *  else
             *  {
             *      showRect = rc;
             *      sourceRect = new Rectangle(0, 0, image.Width, image.Height);
             *  }
             *
             * }
             *
             * if (!textRect.IsEmpty)
             * {
             *  if (argm == SMContentArangement.TextOnly)
             *  {
             *      DrawStyledBorder(context, layout, bounds);
             *  }
             *  textRect.Inflate(2, 2);
             *  rt.DrawString(context, layout, plainText, textRect);
             * }
             * }*/

            /*if (!imgRect.IsEmpty && refImage != null && refImage.HasSpots())
             * {
             *  foreach (MNReferencedSpot rs in refImage.SafeSpots)
             *  {
             *      if (rs.ContentType != SMContentType.TaggedArea) continue;
             *      if (rs.UIStateHighlighted || (HoverSpot == rs))
             *      {
             *          rs.Paint(context.g, showRect, false, context.SpotAreaBorderPen, null);
             *      }
             *  }
             * }*/

            string blockFormat = Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml() + "position:absolute;" + Area.HtmlLTRB();

            sbCss.AppendFormat(".c{0}n {{ {1} {2} }}\n", Id, HtmlFormatColor(false), blockFormat);
            sbCss.AppendFormat(".c{0}h {{ {1} {2} }}\n", Id, HtmlFormatColor(true), blockFormat);
            string imgText = "", textText = "";



            if (argm != SMContentArangement.TextOnly)
            {
                imgText = string.Format("<td><img src=\"{1}\" style='object-fit:contain;width:100%;height:100%'></td>\n", Id, ctx.GetFileNameFromImage(refImage));
            }
            if (argm != SMContentArangement.ImageOnly)
            {
                // wrapping text into vertical/horizontal alignment DIV
                textText  = "<td>";
                textText += plainText;
                textText += "</td>\n";
            }

            switch (argm)
            {
            case SMContentArangement.ImageAbove:
                sbHtml.AppendFormat("  <table class=\"c{0}n\">\n", Id);
                sbHtml.Append("<tr>");
                sbHtml.Append(imgText);
                sbHtml.Append("<tr>");
                sbHtml.Append(textText);
                sbHtml.Append("</table>\n");
                break;

            case SMContentArangement.ImageBelow:
                sbHtml.AppendFormat("  <table class=\"c{0}n\">\n", Id);
                sbHtml.Append("<tr>");
                sbHtml.Append(textText);
                sbHtml.Append("<tr>");
                sbHtml.Append(imgText);
                sbHtml.Append("</table>\n");
                break;

            case SMContentArangement.ImageOnLeft:
                sbHtml.AppendFormat("  <table class=\"c{0}n\">\n", Id);
                sbHtml.Append("<tr>");
                sbHtml.Append(imgText);
                sbHtml.Append(textText);
                sbHtml.Append("</table>\n");
                break;

            case SMContentArangement.ImageOnRight:
                sbHtml.AppendFormat("  <table class=\"c{0}n\">\n", Id);
                sbHtml.Append("<tr>");
                sbHtml.Append(textText);
                sbHtml.Append(imgText);
                sbHtml.Append("</table>\n");
                break;

            case SMContentArangement.TextOnly:
                sbHtml.AppendFormat("  <table class=\"c{0}n\">\n", Id);
                sbHtml.Append("<tr>");
                sbHtml.Append(textText);
                sbHtml.Append("</table>\n");
                break;

            case SMContentArangement.ImageOnly:
                sbHtml.AppendFormat("  <div class=\"c{0}n\">\n", Id);
                sbHtml.Append(imgText);
                sbHtml.Append("</div>\n");
                break;
            }
        }
예제 #15
0
파일: SMLabel.cs 프로젝트: gopa810/Rambha
        public override void ExportToHtml(MNExportContext ctx, int zorder, StringBuilder sbHtml, StringBuilder sbCss, StringBuilder sbJS)
        {
//            SMRectangleArea area = this.Area;
//            Rectangle bounds = area.RelativeArea;


            if (Text != null && Text.Contains("\\n"))
            {
                Text = Text.Replace("\\n", "\n");
            }
            Text = Text.Replace("\n", "<br>");
            string plainText = Text;

            if (Content != null)
            {
                plainText = null;
                if (Content is MNReferencedText)
                {
                    plainText = ((MNReferencedText)Content).Text;
                }
                else if (Content is MNReferencedSound)
                {
                    plainText = Text;
                }
            }

            if (plainText.StartsWith("$"))
            {
                plainText = Document.ResolveProperty(plainText.Substring(1));
            }

            if (plainText != null)
            {
                //Size textSize = richText.MeasureString(context, plainText, textBounds.Width);

                /*Rectangle r = Area.GetDockedRectangle(SMRectangleArea._size_4_3, textSize);
                 * if (Area.Dock != SMControlSelection.None)
                 * {
                 *  textBounds.X = Area.RelativeArea.X + SMRectangleArea.PADDING_DOCK_LEFT;
                 *  textBounds.Y = Area.RelativeArea.Y + SMRectangleArea.PADDING_DOCK_TOP;
                 *  textBounds.Width = Area.RelativeArea.Width - SMRectangleArea.PADDING_DOCK_LEFT
                 *      - SMRectangleArea.PADDING_DOCK_RIGHT + 2;
                 *  textBounds.Height = Area.RelativeArea.Height - SMRectangleArea.PADDING_DOCK_TOP - SMRectangleArea.PADDING_DOCK_BOTTOM + 2;
                 *  richText.Paragraph.VertAlign = SMVerticalAlign.Top;
                 * }*/


                /*if (Area.BackType == SMBackgroundType.Shadow && Area.BackgroundImage != null)
                 * {
                 *  sbHtml.AppendFormat("<img style='position:absolute;top:{0}%;left:{1}%;width:{2}%;height:{3}%;' src=\"{4}\" />",
                 *    SMRectangleArea.AbsToPercX(textBounds.X + Area.BackgroundImageOffset.X),
                 *    SMRectangleArea.AbsToPercY(textBounds.Y + Area.BackgroundImageOffset.Y),
                 *    SMRectangleArea.AbsToPercX(Area.BackgroundImage.Size.Width),
                 *    SMRectangleArea.AbsToPercX(Area.BackgroundImage.Size.Height),
                 *    ctx.GetFileNameFromImage(Area.BackgroundImage));
                 * }*/

                //if (Area.Dock == SMControlSelection.None) DrawStyledBorder(context, layout, bounds);

                string onclick = GetOnclickHtml();

                //richText.DrawString(context, layout, textBounds);
                string blockFormat = Font.HtmlString() + Paragraph.Html() + ContentPaddingHtml() + "position:absolute;" + Area.HtmlLTRB();
                sbCss.AppendFormat(".c{0}n {{ {1} {2} }}\n", Id, HtmlFormatColor(false), blockFormat);
                sbCss.AppendFormat(".c{0}h {{ {1} {2} }}\n", Id, HtmlFormatColor(true), blockFormat);
                sbHtml.AppendFormat("<div class=\"c{0}n\" style='display:flex;flex-direction:column;justify-content:{1};cursor:pointer;'", Id, GetVerticalAlignHtml());
                if (onclick.Length > 0)
                {
                    sbHtml.AppendFormat(" onclick=\"{0}\" ", onclick);
                }
                sbHtml.Append(">\n");
                sbHtml.Append("<div>" + plainText + "</div>");
                sbHtml.AppendFormat("\n</div>\n");
            }
        }