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