Beispiel #1
0
 public override void Paint(MNPageContext context, SMStatusLayout layout, int X, int Y)
 {
     if (Type == SMWordSpecialType.HorizontalLine)
     {
         context.g.DrawLine(SMGraphics.GetPen(layout.ForeColor, 1), rect.X + X, rect.Y + Y + rect.Height / 2, rect.Right + X, rect.Y + Y + rect.Height / 2);
     }
     base.Paint(context, layout, X, Y);
 }
Beispiel #2
0
 public override Brush GetCurrentTextBrush(SMStatusLayout layout)
 {
     if (textBrush != null)
     {
         return(textBrush);
     }
     return(base.GetCurrentTextBrush(layout));
 }
Beispiel #3
0
        public override void Paint(MNPageContext context)
        {
            if (!Visible || context.CurrentPage == null)
            {
                return;
            }

            //Rectangle bounds = Area.GetBounds(context);
            Rectangle textBounds = new Rectangle(32, 0, context.PageWidth - 64, context.PageHeight);

            string plainText = context.CurrentPage.MessageText;
            string titleText = context.CurrentPage.MessageTitle;

            SMStatusLayout layout      = GetFullStatusLayout();
            Font           usedFont    = GetUsedFont();
            int            titleHeight = 0;
            int            textHeight  = 0;

            if (titleText != null)
            {
                Size size = titleRichText.MeasureString(context, titleText, textBounds.Width);
                titleHeight = size.Height;
            }

            if (plainText != null)
            {
                Size size = messageRichText.MeasureString(context, plainText, textBounds.Width);
                textHeight = size.Height;
            }

            int cy = context.PageHeight;

            if (textHeight > 0)
            {
                cy = cy - textHeight - 32;
                context.g.FillRectangle(Brushes.LightBlue, 0, cy, context.PageWidth, textHeight + 32);
                textBounds.Y      = cy;
                textBounds.Height = textHeight + 32;
                messageRichText.DrawString(context, layout, plainText, textBounds);
            }

            if (titleHeight > 0)
            {
                cy = cy - titleHeight - 16;
                context.g.FillRectangle(Brushes.CadetBlue, 0, cy, context.PageWidth, titleHeight + 16);
                textBounds.Y      = cy;
                textBounds.Height = titleHeight + 16;
                titleRichText.DrawString(context, layout, titleText, textBounds);
            }

            if (titleHeight + textHeight > 0)
            {
                cy -= 4;
                context.g.FillRectangle(Brushes.Black, 0, cy, context.PageWidth, 4);
            }

            CurrentTop = cy;
        }
Beispiel #4
0
        public override void Paint(MNPageContext context)
        {
            Rectangle bounds = Area.GetBounds(context);

            SMStatusLayout layout = PrepareBrushesAndPens();

            Rectangle textBounds = ContentPadding.ApplyPadding(bounds);

            // size of one cell
            SizeF sizeChar = context.g.MeasureString("M", Font.Font);
            int   cellSize = (int)(sizeChar.Height * 12 / 10);
            Font  drawFont = GetUsedFont();

            // prepare formating
            StringFormat format = new StringFormat();

            format.Alignment     = StringAlignment.Center;
            format.LineAlignment = StringAlignment.Center;

            if (wordsModified)
            {
                RecalculateWords(context, textBounds.Width);
                while (Lines.Count > LinesCount && LinesCount > 0)
                {
                    TextBuilder.Remove(TextBuilder.Length - 1, 1);
                    RecalculateWords(context, textBounds.Width);
                }
                wordsModified = false;
            }

            Brush textB = (UIStateError == MNEvaluationResult.Incorrect ? Brushes.Red : tempForeBrush);
            Brush cursB = (UIStateError == MNEvaluationResult.Incorrect ? Brushes.Pink : Brushes.LightBlue);

            Font usedFont = Font.Font;

            // drawing all positions
            for (int i = 0; i < LinesCount; i++)
            {
                int y = cellSize * (i + 1) + textBounds.Y;
                context.g.DrawLine(Pens.Gray, textBounds.Left, y, textBounds.Right, y);
                // draws cursor only if control is focused
                if (i < Lines.Count)
                {
                    SizeF ll = context.g.MeasureString(Lines[i], usedFont);
                    int   y2 = y - (int)ll.Height - 3;
                    context.g.DrawString(Lines[i], usedFont, textB, textBounds.X, y2);

                    if (i == Lines.Count - 1)
                    {
                        context.g.FillRectangle(cursB, textBounds.X + ll.Width + 2, y2, cellSize * 2 / 3, cellSize);
                    }
                }
            }

            // draw selection marks
            base.Paint(context);
        }
Beispiel #5
0
 public void Set(SMStatusLayout s)
 {
     BackColor    = s.BackColor;
     ForeColor    = s.ForeColor;
     BorderColor  = s.BorderColor;
     BorderStyle  = s.BorderStyle;
     BorderWidth  = s.BorderWidth;
     CornerRadius = s.CornerRadius;
 }
Beispiel #6
0
        /*
         * [Browsable(true), Category("Appearance")]
         * public bool SizeToFit { get; set; }
         *
         * [Browsable(true), Category("Appearance")]
         * public float LineSpacing { get; set; }*/

        public MNReferencedStyle()
        {
            Name           = "";
            Font           = new SMFont();
            ContentPadding = new SMContentPadding();
            Paragraph      = new SMParaFormat();
            HighlightState = new SMStatusLayout();
            NormalState    = new SMStatusLayout();
        }
Beispiel #7
0
 public SMTextContainer(MNPage p)
     : base(p)
 {
     Text             = "Text Container";
     Evaluation       = MNEvaluationType.Inherited;
     ItemLayout       = new SMStatusLayout();
     ItemMargin       = new SMContentPadding();
     ItemMargin.Left  = ItemMargin.Right = 8;
     ItemMargin.Top   = ItemMargin.Bottom = 8;
     ItemPadding      = new SMContentPadding();
     ItemPadding.Left = ItemPadding.Right = 8;
     ItemPadding.Top  = ItemPadding.Bottom = 8;
 }
Beispiel #8
0
        public void DrawString(MNPageContext context, SMStatusLayout layout, string plainText, Rectangle textBounds, int nPage)
        {
            if (!p_prevText.Equals(plainText) || (p_prevWidth != textBounds.Width) || drawWords == null)
            {
                p_prevText = plainText;
                drawWords  = WordListFromString(plainText);
                richLayout = RecalculateWordsLayout(context, textBounds);
            }

            foreach (SMWordBase wt in drawWords)
            {
                if (wt.PageNo == nPage)
                {
                    wt.Paint(context, layout, textBounds.X, textBounds.Y);
                }
            }
        }
Beispiel #9
0
        public void PaintPageNo(MNPageContext context, SMStatusLayout layout, int X, int Y)
        {
            Brush backgroundBrush     = SMGraphics.GetBrush(layout.BackColor);
            Brush highBackgroundBrush = SMGraphics.GetBrush(Color.LightGray);
            Brush textBrush           = SMGraphics.GetBrush(layout.ForeColor);

            foreach (SMTextContainerLine wline in drawLines)
            {
                foreach (SMTextContainerWord wt in wline)
                {
                    Rectangle r = wt.rect;
                    r.Offset(X, Y);
                    context.g.DrawFillRoundedRectangle(Pens.Black, wt.Used ? highBackgroundBrush : backgroundBrush, r, 5);
                    context.g.DrawString(wt.text, Font.Font, textBrush, r, SMGraphics.StrFormatCenter);
                }
            }
        }
Beispiel #10
0
 private void DrawListItem(MNPageContext context, SMStatusLayout layout, Font usedFont, Rectangle showRect, bool isFirst, StringItem obj)
 {
     if (obj.IsText)
     {
         StringFormat format = Paragraph.GetAlignmentStringFormat();
         if (Orientation == SMTextDirection.Horizontal)
         {
             format.Trimming     = StringTrimming.None;
             format.FormatFlags |= StringFormatFlags.NoClip | StringFormatFlags.NoWrap;
         }
         context.g.DrawString(CapitalizeCond(obj.Text, isFirst), usedFont, tempForeBrush, showRect, format);
     }
     else if (obj.IsImage)
     {
         DrawImage(context, layout, showRect, obj.Image.ImageData, SMContentScaling.Fit);
     }
 }
Beispiel #11
0
        public void PaintPageNo(MNPageContext context, SMStatusLayout layout, int pageNo, int X, int Y)
        {
            if (pageNo >= PageCount)
            {
                pageNo = PageCount - 1;
            }
            if (pageNo < 0)
            {
                pageNo = 0;
            }

            foreach (SMWordLine wline in drawLines)
            {
                foreach (SMWordBase wt in wline)
                {
                    if (wt.PageNo == pageNo)
                    {
                        wt.Paint(context, layout, X, Y);
                    }
                }
            }
        }
Beispiel #12
0
        public override void Paint(MNPageContext context, SMStatusLayout layout, int X, int Y)
        {
            string s = GetCurrentText();

            //Brush b = SMGraphics.GetBrush(layout.BackColor);

            if (UIStateHover)
            {
                context.g.DrawRectangle(SMGraphics.GetPen(SMGraphics.dropableLayoutH.BorderColor, 4), rect.X + X, rect.Y + Y, rect.Width, rect.Height);
            }
            else
            {
                context.g.DrawRectangle(SMGraphics.GetPen(SMGraphics.dropableLayoutN.BorderColor, 2), rect.X + X, rect.Y + Y, rect.Width, rect.Height);
            }

            if (Editable && Focused)
            {
                SizeF sz = context.g.MeasureString(editedText, this.Font.Font);
                context.g.FillRectangle(Brushes.LightBlue, rect.X + X + (int)sz.Width, rect.Y + Y + 1, 10, rect.Height - 2);
            }

            context.g.DrawString(s, this.Font.Font, GetCurrentTextBrush(layout), rect.Location.X + X, rect.Location.Y + Y);
        }
Beispiel #13
0
        public override Brush GetCurrentTextBrush(SMStatusLayout layout)
        {
            if (Editable)
            {
                if (tag != null && editedText != null)
                {
                    int a = tag.Length;
                    int b = editedText.Length;
                    int c = Math.Min(a, b);
                    if (c > 0)
                    {
                        if (tag.Substring(0, c).Equals(editedText.Substring(0, c), StringComparison.CurrentCultureIgnoreCase))
                        {
                            return(SMGraphics.GetBrush(Color.DarkGreen));
                        }
                        else
                        {
                            return(SMGraphics.GetBrush(Color.Red));
                        }
                    }
                }

                return(SMGraphics.GetBrush(Color.DarkGreen));
            }
            else
            {
                if (droppedItem != null)
                {
                    return(SMGraphics.GetBrush(Color.MediumBlue));
                }
                else
                {
                    return(base.GetCurrentTextBrush(layout));
                }
            }
        }
Beispiel #14
0
 public virtual void Paint(MNPageContext context, SMStatusLayout layout, int X, int Y)
 {
 }
Beispiel #15
0
        public override void Paint(MNPageContext context)
        {
            Graphics  g    = context.g;
            SMImage   pi   = this;
            Rectangle rect = Area.GetBounds(context);

            SMConnection conn = context.CurrentPage.FindConnection(this);

            if (conn != null)
            {
                UIStateHover = true;
            }

            SMStatusLayout layout = PrepareBrushesAndPens();

            Debugger.Log(0, "", "State of " + Text + " Image is " + UIStateChecked.ToString() + "\n");
            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 (ExpectedChecked != Bool3.Undef)
            {
                DrawStyledBackground(context, layout, bounds);
            }

            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);
                    }
                }
            }

            if (UIStateError == MNEvaluationResult.Incorrect && UIStateChecked)
            {
                if (Document.HasViewer)
                {
                    Document.Viewer.ScheduleCall(MNNotificationCenter.RectifyDelay, this, "clearCheck");
                }
            }

            base.Paint(context);
        }
Beispiel #16
0
        public override void Paint(MNPageContext context)
        {
            Graphics      g    = context.g;
            SMImageButton pi   = this;
            Rectangle     rect = Area.GetBounds(context);

            SMStatusLayout layout = PrepareBrushesAndPens();

            DrawStyledBackground(context, layout, rect);
            DrawStyledBorder(context, layout, rect);

            Rectangle           bounds         = ContentPadding.ApplyPadding(rect);
            Rectangle           imageBounds    = Rectangle.Empty;
            Rectangle           textBounds     = Rectangle.Empty;
            SMContentArangement argm           = this.ContentArangement;
            SMContentScaling    ContentScaling = SMContentScaling.Fit;

            Image image = GetContentImage();

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

            if (argm == SMContentArangement.ImageOnly)
            {
                SMContentScaling scaling = ContentScaling;
                Rectangle        rc      = DrawImage(context, null, bounds, image, scaling, 0, 0);
                showRect = rc;
            }
            else
            {
                Rectangle imgRect   = bounds;
                Size      textSize  = Size.Empty;
                Font      usedFont  = GetUsedFont();
                string    plainText = Text;
                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)
                {
                    imgRect.Size = SMControl.GetImageDrawSize(bounds, image);
                    if (bounds.Width - imgRect.Width < textSize.Width + ContentPadding.LeftRight)
                    {
                        imgRect.Width = bounds.Width - textSize.Width - ContentPadding.LeftRight;
                        imgRect.Size  = SMControl.GetImageDrawSize(imgRect, image);
                    }
                    textRect.Width = bounds.Width - imgRect.Width - ContentPadding.LeftRight;
                    textRect.X     = bounds.Right - textRect.Width;
                    imgRect.Y      = (bounds.Top + bounds.Bottom) / 2 - imgRect.Height / 2;
                }
                else if (argm == SMContentArangement.ImageOnRight)
                {
                    imgRect.Size = SMControl.GetImageDrawSize(bounds, image);
                    if (bounds.Width - imgRect.Width < textSize.Width + ContentPadding.LeftRight)
                    {
                        imgRect.Width = bounds.Width - textSize.Width - ContentPadding.LeftRight;
                        imgRect.Size  = SMControl.GetImageDrawSize(imgRect, image);
                    }
                    textRect.Width = bounds.Width - imgRect.Width - ContentPadding.LeftRight;
                    imgRect.X      = textRect.Right + 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, null, imgRect, image, ContentScaling, 0, 0);
                    showRect = rc;
                }

                if (!textRect.IsEmpty)
                {
                    textRect.Inflate(1, 1);
                    rt.DrawString(context, layout, plainText, textRect);
                }
            }

            base.Paint(context);
        }
Beispiel #17
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>");
        }
Beispiel #18
0
        public override void Paint(MNPageContext context)
        {
            Rectangle bounds = Area.GetBounds(context);

            SMStatusLayout layout = PrepareBrushesAndPens();

            Rectangle textBounds = ContentPadding.ApplyPadding(bounds);

            if (Text.Length == 0)
            {
                bool b = UIStatePressed;
                UIStatePressed |= UIStateChecked;
                DrawStyledBackground(context, layout, textBounds);
                DrawStyledBorder(context, layout, textBounds);
                UIStatePressed = b;
            }
            else
            {
                Font font = GetUsedFont();

                SizeF cbSize = context.g.MeasureString("M", font);
                int   inpad  = (int)(cbSize.Height / 8);
                int   inpad2 = inpad / 2;
                int   height = (int)(cbSize.Height * 3 / 4);


                SizeF sf       = richText.MeasureString(context, Text, textBounds.Width - height - 2 * inpad);
                Size  textSize = new Size((int)sf.Width + 5, (int)sf.Height);

                Pen drawPen = (UIStateError == MNEvaluationResult.Incorrect ? Pens.Red : tempForePen);

                Rectangle rectCB = textBounds;
                if (CheckBoxAtEnd)
                {
                    rectCB          = new Rectangle(textBounds.X + textSize.Width + inpad, rectCB.Top + inpad, height, height);
                    textBounds.Size = textSize;
                }
                else
                {
                    rectCB          = new Rectangle(rectCB.Left + inpad, rectCB.Top + inpad, height, height);
                    textBounds.Size = textSize;
                    textBounds.X   += height + 2 * inpad + ContentPadding.LeftRight;
                }

                if (Status)
                {
                    context.g.DrawFillRoundedRectangle(SMGraphics.GetPen(layout.ForeColor, 1), SMGraphics.GetBrush(layout.BackColor), rectCB, 5);
                }
                else
                {
                    context.g.DrawRoundedRectangle(SMGraphics.GetPen(layout.ForeColor, 1), rectCB, 5);
                }

                if (Clickable)
                {
                    richText.DrawString(context, SMGraphics.clickableLayoutN, Text, textBounds);
                }
                else
                {
                    richText.DrawString(context, NormalState, Text, textBounds);
                }
            }

            // in case this is wrongly checked, run clearing the state in 2 secs
            if (UIStateError == MNEvaluationResult.Incorrect && UIStateChecked)
            {
                if (Document.HasViewer)
                {
                    Document.Viewer.ScheduleCall(MNNotificationCenter.RectifyDelay, this, "clearCheck");
                }
            }


            // draw selection marks
            base.Paint(context, false);
        }
Beispiel #19
0
        public override void Paint(MNPageContext context)
        {
            Rectangle bounds = Area.GetBounds(context);

            SMStatusLayout layout = PrepareBrushesAndPens();

            if (p_format == null)
            {
                p_format               = new StringFormat();
                p_format.Alignment     = StringAlignment.Center;
                p_format.LineAlignment = StringAlignment.Center;
            }

            if (!p_prevContent.Equals(ContentCells))
            {
                AnalyzeContents();
                FindFirstEmptyCell();
                p_prevContent = ContentCells;
                if (p_xmax < 1 || p_ymax < 1)
                {
                    return;
                }
            }

            Rectangle textBounds = ContentPadding.ApplyPadding(bounds);

            // size of one cell
            p_cellx = Math.Min(textBounds.Height / p_ymax, textBounds.Width / p_xmax);
            Font usedFont = SMGraphics.GetFontVariation(Font.Font, p_cellx * 0.7f);


            // prepare rectangle for letter
            Rectangle rect = new Rectangle();

            rect.Width  = p_cellx;
            rect.Height = p_cellx;
            Brush bb;

            int lastIndex = p_ymax - 1;

            for (int x = 0; x < p_xmax; x++)
            {
                rect.X = textBounds.X + x * p_cellx;
                for (int y = 0; y < p_ymax; y++)
                {
                    rect.Y = textBounds.Y + y * p_cellx;
                    if (p_array[x, y, 1].Length > 0)
                    {
                        if (x == p_focusX && y == p_focusY)
                        {
                            context.g.FillRectangle(Brushes.LightBlue, rect);
                        }
                        else
                        {
                            context.g.FillRectangle(tempBackBrush, rect);
                        }
                        context.g.DrawLine(tempBorderPen, rect.X, rect.Y, rect.X + p_cellx, rect.Y);
                        context.g.DrawLine(tempBorderPen, rect.X, rect.Y, rect.X, rect.Y + p_cellx);
                        if (y >= p_ymax - 1 || p_array[x, y + 1, 1].Length == 0)
                        {
                            context.g.DrawLine(tempBorderPen, rect.X, rect.Y + p_cellx, rect.X + p_cellx, rect.Y + p_cellx);
                        }
                        if (x >= p_xmax - 1 || p_array[x + 1, y, 1].Length == 0)
                        {
                            context.g.DrawLine(tempBorderPen, rect.X + p_cellx, rect.Y, rect.X + p_cellx, rect.Y + p_cellx);
                        }
                        bb = ((UIStateError == MNEvaluationResult.Incorrect &&
                               (p_array[x, y, 0] != p_array[x, y, 1])) ? Brushes.Red : tempForeBrush);
                        context.g.DrawString(p_array[x, y, 0], usedFont, bb, rect, p_format);
                    }
                }
            }


            // draw selection marks
            base.Paint(context);
        }
Beispiel #20
0
        public override void Paint(MNPageContext context)
        {
            //Debugger.Log(0, "", "-- paint selection control -- Horizontal:" + bHorizontal + "\n");
            SMStatusLayout layout = PrepareBrushesAndPens();

            PrepareContent(context);

            Rectangle r = Area.GetBounds(context);

            Font  font      = GetUsedFont();
            Brush backBrush = null;
            Brush foreBrush = null;
            int   radius    = 15;

            if (bHorizontal)
            {
                int width = 1;
                foreach (SelText st in texts)
                {
                    width += st.size.Width;
                }

                int index   = 0;
                int currPos = r.Left;
                foreach (SelText st in texts)
                {
                    int thisWidth = r.Width * st.size.Width / width;
                    layout    = (p_currSelection == index ? SMGraphics.clickableLayoutH : SMGraphics.clickableLayoutN);
                    backBrush = SMGraphics.GetBrush(layout.BackColor);
                    foreBrush = SMGraphics.GetBrush(layout.ForeColor);

                    if (index == 0)
                    {
                        context.g.FillEllipse(backBrush, r.Left, r.Top, radius * 2, radius * 2);
                        context.g.FillEllipse(backBrush, r.Left, r.Bottom - radius * 2, radius * 2, radius * 2);
                        context.g.FillRectangle(backBrush, r.Left, r.Top + radius, radius, r.Height - 2 * radius);
                    }
                    else
                    {
                        context.g.FillRectangle(backBrush, currPos, r.Top, radius, r.Height);
                    }

                    if (index == texts.Count - 1)
                    {
                        context.g.FillEllipse(backBrush, r.Right - radius * 2, r.Top, radius * 2, radius * 2);
                        context.g.FillEllipse(backBrush, r.Right - radius * 2, r.Bottom - radius * 2, radius * 2, radius * 2);
                        context.g.FillRectangle(backBrush, currPos + thisWidth - radius, r.Top + radius,
                                                r.Right - (currPos + thisWidth - radius), r.Height - 2 * radius);
                    }
                    else
                    {
                        context.g.FillRectangle(backBrush, currPos + thisWidth - radius, r.Top, radius, r.Height);
                    }

                    context.g.FillRectangle(backBrush, currPos + radius, r.Top, thisWidth - 2 * radius, r.Height);

                    if (index > 0)
                    {
                        context.g.DrawLine(tempForePen, currPos, r.Top, currPos, r.Bottom);
                    }

                    Rectangle rt = new Rectangle();
                    rt.X      = currPos;
                    rt.Y      = r.Top;
                    rt.Width  = thisWidth;
                    rt.Height = r.Height;
                    context.g.DrawString(st.text, font, foreBrush, rt, SMGraphics.StrFormatCenter);
                    st.drawRect = rt;

                    currPos += thisWidth;
                    index++;
                }
            }
            else
            {
                int height = 1;
                foreach (SelText st in texts)
                {
                    height += st.size.Height;
                }

                int index   = 0;
                int currPos = r.Top;
                //Debugger.Log(0, "", "--- selection control ---\n");
                foreach (SelText st in texts)
                {
                    int thisHeight = r.Height * st.size.Height / height;
                    layout    = (p_currSelection == index ? SMGraphics.clickableLayoutH : SMGraphics.clickableLayoutN);
                    backBrush = SMGraphics.GetBrush(layout.BackColor);
                    foreBrush = SMGraphics.GetBrush(layout.ForeColor);

                    if (index == 0)
                    {
                        context.g.FillEllipse(backBrush, r.Left, r.Top, radius * 2, radius * 2);
                        context.g.FillEllipse(backBrush, r.Right - radius * 2, r.Top, radius * 2, radius * 2);
                        context.g.FillRectangle(backBrush, r.Left + radius, r.Top, r.Width - 2 * radius, radius);
                    }
                    else
                    {
                        context.g.FillRectangle(backBrush, r.Left, currPos, r.Width, radius);
                    }

                    if (index == texts.Count - 1)
                    {
                        context.g.FillEllipse(backBrush, r.Left, r.Bottom - radius * 2, radius * 2, radius * 2);
                        context.g.FillEllipse(backBrush, r.Right - radius * 2, r.Bottom - radius * 2, radius * 2, radius * 2);
                        context.g.FillRectangle(backBrush, r.Left + radius, currPos + thisHeight - radius,
                                                r.Width - 2 * radius, r.Bottom - (currPos + thisHeight - radius));
                    }
                    else
                    {
                        context.g.FillRectangle(backBrush, r.Left, currPos + thisHeight - radius, r.Width, radius);
                    }

                    context.g.FillRectangle(backBrush, r.Left, currPos + radius, r.Width, thisHeight - 2 * radius);

                    if (index > 0)
                    {
                        context.g.DrawLine(tempForePen, r.Left, currPos, r.Right, currPos);
                    }

                    Rectangle rt = new Rectangle();
                    rt.X      = r.Left;
                    rt.Y      = currPos;
                    rt.Width  = r.Width;
                    rt.Height = thisHeight;
                    context.g.DrawString(st.text, font, foreBrush, rt, SMGraphics.StrFormatCenter);
                    st.drawRect = rt;

                    currPos += thisHeight;
                    index++;
                }
            }

            context.g.DrawRoundedRectangle(tempForePen, r, radius);

            // in case this is wrongly checked, run clearing the state in 2 secs
            if (UIStateError == MNEvaluationResult.Incorrect && HasImmediateEvaluation)
            {
                if (Document.HasViewer)
                {
                    Document.Viewer.ScheduleCall(MNNotificationCenter.RectifyDelay, this, "clearCheck");
                }
            }

            base.Paint(context);
        }
Beispiel #21
0
 public override void Paint(MNPageContext context, SMStatusLayout layout, int X, int Y)
 {
     //context.g.FillRectangle(Brushes.LightGreen, rect);
     context.g.DrawString(this.text, this.WinFont, GetCurrentTextBrush(layout), rect.X + X, rect.Y + Y + this.lineOffset * rect.Height / 100);
 }
Beispiel #22
0
 public void DrawString(MNPageContext context, SMStatusLayout layout, string plainText, Rectangle textBounds)
 {
     DrawString(context, layout, plainText, textBounds, 0);
 }
Beispiel #23
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;
            }
        }
Beispiel #24
0
        public override void Paint(MNPageContext context)
        {
            Rectangle rect = Area.GetBounds(context);
            //SizeF offset = SizeF.Empty;

            SMStatusLayout layout = PrepareBrushesAndPens();

            Font usedFont = GetUsedFont();

            CalcCells(context.g, usedFont, rect);

            if (DrawnObjects.Count < Objects.Count)
            {
                MixObjects(context.drawSelectionMarks);
            }

            bool enabledBorder = true;

            List <int> drw = DrawnObjects;

            if (moveTapIndex >= 0)
            {
                drw = new List <int>();
                drw.AddRange(DrawnObjects);

                int a = drw[startTapIndex];
                drw.RemoveAt(startTapIndex);
                drw.Insert(moveTapIndex, a);
            }

            float     floating_offset = 0;
            Rectangle r, showRect;
            int       j = 0;
            Point     lastPoint = context.PhysicalToLogical(context.lastClientPoint);

            for (int i = 0; i < drw.Count; i++, j++)
            {
                int objectIndex;

                if (moveTapIndex >= 0 && moveTapIndex == j)
                {
                    objectIndex = startObjectIndex;
                }
                else
                {
                    objectIndex = drw[j];
                    if (objectIndex == startObjectIndex)
                    {
                        j++;
                        objectIndex = drw[j];
                    }
                }


                StringItem obj = Objects[objectIndex];

                r          = obj.Rectangle;
                r.Location = rect.Location;
                if (Orientation == SMTextDirection.Horizontal)
                {
                    r.X += (int)floating_offset;
                }
                else
                {
                    r.Y += (int)floating_offset;
                }
                r.Inflate(-3, -3);
                showRect = r;
                showRect.Inflate(-3, -3);

                // draw object
                DrawListItem(context, layout, usedFont, showRect, i == 0, obj);


                // move floating offset
                if (Orientation == SMTextDirection.Horizontal)
                {
                    floating_offset += obj.ItemWidth;
                }
                else
                {
                    floating_offset += obj.ItemHeight;
                }

                // draw a border
                Brush br;

                if (objectIndex == i && enabledBorder && startTapIndex < 0)
                {
                    if (objectIndex == startObjectIndex)
                    {
                        br = Brushes.BlueViolet;
                    }
                    else
                    {
                        br = Brushes.Green;
                    }
                }
                else
                {
                    if (objectIndex == startObjectIndex)
                    {
                        br = Brushes.BlueViolet;
                    }
                    else
                    {
                        br = Brushes.Gainsboro;
                    }
                    enabledBorder = false;
                }

                context.g.FillRectangle(br, r.X, r.Y, 3, r.Height);
                context.g.FillRectangle(br, r.X, r.Y, r.Width, 3);
                context.g.FillRectangle(br, r.Right - 3, r.Y, 3, r.Height);
                context.g.FillRectangle(br, r.X, r.Bottom - 3, r.Width, 3);
            }

            if (startObjectIndex >= 0)
            {
                showRect = new Rectangle(lastPoint.X - startObjectWidth,
                                         lastPoint.Y - startObjectHeight, startObjectWidth * 2, startObjectHeight * 2);
                context.g.DrawRectangle(Pens.BlueViolet, showRect);
                DrawListItem(context, layout, usedFont, showRect, false, Objects[startObjectIndex]);
            }

            base.Paint(context);
        }
Beispiel #25
0
 public override void Paint(MNPageContext context, SMStatusLayout layout, int X, int Y)
 {
     context.g.DrawImage(image, rect.X + X, rect.Y + Y, rect.Width, rect.Height);
 }
Beispiel #26
0
 public virtual Brush GetCurrentTextBrush(SMStatusLayout layout)
 {
     return(SMGraphics.GetBrush(layout.ForeColor));
 }
Beispiel #27
0
        public override void Paint(MNPageContext context)
        {
            SMRectangleArea area   = this.Area;
            Rectangle       bounds = area.GetBounds(context);

            SMConnection conn = context.CurrentPage.FindConnection(this);

            if (conn != null)
            {
                UIStateHover = true;
            }


            bool b = UIStateHover;

            UIStateHover |= SwitchStatus;
            SMStatusLayout layout = PrepareBrushesAndPens();

            UIStateHover = b;

            Rectangle boundsA = bounds;

            boundsA.Y       = Math.Max(0, bounds.Top);
            boundsA.X       = Math.Max(0, bounds.Left);
            boundsA.Width   = Math.Min(context.PageWidth, bounds.Right);
            boundsA.Height  = Math.Min(context.PageHeight, bounds.Bottom);
            boundsA.Width  -= boundsA.X;
            boundsA.Height -= boundsA.Y;

            Rectangle textBounds = ContentPadding.ApplyPadding(boundsA);

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

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

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

            Font usedFont = GetUsedFont();

            if (plainText != null)
            {
                Size      textSize = richText.MeasureString(context, plainText, textBounds.Width);
                Rectangle r        = Area.GetDockedRectangle(context.PageSize, 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.None)
                {
                    DrawStyledBackground(context, layout, bounds);
                }
                else if (Area.BackType == SMBackgroundType.Solid)
                {
                    context.g.FillRectangle(SMGraphics.GetBrush(Page.BackgroundColor), r);
                }
                else if (Area.BackType == SMBackgroundType.Shadow && Area.BackgroundImage != null)
                {
                    context.g.DrawImage(Area.BackgroundImage,
                                        textBounds.X + Area.BackgroundImageOffset.X,
                                        textBounds.Y + Area.BackgroundImageOffset.Y);
                }

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

                richText.DrawString(context, layout, textBounds);
            }
            else if (runningText != null)
            {
                DrawStyledBackground(context, layout, bounds);
                DrawStyledBorder(context, layout, bounds);

                Point curr  = new Point(textBounds.Left, textBounds.Top);
                int   index = 0;
                foreach (GOFRunningTextItem w in runningText.Words)
                {
                    Brush currBrush = (runningText.currentWord >= index ? Brushes.Red : tempForeBrush);
                    SizeF textSize  = context.g.MeasureString(w.Text, usedFont);
                    if (curr.X + textSize.Width > textBounds.Right)
                    {
                        curr.X  = textBounds.Left;
                        curr.Y += (int)textSize.Height;
                    }
                    context.g.DrawString(w.Text, usedFont, currBrush, curr);
                    curr.X += (int)textSize.Width;

                    index++;
                }
            }

            if (UIStateError == MNEvaluationResult.Incorrect && UIStateChecked)
            {
                if (Document.HasViewer)
                {
                    Document.Viewer.ScheduleCall(MNNotificationCenter.RectifyDelay, this, "clearCheck");
                }
            }

            // draw selection marks
            base.Paint(context);
        }