public Resources(string fontFamily, float fontSize, float dpiSensitivePensScale = 1f) { this.UserActionBrush = new LJD.Brush(Color.LightSalmon); this.StateChangeBrush = new LJD.Brush(Color.FromArgb(0xff, Color.FromArgb(0xC8F6C8))); this.UserActionFramePen = new LJD.Pen(Color.Gray, 1); this.BookmarkArrowBackgroundBrush = new LJD.Brush(Color.FromArgb(0xff, Color.FromArgb(0xE3EDFF))); this.BookmarkArrowPen = new LJD.Pen(Color.Gray, 1); this.SelectedLineColor = Color.FromArgb(187, 196, 221); this.SelectedLineBrush = new LJD.Brush(SelectedLineColor); this.ControlBackgroundBrush = new LJD.Brush(Color.White); this.Font = new LJD.Font(fontFamily, fontSize); this.UnderlinedFont = new LJD.Font(fontFamily, fontSize, FontStyle.Underline); this.RolePen = new LJD.Pen(Color.Black, 2 * dpiSensitivePensScale); this.RoleCaptionFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Center, LineBreakMode.WrapChars); float normalLineWidth = 1 * dpiSensitivePensScale; this.RequestPen = new LJD.Pen(Color.Black, normalLineWidth); this.ResponsePen = new LJD.Pen(Color.Black, normalLineWidth, dashPattern: new float[] { 5, 2 }); float highlightedLineWidth = (float)Math.Ceiling(2f * dpiSensitivePensScale); this.HighlightedRequestPen = new LJD.Pen(Color.Black, highlightedLineWidth); this.HighlightedResponsePen = new LJD.Pen(Color.Black, highlightedLineWidth, dashPattern: new float[] { 5 * normalLineWidth / highlightedLineWidth, 2 * normalLineWidth / highlightedLineWidth }); this.CaptionRectPen = new LJD.Pen(Color.Black, 1); this.LinkCaptionBrush = new LJD.Brush(Color.Blue); this.NoLinkCaptionBrush = new LJD.Brush(Color.Black); this.ExecutionOccurrencePen = new LJD.Pen(Color.Black, 1); this.HighlightedExecutionOccurrencePen = new LJD.Pen(Color.Black, highlightedLineWidth); this.NormalExecutionOccurrenceBrush = new LJD.Brush(Color.LightGray); this.NormalHighlightedExecutionOccurrenceBrush = new LJD.Brush(Color.DarkGray); this.ActivityExecutionOccurrenceBrush = new LJD.Brush(Color.LightBlue); this.ActivityHighlightedExecutionOccurrenceBrush = this.ActivityExecutionOccurrenceBrush; //new LJD.Brush(Color.FromArgb(0xff, Color.FromArgb(0x8DB8C6))); this.NormalArrowTextBrush = new LJD.Brush(Color.Black); this.ErrorArrowTextBrush = new LJD.Brush(Color.Red); this.ArrowTextFormat = new LJD.StringFormat(StringAlignment.Near, StringAlignment.Far, LineBreakMode.SingleLineEndEllipsis); this.UserActionTextFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Far, LineBreakMode.SingleLineEndEllipsis); this.TimeDeltaFormat = new LJD.StringFormat(StringAlignment.Far, StringAlignment.Center); this.ArrowEndShapePoints = new [] { new PointF(-5, -4), new PointF(-5, +4), new PointF(0, 0) }; this.DpiScale = dpiSensitivePensScale; }
public Resources(string fontName, float fontBaseSize, LJD.Image bookmarkIcon) { AxesFont = new LJD.Font(fontName, fontBaseSize); AxesPen = LJD.Pens.DarkGray; XAxisPointLabelFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Far); YAxisPointLabelFormat = new LJD.StringFormat(StringAlignment.Far, StringAlignment.Center); YAxisLabelFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Far); DataPointLabelBrush = LJD.Brushes.Text; var bmkColor = Color.FromArgb(0x5b, 0x87, 0xe0); BookmarkPen = new LJD.Pen(bmkColor, 1); BookmarkBrush = new LJD.Brush(bmkColor); BookmarkIcon = bookmarkIcon; EventTextFont = new LJD.Font(fontName, fontBaseSize * 0.8f); EventTextFormat = new LJD.StringFormat(StringAlignment.Far, StringAlignment.Far); ParsedEventPen = new LJD.Pen(Color.Red, 1); ParsedEventBrush = new LJD.Brush(Color.Red); GroupCaptionFont = EventTextFont; ParsedEventsGroupBrush = new LJD.Brush(Color.FromArgb(100, Color.Red)); BookmarksGroupGrush = new LJD.Brush(Color.FromArgb(100, Color.Blue)); }
public Resources( IViewModel viewModel, string fontFamily, float fontSize, float dpiSensitivePensScale = 1f) { bool isDark() => viewModel.ColorTheme == Presenters.ColorThemeMode.Dark; this.UserActionBrush = new LJD.Brush(Color.LightSalmon); this.StateChangeBrush = new LJD.Brush(Color.FromArgb(0xff, Color.FromArgb(0xC8F6C8))); this.UserActionFramePen = new LJD.Pen(Color.Gray, 1); this.bookmarkArrowBackgroundBrush = Selectors.Create( isDark, dark => new LJD.Brush(dark ? Color.FromArgb(0, 31, 39) : Color.FromArgb(0xff, Color.FromArgb(0xE3EDFF))) ); this.bookmarkArrowPen = Selectors.Create( isDark, dark => new LJD.Pen(dark ? Color.LightGray : Color.Gray, 1) ); this.selectedLineBrushSelector = Selectors.Create( isDark, dark => dark ? new Brush(Color.FromArgb(40, 80, 120)) : new Brush(Color.FromArgb(167, 176, 201)) ); this.ControlBackgroundBrush = Brushes.TextBackground; this.Font = new LJD.Font(fontFamily, fontSize); this.UnderlinedFont = new LJD.Font(fontFamily, fontSize, FontStyle.Underline); this.RolePen = new LJD.Pen(SystemColors.Text, 2 * dpiSensitivePensScale); this.RoleCaptionFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Center, LineBreakMode.WrapChars); float normalLineWidth = 1 * dpiSensitivePensScale; this.RequestPen = new LJD.Pen(SystemColors.Text, normalLineWidth); this.ResponsePen = new LJD.Pen(SystemColors.Text, normalLineWidth, dashPattern: new float[] { 5, 2 }); float highlightedLineWidth = (float)Math.Ceiling(2f * dpiSensitivePensScale); this.HighlightedRequestPen = new LJD.Pen(SystemColors.Text, highlightedLineWidth); this.HighlightedResponsePen = new LJD.Pen(SystemColors.Text, highlightedLineWidth, dashPattern: new float[] { 5 * normalLineWidth / highlightedLineWidth, 2 * normalLineWidth / highlightedLineWidth }); this.CaptionRectPen = new LJD.Pen(SystemColors.Text, 1); this.LinkCaptionBrush = new LJD.Brush(SystemColors.Link); this.NoLinkCaptionBrush = new LJD.Brush(SystemColors.Text); this.ExecutionOccurrencePen = new LJD.Pen(SystemColors.Text, 1); this.HighlightedExecutionOccurrencePen = new LJD.Pen(SystemColors.Text, highlightedLineWidth); this.normalExecutionOccurrenceBrush = Selectors.Create( isDark, dark => new LJD.Brush(dark ? Color.FromArgb(100, 100, 100) : Color.LightGray) ); this.normalHighlightedExecutionOccurrenceBrush = Selectors.Create( isDark, dark => new LJD.Brush(dark ? Color.FromArgb(150, 150, 150) : Color.DarkGray) ); this.ActivityExecutionOccurrenceBrush = new LJD.Brush(Color.LightBlue); this.ActivityHighlightedExecutionOccurrenceBrush = this.ActivityExecutionOccurrenceBrush; this.NormalArrowTextBrush = Brushes.Text; this.ErrorArrowTextBrush = new LJD.Brush(Color.Red); this.ArrowTextFormat = new LJD.StringFormat(StringAlignment.Near, StringAlignment.Far, LineBreakMode.SingleLineEndEllipsis); this.UserActionTextFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Far, LineBreakMode.SingleLineEndEllipsis); this.TimeDeltaFormat = new LJD.StringFormat(StringAlignment.Far, StringAlignment.Center); this.ArrowEndShapePoints = new [] { new PointF(-5, -4), new PointF(-5, +4), new PointF(0, 0) }; this.DpiScale = dpiSensitivePensScale; }
public void DrawArrowsView(LJD.Graphics g, Size viewSize, Action <Rectangle> drawFocusRect) { foreach (var message in eventsHandler.ArrowsDrawInfo) { if (!message.IsFullyVisible) { continue; } if (message.SelectionState != ArrowSelectionState.NotSelected) { int y = message.Y; int h = message.Height; var r = new Rectangle( 0, y - h + 2, viewSize.Width, h - 2 ); g.FillRectangle(resources.SelectedLineBrush, r); if (message.SelectionState == ArrowSelectionState.FocusedSelectedArrow) { drawFocusRect(r); } } } foreach (var role in eventsHandler.RolesDrawInfo) { var x = role.X; g.DrawLine(resources.RolePen, x, 0, x, viewSize.Height); foreach (var eo in role.ExecutionOccurrences) { LJD.Brush fillBrush; if (eo.DrawMode == ExecutionOccurrenceDrawMode.Normal) { fillBrush = eo.IsHighlighted ? resources.NormalHighlightedExecutionOccurrenceBrush : resources.NormalExecutionOccurrenceBrush; } else if (eo.DrawMode == ExecutionOccurrenceDrawMode.Activity) { fillBrush = eo.IsHighlighted ? resources.ActivityHighlightedExecutionOccurrenceBrush : resources.ActivityExecutionOccurrenceBrush; } else { continue; } g.FillRectangle(fillBrush, eo.Bounds); g.DrawRectangle(eo.IsHighlighted ? resources.HighlightedExecutionOccurrencePen : resources.ExecutionOccurrencePen, eo.Bounds); } } Action <string, LJD.Brush, LJD.Brush, RectangleF> drawTextHelper = (str, back, fore, textRect) => { if (back != null) { var fillSz = g.MeasureString(str, resources.Font, resources.ArrowTextFormat, textRect.Size); var fillRect = new RectangleF(textRect.X, textRect.Y + 4, fillSz.Width, textRect.Height - 5); g.FillRectangle(back, fillRect); } g.DrawString(str, resources.Font, fore, textRect, resources.ArrowTextFormat); }; Action <PointF, bool> drawArrow = (pt, leftToRight) => { var pts = new List <PointF>(4); pts.Add(pt); foreach (var p in resources.ArrowEndShapePoints) { pts.Add(new PointF(pt.X + (leftToRight ? 1f : -1f) * p.X, pt.Y + p.Y)); } g.FillPolygon(resources.NormalArrowTextBrush, pts.ToArray()); }; foreach (var message in eventsHandler.ArrowsDrawInfo) { int y = message.Y; int x1 = message.FromX; int x2 = message.ToX; int h = message.Height; int w = message.Width; int padding = message.TextPadding; var backBrush = message.SelectionState != ArrowSelectionState.NotSelected ? resources.SelectedLineBrush : resources.ControlBackgroundBrush; var textBrush = message.Color == ArrowColor.Error ? resources.ErrorArrowTextBrush : resources.NormalArrowTextBrush; if (message.Mode == ArrowDrawMode.Arrow || message.Mode == ArrowDrawMode.DottedArrow) { var pen = !message.IsHighlighted ? (message.Mode == ArrowDrawMode.Arrow ? resources.RequestPen : resources.ResponsePen) : (message.Mode == ArrowDrawMode.Arrow ? resources.HighlightedRequestPen : resources.HighlightedResponsePen); if (x1 != x2) { if (message.IsFullyVisible) { drawTextHelper( message.DisplayName, backBrush, textBrush, new RectangleF( Math.Min(x1, x2) + padding, y - h, Math.Abs(x1 - x2) - padding * 2, h ) ); } var nonHorizontal = message.NonHorizontalDrawingData; if (nonHorizontal != null) { g.DrawLines( pen, new[] { new Point(x1, y), new Point(nonHorizontal.VerticalLineX, y), new Point(nonHorizontal.VerticalLineX, nonHorizontal.Y), new Point(nonHorizontal.ToX, nonHorizontal.Y) } ); drawArrow(new PointF(nonHorizontal.ToX, nonHorizontal.Y), x2 > x1); } else { if (message.IsFullyVisible) { g.DrawLine( pen, x1, y, x2, y ); drawArrow(new PointF(x2, y), x2 > x1); } } } else { var midY = y - h / 2; var loopW = 10; var loopH = 10; drawTextHelper( message.DisplayName, backBrush, textBrush, new RectangleF( x1 + loopW + padding, y - h, message.Width - (loopW + padding * 2), h ) ); g.DrawLines( pen, new[] { new Point(x1, midY - loopH / 2), new Point(x1 + loopW, midY - loopH / 2), new Point(x1 + loopW, midY + loopH / 2), new Point(x1, midY + loopH / 2), } ); drawArrow(new PointF(x1, midY + loopH / 2), false); } } else if (message.Mode == ArrowDrawMode.Bookmark) { if (!message.IsFullyVisible) { continue; } float radius = h / 4f; var textRect = new RectangleF( message.MinX - w / 2 + padding, y - h, (message.MaxX - message.MinX + w) - padding * 2, h ); var sz = g.MeasureString("ABC", resources.Font, resources.ArrowTextFormat, textRect.Size).ToSize(); var r = new RectangleF(textRect.X, y - sz.Height - 1, textRect.Width, sz.Height); r.Inflate(radius, 0); g.PushState(); g.EnableAntialiasing(true); g.FillRoundRectangle(resources.BookmarkArrowBackgroundBrush, r, radius); g.DrawRoundRectangle(resources.BookmarkArrowPen, r, radius); g.PopState(); SizeF q = new SizeF(3, 3).Scale(resources.DpiScale); if (x1 - q.Width > r.Left && x1 + q.Width < r.Right) { PointF[] pts; pts = new [] { new PointF(x1 - q.Width, r.Top + r.Height / 2), new PointF(x1 - q.Width, r.Top), new PointF(x1, r.Top - q.Height), new PointF(x1 + q.Width, r.Top), new PointF(x1 + q.Width, r.Top + r.Height / 2), }; g.FillPolygon(resources.BookmarkArrowBackgroundBrush, pts); g.DrawLines(resources.BookmarkArrowPen, pts.Skip(1).Take(3).ToArray()); pts = new [] { new PointF(x1 + q.Width, r.Bottom - r.Height / 2), new PointF(x1 + q.Width, r.Bottom), new PointF(x1, r.Bottom + q.Height), new PointF(x1 - q.Width, r.Bottom), new PointF(x1 - q.Width, r.Bottom - r.Height / 2), }; g.FillPolygon(resources.BookmarkArrowBackgroundBrush, pts); g.DrawLines(resources.BookmarkArrowPen, pts.Skip(1).Take(3).ToArray()); } drawTextHelper( message.DisplayName, null, textBrush, textRect ); } else if (message.Mode == ArrowDrawMode.UserAction || message.Mode == ArrowDrawMode.StateChange || message.Mode == ArrowDrawMode.APICall || message.Mode == ArrowDrawMode.ActivityLabel) { if (!message.IsFullyVisible) { continue; } var icon = message.Mode == ArrowDrawMode.UserAction ? resources.UserActionImage : null; float radius = h / 4f; var r = new RectangleF( x1 - (w - radius), y - h, (w - radius) * 2, h ); var sz = g.MeasureString(message.DisplayName, resources.Font, resources.UserActionTextFormat, r.Size); var szh = sz.Height; var boxRect = new RectangleF( x1 - sz.Width / 2, y - szh - 1, sz.Width, szh ); boxRect.Inflate(radius, 0); g.PushState(); g.EnableAntialiasing(true); LJD.Brush backgroundBrush = null; LJD.Pen strokePen = resources.UserActionFramePen; if (message.Mode == ArrowDrawMode.UserAction || message.Mode == ArrowDrawMode.APICall) { backgroundBrush = resources.UserActionBrush; } else if (message.Mode == ArrowDrawMode.StateChange) { backgroundBrush = resources.StateChangeBrush; } else if (message.Mode == ArrowDrawMode.ActivityLabel) { backgroundBrush = resources.ActivityExecutionOccurrenceBrush; if (message.IsHighlighted) { strokePen = resources.HighlightedExecutionOccurrencePen; } } g.FillRoundRectangle( backgroundBrush, boxRect, radius ); g.DrawRoundRectangle( strokePen, boxRect, radius ); g.PopState(); g.DrawString(message.DisplayName, resources.Font, textBrush, boxRect, resources.UserActionTextFormat); if (icon != null) { var iconsz = icon.GetSize(width: 10f).Scale(resources.DpiScale); g.DrawImage( icon, new RectangleF( (int)(boxRect.Left - iconsz.Width * 1.3f), (int)(boxRect.Y + (boxRect.Height - iconsz.Height) / 2), iconsz.Width, iconsz.Height ) ); } } } }
public static void DrawResizer(LJD.Graphics g, Rectangle bounds, LJD.Brush backgroundBrush) { g.FillRectangle(backgroundBrush, bounds); DrawEllipsis(g, bounds); }
public GraphicsResources( IViewModel viewModel, string fontName, float activitesCaptionsFontSize, float actionCaptionsFontSize, float rulerMarkFontSize, LJD.Image userIcon, LJD.Image apiIcon, LJD.Image bookmarkIcon, LJD.Image focusedMessageLineTop, float pensScale, LJD.Brush systemControlBrush ) { bool isDark() => viewModel.ColorTheme == Presenters.ColorThemeMode.Dark; ActivitesCaptionsFont = new LJD.Font(fontName, activitesCaptionsFontSize); ActivitesCaptionsBrush = LJD.Brushes.Text; ActionCaptionFont = new LJD.Font(fontName, actionCaptionsFontSize); RulerMarkFont = new LJD.Font(fontName, rulerMarkFontSize); UserIcon = userIcon; APIIcon = apiIcon; BookmarkIcon = bookmarkIcon; selectedActivityBackgroundBrush = Selectors.Create(isDark, dark => new LJD.Brush(dark ? Color.FromArgb(40, 80, 120) : Color.FromArgb(187, 196, 221))); RulerMarkBrush = LJD.Brushes.Text; rulerLinePen = Selectors.Create(isDark, dark => new LJD.Pen(dark ? Color.DarkGray : Color.LightGray, 1)); Color adjust(Color cl, bool dark) => dark?cl.MakeDarker(60) : cl; procedureBrush = Selectors.Create(isDark, dark => new LJD.Brush(adjust(Color.LightBlue, dark))); lifetimeBrush = Selectors.Create(isDark, dark => new LJD.Brush(adjust(Color.LightGreen, dark))); networkMessageBrush = Selectors.Create(isDark, dark => new LJD.Brush(adjust(Color.LightSalmon, dark))); unknownActivityBrush = Selectors.Create(isDark, dark => new LJD.Brush(adjust(Color.LightGray, dark))); ActivitiesTopBoundPen = new LJD.Pen(Color.Gray, 1); milestonePen = Selectors.Create(isDark, dark => new LJD.Pen(dark ? Color.FromArgb(0, 67, 175) : Color.FromArgb(180, Color.SteelBlue), pensScale * 3f)); activityBarBoundsPen = Selectors.Create(isDark, dark => new LJD.Pen(dark ? Color.White : Color.Gray, 1f)); ActivitiesConnectorPen = new LJD.Pen(Color.DarkGray, pensScale * 1f, new[] { 1f, 1f }); PhaseBrushes = new LJD.Brush[] { new LJD.Brush(Color.FromArgb(255, 170, 170, 170)), new LJD.Brush(Color.FromArgb(255, 0, 150, 136)), new LJD.Brush(Color.FromArgb(255, 63, 72, 204)), new LJD.Brush(Color.FromArgb(255, 34, 175, 76)), }; UserEventPen = new LJD.Pen(Color.Salmon, pensScale * 2f); EventRectBrush = new LJD.Brush(Color.Salmon); EventRectPen = new LJD.Pen(Color.Gray, 1); EventCaptionBrush = new LJD.Brush(Color.Black); EventCaptionFont = ActionCaptionFont; EventCaptionStringFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Far); BookmarkPen = new LJD.Pen(Color.FromArgb(0x5b, 0x87, 0xe0), pensScale * 1f); FocusedMessagePen = new LJD.Pen(Color.Blue, pensScale * 1f); FocusedMessageLineTop = focusedMessageLineTop; MeasurerPen = new LJD.Pen(Color.DarkGreen, pensScale * 1f, new[] { 4f, 2f }); MeasurerTextFont = new LJD.Font(fontName, rulerMarkFontSize); MeasurerTextBrush = new LJD.Brush(Color.Black); MeasurerTextBoxBrush = new LJD.Brush(Color.White); MeasurerTextBoxPen = new LJD.Pen(Color.DarkGreen, 1f); MeasurerTextFormat = new LJD.StringFormat(StringAlignment.Center, StringAlignment.Center); navigationPanel_InvisibleBackground = Selectors.Create(isDark, dark => dark ? LJD.Brushes.TextBackground : new LJD.Brush(Color.FromArgb(235, 235, 235))); navigationPanel_VisibleBackground = Selectors.Create(isDark, dark => new LJD.Brush(dark ? Color.FromArgb(60, 60, 60) : Color.White)); SystemControlBrush = systemControlBrush; VisibleRangePen = new LJD.Pen(Color.Gray, 1f); foldingSignPen = Selectors.Create(isDark, dark => dark? LJD.Pens.White : LJD.Pens.Black); }