private Rectangle DrawNavigationButtons(MNPageContext context, Rectangle textBounds) { context.g.DrawLine(SMGraphics.GetPen(NormalState.ForeColor, 1), textBounds.Left, textBounds.Bottom, textBounds.Right, textBounds.Bottom); if (HasPrevPage()) { prevBtnRect = new Rectangle(textBounds.Left, textBounds.Bottom, textBounds.Width / 2 - 32, navigButtonsHeight); if (prevBtnPressed) { context.g.FillRectangle(SMGraphics.GetBrush(Color.LightGreen), prevBtnRect); } context.g.DrawString("< PREV", SMGraphics.GetFontVariation(SystemFonts.MenuFont, 20f), SMGraphics.GetBrush(Color.Gray), prevBtnRect, SMGraphics.StrFormatCenter); } if (HasNextPage()) { nextBtnRect = new Rectangle(textBounds.Left + textBounds.Width / 2 + 32, textBounds.Bottom, textBounds.Width / 2 - 32, navigButtonsHeight); if (nextBtnPressed) { context.g.FillRectangle(SMGraphics.GetBrush(Color.LightGreen), nextBtnRect); } context.g.DrawString("NEXT >", SMGraphics.GetFontVariation(SystemFonts.MenuFont, 20f), SMGraphics.GetBrush(Color.Gray), nextBtnRect, SMGraphics.StrFormatCenter); } context.g.DrawString(string.Format("{0}/{1}", CurrentPage + 1, PageCount), SMGraphics.GetFontVariation(SystemFonts.MenuFont, 20f), SMGraphics.GetBrush(Color.Gray), new Rectangle(textBounds.Left + textBounds.Width / 2 - 48, textBounds.Bottom, 96, navigButtonsHeight), SMGraphics.StrFormatCenter); return(textBounds); }
/// <summary> /// /// </summary> /// <param name="graphics"></param> /// <param name="rect">Absolute value</param> /// <param name="x">Relative value</param> /// <param name="y">Relative value</param> /// <param name="c"></param> public void PaintPoint(Graphics graphics, Rectangle rect, int x, int y, Color c) { int xa = rect.X + Convert.ToInt32(rect.Width * x / 100.0); int ya = rect.Y + Convert.ToInt32(rect.Height * y / 100.0); graphics.FillRectangle(SMGraphics.GetBrush(c), xa - 6, ya - 6, 12, 12); }
private void DrawCard(MNPageContext context, Rectangle rect, MNReferencedImage image) { Size imgSize = SMGraphics.GetMaximumSize(rect, image.ImageData.Size); context.g.DrawImage(image.ImageData, rect.X + rect.Width / 2 - imgSize.Width / 2, rect.Y + rect.Height / 2 - imgSize.Height / 2, imgSize.Width, imgSize.Height); }
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); }
private Rectangle DrawColumnSeparators(MNPageContext context, Rectangle textBounds) { Pen pen = SMGraphics.GetPen(NormalState.ForeColor, 1); for (int i = 1; i < Columns; i++) { int x = textBounds.Left + i * textBounds.Width / Columns; int y = textBounds.Top; int y2 = textBounds.Bottom; if (ShowNavigationButtons) { y2 -= navigButtonsHeight; } int cy = y; switch (ColumnSeparatorStyle) { case SMLineStyle.Plain: context.g.DrawLine(pen, x, y, x, y2); break; case SMLineStyle.Dashed: while (cy + 16 < y2) { context.g.DrawLine(pen, x, cy, x, cy + 16); cy += 24; } break; case SMLineStyle.Doted: while (cy + 3 < y2) { context.g.DrawRectangle(pen, x, cy, 2, 2); cy += 8; } break; case SMLineStyle.ZigZag: while (cy + 16 < y2) { context.g.DrawLine(pen, x, cy, x - 4, cy + 4); context.g.DrawLine(pen, x - 4, cy + 4, x + 4, cy + 12); context.g.DrawLine(pen, x + 4, cy + 12, x, cy + 16); cy += 16; } break; } } return(textBounds); }
public MNPageContext() { redConstraintTrack = new Pen(Color.Red, 3); LastMatrix = new Matrix(); LastInvertMatrix = new Matrix(); CurrentPage = null; HintFont = new Font(FontFamily.GenericSansSerif, 9); MenuFont = SMGraphics.GetFontVariation(MNFontName.GilSansMurari, 18); MenuTitleFont = new Font(FontFamily.GenericSansSerif, 24); DragItemFont = new Font(FontFamily.GenericSansSerif, 35); PageTitleFont = new Font(FontFamily.GenericSansSerif, 20, FontStyle.Italic); semitransparentGrayBrush = new SolidBrush(Color.FromArgb(128, Color.Gray)); messageBox = new SMTitledMessage(CurrentPage); SpotAreaBorderPen = new Pen(Color.LightBlue, 3); }
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); } } }
public override void Paint(MNPageContext context) { Rectangle bounds = Area.GetBounds(context); Rectangle textBounds = bounds; Pen currentPen; // background image is drawn centered if (BackgroundImage != null) { BackgroundImageRect = new Rectangle(textBounds.Location, SMGraphics.GetMaximumSize(textBounds, BackgroundImage.ImageData.Size)); BackgroundImageRect.Offset((textBounds.Width - BackgroundImageRect.Width) / 2, (textBounds.Height - BackgroundImageRect.Height) / 2); context.g.DrawImage(BackgroundImage.ImageData, BackgroundImageRect); } /*context.g.DrawRectangle(Pens.Gray, textBounds.Right - 16, textBounds.Bottom - 48, 16, 16); * context.g.DrawRectangle(Pens.Gray, textBounds.Right - 16, textBounds.Bottom - 32, 16, 16); * context.g.DrawRectangle(Pens.Gray, textBounds.Right - 16, textBounds.Bottom - 16, 16, 16);*/ context.g.DrawRectangle(Pens.Black, textBounds); if (!context.drawSelectionMarks) { foreach (DrawPoints dp in drawPoints) { currentPen = SMGraphics.GetPen(dp.penColor, dp.penWidth); context.g.DrawLines(currentPen, dp.pts); } if (tempPoints.pts.Count > 1) { currentPen = SMGraphics.GetPen(tempPoints.penColor, tempPoints.penWidth); context.g.DrawLines(currentPen, tempPoints.pts.ToArray <Point>()); } } // draw selection marks base.Paint(context); }
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); }
public override void Paint(MNPageContext context) { Rectangle rect = Area.GetBounds(context); Brush keyBack = Brushes.LightGray; Brush keyPress = Brushes.Blue; float ax = rect.Width / 100f; float ay = rect.Height / 28f; Font font = SMGraphics.GetFontVariation(SystemFonts.DefaultFont, 4 * Math.Min(ax, ay)); PointF origin = new PointF(rect.X + rect.Width / 2 - 50 * ax, rect.Y + rect.Height / 2 - 14 * ay); Brush textBrush = Brushes.Black; Brush textPressBrush = Brushes.White; foreach (SMKeyboardKey key in Keys) { key.PaintedRect = new RectangleF(key.X * ax + origin.X, key.Y * ay + origin.Y, key.Width * ax, key.Height * ay); Rectangle r = new Rectangle((int)key.PaintedRect.X, (int)key.PaintedRect.Y, (int)key.PaintedRect.Width, (int)key.PaintedRect.Height); context.g.FillRectangle(key.Pressed ? keyPress : keyBack, r); if (key.Image != null) { float b = Math.Min(key.PaintedRect.Width / key.Image.Width, key.PaintedRect.Height / key.Image.Height); b *= 0.7f; Rectangle r2 = new Rectangle(Convert.ToInt32(key.PaintedRect.X + key.PaintedRect.Width / 2), Convert.ToInt32(key.PaintedRect.Y + key.PaintedRect.Height / 2), Convert.ToInt32(b * key.Image.Width), Convert.ToInt32(b * key.Image.Height)); r2.X -= r2.Width / 2; r2.Y -= r2.Height / 2; context.g.DrawImage(key.Image, r2); } else { context.g.DrawString(key.Key, font, key.Pressed ? textPressBrush : textBrush, r, p_sf); } } base.Paint(context); }
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)); } } }
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); 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) { //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); }
public virtual Brush GetCurrentTextBrush(SMStatusLayout layout) { return(SMGraphics.GetBrush(layout.ForeColor)); }
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 SMFont GetFont() { return(SMGraphics.GetVirtFontVariation(fontName, fontSize, Bold, Italic, Underline, Strikeout)); }
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); }