Пример #1
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");
        }
Пример #2
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");
        }
Пример #3
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");
        }
Пример #4
0
        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;
            }
        }