public void Paint(MNPageContext context) { if (Source == null || Target == null) { return; } SMRectangleArea sa = Source.Area; SMRectangleArea ta = Target.Area; Rectangle rs = sa.GetBounds(context); Rectangle rt = ta.GetBounds(context); Point sc = Point.Empty; Point tc = Point.Empty; if (Source.DragLineAlign == SMDragLineAlign.Undef) { if (Source.NormalState.BorderStyle == SMBorderStyle.Elipse) { sc = IntersectionPointLineElipse(rs, CenterPoint(rt)); } else { sc = IntersectionPointLineRect(rs, CenterPoint(rt)); } } else if (Source.DragLineAlign == SMDragLineAlign.LeftRight) { if (rs.Left > rt.Right) { sc = new Point(rs.Left, rs.Top + rs.Height / 2); } else { sc = new Point(rs.Right, rs.Top + rs.Height / 2); } } else if (Source.DragLineAlign == SMDragLineAlign.TopBottom) { if (rs.Top > rt.Bottom) { sc = new Point(rs.Left + rs.Width / 2, rs.Top); } else { sc = new Point(rs.Left + rs.Width / 2, rs.Bottom); } } if (Target.DragLineAlign == SMDragLineAlign.LeftRight) { if (rs.Left < rt.Right) { tc = new Point(rt.Left, rt.Top + rt.Height / 2); } else { tc = new Point(rt.Right, rt.Top + rt.Height / 2); } } else if (Target.DragLineAlign == SMDragLineAlign.TopBottom) { if (rs.Top < rt.Bottom) { tc = new Point(rt.Left + rt.Width / 2, rt.Top); } else { tc = new Point(rt.Left + rt.Width / 2, rt.Bottom); } } else { if (Target.NormalState.BorderStyle == SMBorderStyle.Elipse) { tc = IntersectionPointLineElipse(rt, CenterPoint(rs)); } else { tc = IntersectionPointLineRect(rt, CenterPoint(rs)); } } switch (ConnectionStyle) { default: context.g.DrawLine(Pens.Black, sc, tc); 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); }