public override void Draw(Graphics _canvas, CoordinateSystem _transformer, bool _bSelected, long _iCurrentTimestamp) { double fOpacityFactor = m_InfosFading.GetOpacityFactor(_iCurrentTimestamp); if (fOpacityFactor <= 0) { return; } Point pointO = _transformer.Transform(m_PointO); Point pointA = _transformer.Transform(m_PointA); Point pointB = _transformer.Transform(m_PointB); Rectangle boundingBox = _transformer.Transform(m_BoundingBox); using (Pen penEdges = m_StyleHelper.GetBackgroundPen((int)(fOpacityFactor * 255))) using (SolidBrush brushEdges = m_StyleHelper.GetBackgroundBrush((int)(fOpacityFactor * 255))) using (SolidBrush brushFill = m_StyleHelper.GetBackgroundBrush((int)(fOpacityFactor * m_iDefaultBackgroundAlpha))) { // Disk section _canvas.FillPie(brushFill, boundingBox, m_fStartAngle, m_fSweepAngle); _canvas.DrawPie(penEdges, boundingBox, m_fStartAngle, m_fSweepAngle); // Edges _canvas.DrawLine(penEdges, pointO, pointA); _canvas.DrawLine(penEdges, pointO, pointB); // Handlers _canvas.DrawEllipse(penEdges, pointO.Box(3)); _canvas.FillEllipse(brushEdges, pointA.Box(3)); _canvas.FillEllipse(brushEdges, pointB.Box(3)); SolidBrush fontBrush = m_StyleHelper.GetForegroundBrush((int)(fOpacityFactor * 255)); int angle = (int)Math.Floor(-m_fSweepAngle); string label = angle.ToString() + "°"; Font tempFont = m_StyleHelper.GetFont((float)_transformer.Scale); SizeF labelSize = _canvas.MeasureString(label, tempFont); // Background float shiftx = (float)(_transformer.Scale * m_TextShift.X); float shifty = (float)(_transformer.Scale * m_TextShift.Y); PointF textOrigin = new PointF(shiftx + pointO.X - labelSize.Width / 2, shifty + pointO.Y - labelSize.Height / 2); RectangleF backRectangle = new RectangleF(textOrigin, labelSize); RoundedRectangle.Draw(_canvas, backRectangle, brushFill, tempFont.Height / 4, false); // Text _canvas.DrawString(label, tempFont, fontBrush, backRectangle.Location); tempFont.Dispose(); fontBrush.Dispose(); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (tracking) { opacityFactor = 1.0; } if (opacityFactor <= 0) { return; } ComputeValues(transformer); Point pointO = transformer.Transform(points["o"]); Point pointA = transformer.Transform(points["a"]); Point pointB = transformer.Transform(points["b"]); Rectangle boundingBox = transformer.Transform(angleHelper.SweepAngle.BoundingBox); if (boundingBox.Size == Size.Empty) { return; } using (Pen penEdges = styleHelper.GetBackgroundPen((int)(opacityFactor * 255))) using (SolidBrush brushEdges = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255))) using (SolidBrush brushFill = styleHelper.GetBackgroundBrush((int)(opacityFactor * defaultBackgroundAlpha))) { penEdges.Width = 2; // Disk section canvas.FillPie(brushFill, boundingBox, angleHelper.SweepAngle.Start, angleHelper.SweepAngle.Sweep); canvas.DrawArc(penEdges, boundingBox, angleHelper.SweepAngle.Start, angleHelper.SweepAngle.Sweep); // Edges penEdges.DashStyle = DashStyle.Dash; canvas.DrawLine(penEdges, pointO, pointA); penEdges.DashStyle = DashStyle.Solid; canvas.DrawLine(penEdges, pointO, pointB); // Handlers canvas.DrawEllipse(penEdges, pointO.Box(3)); canvas.FillEllipse(brushEdges, pointA.Box(3)); canvas.FillEllipse(brushEdges, pointB.Box(3)); angleHelper.DrawText(canvas, opacityFactor, brushFill, pointO, transformer, CalibrationHelper, styleHelper); } }
public void Draw(Graphics canvas, IImageToViewportTransformer transformer, long timestamp, StyleHelper styleHelper) { double opacityFactor = infosFading.GetOpacityFactor(timestamp); if (opacityFactor <= 0) { return; } using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255))) using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacityFactor * 255))) using (Font fontText = styleHelper.GetFont((float)transformer.Scale)) using (Pen penContour = styleHelper.GetForegroundPen((int)(opacityFactor * 255))) { // Note: recompute background size in case the font floored. string text = value.ToString(); SizeF textSize = canvas.MeasureString(text, fontText); Point bgLocation = transformer.Transform(background.Rectangle.Location); Size bgSize = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); penContour.Width = 2; Rectangle rect = new Rectangle(bgLocation, bgSize); RoundedRectangle.Draw(canvas, rect, brushBack, fontText.Height / 4, false, true, penContour); canvas.DrawString(text, fontText, brushText, rect.Location); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (opacityFactor <= 0 || editing) { return; } using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacityFactor * 128))) using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacityFactor * 255))) using (Font fontText = styleHelper.GetFont((float)transformer.Scale)) { // Note: recompute background size in case the font floored. SizeF textSize = canvas.MeasureString(text, fontText); Point bgLocation = transformer.Transform(background.Rectangle.Location); Size bgSize = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); Rectangle rect = new Rectangle(bgLocation, bgSize); RoundedRectangle.Draw(canvas, rect, brushBack, fontText.Height / 4, false, false, null); canvas.DrawString(text, fontText, brushText, rect.Location); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacity = infosFading.GetOpacityFactor(currentTimestamp); if (tracking) { opacity = 1.0; } if (opacity <= 0) { return; } List <Point> points = transformer.Transform(genericPosture.PointList); int alpha = (int)(opacity * 255); alpha = Math.Max(0, Math.Min(255, alpha)); int alphaBackground = (int)(opacity * defaultBackgroundAlpha); alphaBackground = Math.Max(0, Math.Min(255, alphaBackground)); using (Pen penEdge = styleHelper.GetBackgroundPen(alpha)) using (SolidBrush brushHandle = styleHelper.GetBackgroundBrush(alpha)) using (SolidBrush brushFill = styleHelper.GetBackgroundBrush(alphaBackground)) { Color basePenEdgeColor = penEdge.Color; Color baseBrushHandleColor = brushHandle.Color; Color baseBrushFillColor = brushFill.Color; DrawSegments(penEdge, basePenEdgeColor, alpha, canvas, transformer, points); DrawCircles(penEdge, basePenEdgeColor, alpha, canvas, transformer, points); DrawAngles(penEdge, basePenEdgeColor, brushFill, baseBrushFillColor, alpha, alphaBackground, opacity, canvas, transformer, points); DrawPoints(brushHandle, baseBrushHandleColor, alpha, canvas, transformer, points); DrawComputedPoints(penEdge, basePenEdgeColor, brushHandle, baseBrushHandleColor, alpha, opacity, canvas, transformer); DrawDistances(brushFill, baseBrushFillColor, alphaBackground, opacity, canvas, transformer, points); DrawPositions(brushFill, baseBrushFillColor, alphaBackground, opacity, canvas, transformer, points); if (PreferencesManager.PlayerPreferences.EnableCustomToolsDebugMode) { DrawDebug(opacity, canvas, transformer, points); } } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { if (currentTimestamp < visibleTimestamp) { return; } double opacityFactor = 1.0; if (currentTimestamp > invisibleTimestamp) { opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); } if (opacityFactor <= 0) { return; } timecode = GetTimecode(currentTimestamp); string text = timecode; using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacityFactor * 128))) using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacityFactor * 255))) using (Font fontText = styleHelper.GetFont((float)transformer.Scale)) { SizeF textSize = canvas.MeasureString(text, fontText); Point bgLocation = transformer.Transform(mainBackground.Rectangle.Location); Size bgSize = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); mainBackground.Rectangle = new RectangleF(mainBackground.Rectangle.Location, untransformed); Rectangle rect = new Rectangle(bgLocation, bgSize); int roundingRadius = fontText.Height / 4; RoundedRectangle.Draw(canvas, rect, brushBack, roundingRadius, false, false, null); canvas.DrawString(text, fontText, brushText, rect.Location); if (showLabel && name.Length > 0) { using (Font fontLabel = styleHelper.GetFont((float)transformer.Scale * 0.5f)) { // Note: the alignment here assumes fixed margins of the rounded rectangle class. SizeF lblTextSize = canvas.MeasureString(name, fontLabel); int labelRoundingRadius = fontLabel.Height / 3; int top = rect.Location.Y - (int)lblTextSize.Height - roundingRadius - labelRoundingRadius; Rectangle lblRect = new Rectangle(rect.Location.X, top, (int)lblTextSize.Width, (int)lblTextSize.Height); RoundedRectangle.Draw(canvas, lblRect, brushBack, labelRoundingRadius, true, false, null); canvas.DrawString(name, fontLabel, brushText, lblRect.Location); } } } }
public override void Draw(Graphics _canvas, CoordinateSystem _transformer, bool _bSelected, long _iCurrentTimestamp) { if (_iCurrentTimestamp < m_iVisibleTimestamp) { return; } double fOpacityFactor = 1.0; if (_iCurrentTimestamp > m_iInvisibleTimestamp) { fOpacityFactor = m_InfosFading.GetOpacityFactor(_iCurrentTimestamp); } if (fOpacityFactor <= 0) { return; } m_Timecode = GetTimecode(_iCurrentTimestamp); // Update unscaled backround size according to timecode text. Needed for hit testing. Font f = m_StyleHelper.GetFont(1F); SizeF totalSize = _canvas.MeasureString(" " + m_Timecode + " ", f); SizeF textSize = _canvas.MeasureString(m_Timecode, f); f.Dispose(); m_MainBackground.Rectangle = new Rectangle(m_MainBackground.Rectangle.Location, new Size((int)totalSize.Width, (int)totalSize.Height)); using (SolidBrush brushBack = m_StyleHelper.GetBackgroundBrush((int)(fOpacityFactor * 128))) using (SolidBrush brushText = m_StyleHelper.GetForegroundBrush((int)(fOpacityFactor * 255))) using (Font fontText = m_StyleHelper.GetFont((float)_transformer.Scale)) { Rectangle rect = _transformer.Transform(m_MainBackground.Rectangle); RoundedRectangle.Draw(_canvas, rect, brushBack, fontText.Height / 4, false); int margin = (int)((totalSize.Width - textSize.Width) / 2); Point textLocation = new Point(rect.X + margin, rect.Y); _canvas.DrawString(m_Timecode, fontText, brushText, textLocation); if (m_bShowLabel && m_Label.Length > 0) { using (Font fontLabel = m_StyleHelper.GetFont((float)_transformer.Scale * 0.5f)) { SizeF lblTextSize = _canvas.MeasureString(m_Label, fontLabel); Rectangle lblRect = new Rectangle(rect.Location.X, rect.Location.Y - (int)lblTextSize.Height, (int)lblTextSize.Width, (int)lblTextSize.Height); RoundedRectangle.Draw(_canvas, lblRect, brushBack, fontLabel.Height / 3, true); _canvas.DrawString(m_Label, fontLabel, brushText, lblRect.Location); } } } }
public void Draw(Graphics canvas, IImageToViewportTransformer transformer, long timestamp, StyleHelper styleHelper) { double fOpacityFactor = infosFading.GetOpacityFactor(timestamp); if (fOpacityFactor <= 0) { return; } int alpha = (int)(255 * fOpacityFactor); //SetText(styleHelper); using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(fOpacityFactor * 255))) using (SolidBrush brushFront = styleHelper.GetForegroundBrush((int)(fOpacityFactor * 255))) using (Pen penContour = styleHelper.GetForegroundPen((int)(fOpacityFactor * 255))) using (Font f = styleHelper.GetFont((float)transformer.Scale)) { // Note: recompute the background size each time in case font floored. string text = value.ToString(); penContour.Width = 2; SizeF textSize = canvas.MeasureString(text, f); Point bgLocation = transformer.Transform(background.Rectangle.Location); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); Size bgSize; if (value < 10) { bgSize = new Size((int)textSize.Height, (int)textSize.Height); Rectangle rect = new Rectangle(bgLocation, bgSize); canvas.FillEllipse(brushBack, rect); canvas.DrawEllipse(penContour, rect); } else { bgSize = new Size((int)textSize.Width, (int)textSize.Height); Rectangle rect = new Rectangle(bgLocation, bgSize); RoundedRectangle.Draw(canvas, rect, brushBack, f.Height / 4, false, true, penContour); } int verticalShift = (int)(textSize.Height / 10); Point textLocation = new Point(bgLocation.X + (int)((bgSize.Width - textSize.Width) / 2), bgLocation.Y + verticalShift); canvas.DrawString(text, f, brushFront, textLocation); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacity = infosFading.GetOpacityFactor(currentTimestamp); if (opacity <= 0) { return; } //int backgroundOpacity = editing ? 255 : 192; int backgroundOpacity = 255; using (SolidBrush brushBack = styleHelper.GetBackgroundBrush((int)(opacity * backgroundOpacity))) using (SolidBrush brushText = styleHelper.GetForegroundBrush((int)(opacity * 255))) using (Pen pen = styleHelper.GetPen(backgroundOpacity)) using (Font fontText = styleHelper.GetFont((float)transformer.Scale)) { SizeF textSize = canvas.MeasureString(text, fontText); Point bgLocation = transformer.Transform(background.Rectangle.Location); Size bgSize = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); Rectangle rect = new Rectangle(bgLocation, bgSize); int roundingRadius = fontText.Height / 4; if (showArrow) { pen.Color = brushBack.Color; pen.Width = fontText.Height / 4; Point arrowStartInScreen = rect.Center(); Point arrowEndInScreen = transformer.Transform(arrowEnd); canvas.DrawLine(pen, arrowStartInScreen, arrowEndInScreen); ArrowHelper.Draw(canvas, pen, arrowEndInScreen, arrowStartInScreen); } RoundedRectangle.Draw(canvas, rect, brushBack, roundingRadius, false, false, null); if (!editing) { canvas.DrawString(text, fontText, brushText, rect.Location); } } }
public override void Draw(Graphics _canvas, CoordinateSystem _transformer, bool _bSelected, long _iCurrentTimestamp) { double fOpacityFactor = m_InfosFading.GetOpacityFactor(_iCurrentTimestamp); if (fOpacityFactor <= 0 || m_bEditMode) { return; } using (SolidBrush brushBack = m_StyleHelper.GetBackgroundBrush((int)(fOpacityFactor * 128))) using (SolidBrush brushText = m_StyleHelper.GetForegroundBrush((int)(fOpacityFactor * 255))) using (Font fontText = m_StyleHelper.GetFont((float)_transformer.Scale)) { Rectangle rect = _transformer.Transform(m_Background.Rectangle); RoundedRectangle.Draw(_canvas, rect, brushBack, fontText.Height / 4, false); _canvas.DrawString(m_Text, fontText, brushText, rect.Location); } }
private void DrawGrid(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, CoordinateSystemGrid grid) { Pen p = styleHelper.GetBackgroundPen(gridAlpha); p.DashStyle = DashStyle.Solid; p.Width = 2; if (grid.VerticalAxis != null) { DrawGridLine(canvas, distorter, transformer, p, grid.VerticalAxis.Start, grid.VerticalAxis.End); } if (grid.HorizontalAxis != null) { DrawGridLine(canvas, distorter, transformer, p, grid.HorizontalAxis.Start, grid.HorizontalAxis.End); } p.DashStyle = DashStyle.Dash; p.Width = 1; foreach (GridLine line in grid.GridLines) { DrawGridLine(canvas, distorter, transformer, p, line.Start, line.End); } SolidBrush brushFill = styleHelper.GetBackgroundBrush(defaultBackgroundAlpha); SolidBrush fontBrush = styleHelper.GetForegroundBrush(255); Font font = styleHelper.GetFont(1.0F); foreach (TickMark tick in grid.TickMarks) { DrawTickMark(canvas, distorter, transformer, tick, brushFill, fontBrush, font); } font.Dispose(); fontBrush.Dispose(); brushFill.Dispose(); p.Dispose(); }
public void Draw(Graphics _canvas, CoordinateSystem _transformer, double _fOpacityFactor) { using (SolidBrush fillBrush = m_StyleHelper.GetBackgroundBrush((int)(_fOpacityFactor * 255))) using (Pen p = m_StyleHelper.GetBackgroundPen((int)(_fOpacityFactor * 64))) using (Font f = m_StyleHelper.GetFont((float)_transformer.Scale)) using (SolidBrush fontBrush = m_StyleHelper.GetForegroundBrush((int)(_fOpacityFactor * 255))) { // Small dot and connector. Point attch = _transformer.Transform(m_AttachLocation); Point center = _transformer.Transform(m_Background.Center); _canvas.FillEllipse(fillBrush, attch.Box(2)); _canvas.DrawLine(p, attch, center); // Background and text. SizeF textSize = _canvas.MeasureString(m_Text, f); Point location = _transformer.Transform(m_Background.Rectangle.Location); Size size = new Size((int)textSize.Width, (int)textSize.Height); Rectangle rect = new Rectangle(location, size); RoundedRectangle.Draw(_canvas, rect, fillBrush, f.Height / 4, false); _canvas.DrawString(m_Text, f, fontBrush, rect.Location); } }
public void Draw(Graphics canvas, IImageToViewportTransformer transformer, double opacityFactor) { using (SolidBrush fillBrush = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255))) using (Pen p = styleHelper.GetBackgroundPen((int)(opacityFactor * 64))) using (Font f = styleHelper.GetFont((float)transformer.Scale)) using (SolidBrush fontBrush = styleHelper.GetForegroundBrush((int)(opacityFactor * 255))) { SizeF textSize = canvas.MeasureString(text, f); Point location = transformer.Transform(background.Rectangle.Location); Size size = new Size((int)textSize.Width, (int)textSize.Height); SizeF untransformed = transformer.Untransform(textSize); background.Rectangle = new RectangleF(background.Rectangle.Location, untransformed); Point attch = transformer.Transform(attachLocation); Point center = transformer.Transform(background.Center); canvas.FillEllipse(fillBrush, attch.Box(2)); canvas.DrawLine(p, attch, center); Rectangle rect = new Rectangle(location, size); RoundedRectangle.Draw(canvas, rect, fillBrush, f.Height / 4, false, false, null); canvas.DrawString(text, f, fontBrush, rect.Location); } }
public override void Draw(Graphics canvas, DistortionHelper distorter, IImageToViewportTransformer transformer, bool selected, long currentTimestamp) { double opacityFactor = infosFading.GetOpacityFactor(currentTimestamp); if (tracking) { opacityFactor = 1.0; } if (opacityFactor <= 0) { return; } ComputeValues(transformer); Point pointO = transformer.Transform(points["o"]); Point pointA = transformer.Transform(points["a"]); Point pointB = transformer.Transform(points["b"]); Rectangle boundingBox = transformer.Transform(angleHelper.BoundingBox); if (boundingBox.Size == Size.Empty) { return; } using (Pen penEdges = styleHelper.GetBackgroundPen((int)(opacityFactor * 255))) using (SolidBrush brushEdges = styleHelper.GetBackgroundBrush((int)(opacityFactor * 255))) using (SolidBrush brushFill = styleHelper.GetBackgroundBrush((int)(opacityFactor * defaultBackgroundAlpha))) { // Disk section canvas.FillPie(brushFill, boundingBox, (float)angleHelper.Angle.Start, (float)angleHelper.Angle.Sweep); canvas.DrawPie(penEdges, boundingBox, (float)angleHelper.Angle.Start, (float)angleHelper.Angle.Sweep); // Edges canvas.DrawLine(penEdges, pointO, pointA); canvas.DrawLine(penEdges, pointO, pointB); // Handlers canvas.DrawEllipse(penEdges, pointO.Box(3)); canvas.FillEllipse(brushEdges, pointA.Box(3)); canvas.FillEllipse(brushEdges, pointB.Box(3)); SolidBrush fontBrush = styleHelper.GetForegroundBrush((int)(opacityFactor * 255)); float angle = CalibrationHelper.ConvertAngleFromDegrees(angleHelper.CalibratedAngle.Sweep); string label = ""; if (CalibrationHelper.AngleUnit == AngleUnit.Degree) { label = string.Format("{0}{1}", (int)Math.Round(angle), CalibrationHelper.GetAngleAbbreviation()); } else { label = string.Format("{0:0.00} {1}", angle, CalibrationHelper.GetAngleAbbreviation()); } Font tempFont = styleHelper.GetFont((float)transformer.Scale); SizeF labelSize = canvas.MeasureString(label, tempFont); // Background float shiftx = (float)(transformer.Scale * angleHelper.TextPosition.X); float shifty = (float)(transformer.Scale * angleHelper.TextPosition.Y); PointF textOrigin = new PointF(shiftx + pointO.X - labelSize.Width / 2, shifty + pointO.Y - labelSize.Height / 2); RectangleF backRectangle = new RectangleF(textOrigin, labelSize); RoundedRectangle.Draw(canvas, backRectangle, brushFill, tempFont.Height / 4, false, false, null); // Text canvas.DrawString(label, tempFont, fontBrush, backRectangle.Location); tempFont.Dispose(); fontBrush.Dispose(); } }