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); }
public override void Paint(MNPageContext context) { Rectangle bounds = Area.GetBounds(context); Rectangle textBounds = ContentPadding.ApplyPadding(bounds); SMStatusLayout layout; if (IsDraggable()) { SMDragResponse dr = Draggable; Draggable = SMDragResponse.None; layout = PrepareBrushesAndPens(); Draggable = dr; } else { layout = PrepareBrushesAndPens(); } DrawStyledBackground(context, layout, bounds); DrawStyledBorder(context, layout, bounds); string stext = Text; if (Content != null) { if (Content is MNReferencedText) { stext = (Content as MNReferencedText).Text; } } if (!p_prevText.Equals(stext)) { Text = stext; p_prevText = stext; SplitTextToWords(stext); } if (drawWordsModified) { RecalculateWordsLayout(context, textBounds.Size, drawWords); drawWordsModified = false; } context.g.DrawRectangle(Pens.Black, textBounds); PaintPageNo(context, IsDraggable() ? SMGraphics.draggableLayoutN : layout, textBounds.X, textBounds.Y); // draw selection marks base.Paint(context); }
public override void Paint(MNPageContext context) { Rectangle bounds = Area.GetBounds(context); Rectangle boundsWithoutNavigation = bounds; if (ShowNavigationButtons) { boundsWithoutNavigation.Height -= navigButtonsHeight; } Rectangle textBounds = ContentPadding.ApplyPadding(bounds); SMStatusLayout layout; SMConnectionCardinality scard = Cardinality; if (UIStateHover && DropablesCount == 1) { Cardinality = SMConnectionCardinality.One; } layout = PrepareBrushesAndPens(); Cardinality = scard; DrawStyledBackground(context, layout, bounds); DrawStyledBorder(context, layout, bounds); string stext = Text; if (Content != null) { if (Content is MNReferencedText) { stext = (Content as MNReferencedText).Text; } } if (!p_prevText.Equals(stext)) { Text = stext; p_prevText = stext; } if (drawWordsModified) { Rectangle layoutBounds = textBounds; if (ShowNavigationButtons) { layoutBounds.Height -= navigButtonsHeight; } SMRichLayout lay = null; lay = RecalculateWordsLayout(context, layoutBounds, drawWords, this, RunningLine, Columns); drawLines = lay.Lines; PageCount = lay.Pages; DropablesCount = lay.DropablesCount; drawWordsModified = false; } PaintPageNo(context, layout, CurrentPage, textBounds.X, textBounds.Y); if (ShowNavigationButtons) { textBounds = DrawNavigationButtons(context, boundsWithoutNavigation); } if (Columns > 1) { textBounds = DrawColumnSeparators(context, textBounds); } // draw selection marks base.Paint(context); }
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); }
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>"); }
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); }
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); }
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); }
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; } }
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); }
public override void Paint(MNPageContext context) { Rectangle bounds = Area.GetBounds(context); Rectangle textBounds = ContentPadding.ApplyPadding(bounds); if (p_prevHighColor != HighlightColor) { p_prevHighColor = HighlightColor; p_prevHighBrush = new SolidBrush(HighlightColor); } 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); for (int i = 0; i < Columns; i++) { for (int i2 = 0; i2 < Rows; i2++) { p_cellStatus[i, i2] = false; } } } SizeF sizeChar = context.g.MeasureString("M", Font.Font); float cellSize = Math.Max(sizeChar.Height, sizeChar.Width); float targetCellSize = Math.Min((textBounds.Width - (Columns + 1) * Spacing) / Columns, (textBounds.Height - (Rows + 1) * Spacing) / Rows); // recalculate actuall size for puzzle textBounds.Height = (int)(targetCellSize * Rows + Spacing * Rows + Spacing); textBounds.Width = (int)(targetCellSize * Columns + Spacing * Columns + Spacing); // recalculate border bounds = ContentPadding.ApplyPadding(textBounds); context.g.DrawRectangle(Pens.Black, bounds); // recalculate size of font Font usedFont = Font.Font; if (targetCellSize > 0.1f) { usedFont = SMGraphics.GetFontVariation(Font.Name, Font.Size * targetCellSize / cellSize); } int index = 0; // prepare rectangle for letter Rectangle rect = new Rectangle(); rect.Width = (int)targetCellSize; rect.Height = (int)targetCellSize; // prepare text formating StringFormat format = new StringFormat(); format.Alignment = StringAlignment.Center; format.LineAlignment = StringAlignment.Center; p_cellSize = (int)targetCellSize; // drawing letters for (int r = 0; r < Rows; r++) { for (int c = 0; c < Columns; c++) { rect.X = Convert.ToInt32(c * targetCellSize + (c + 1) * Spacing) + textBounds.X; rect.Y = Convert.ToInt32(r * targetCellSize + (r + 1) * Spacing) + textBounds.Y; string s = p_alignedText.Substring(index, 1); index++; if (p_cellStatus[c, r]) { context.g.FillRectangle(p_prevHighBrush, rect); } if (UIStateError == MNEvaluationResult.Incorrect) { if (p_cellStatus[c, r] != p_cellExpectedStatus[c, r]) { context.g.DrawString(s, usedFont, Brushes.Gray, rect, format); } else { context.g.DrawString(s, usedFont, Brushes.Black, rect, format); } } else { context.g.DrawString(s, usedFont, Brushes.Black, rect, format); } } } // draw selection marks base.Paint(context); }
public Rectangle GetCellRect(MNPageContext ctx, int row, int column, Size cellSize) { Rectangle r = new Rectangle(column * cellSize.Width, row * cellSize.Height, cellSize.Width, cellSize.Height); return(ContentPadding.ApplyPadding(r)); }