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