public override void Draw(Graphics _canvas, double _fStretchFactor, bool _bSelected, long _iCurrentTimestamp, Point _DirectZoomTopLeft) { double fOpacityFactor = m_InfosFading.GetOpacityFactor(_iCurrentTimestamp); if (fOpacityFactor > 0) { // Rescale the points. m_fStretchFactor = _fStretchFactor; m_DirectZoomTopLeft = new Point(_DirectZoomTopLeft.X, _DirectZoomTopLeft.Y); RescaleCoordinates(m_fStretchFactor, m_DirectZoomTopLeft); //---------------------------------------------------------- // Draw disk section // Unfortunately we need to compute everything at each draw // (draw may be triggered on image resize) //---------------------------------------------------------- ComputeFillRegion(); SolidBrush FillBrush = new SolidBrush(Color.FromArgb((int)((double)m_iDefaultBackgroundAlpha * fOpacityFactor), m_BackgroundFillColor)); Pen PenEdges = new Pen(m_InfosStyle.GetFadingBackColor(fOpacityFactor)); _canvas.FillPie(FillBrush, (float)m_BoundingPoint.X, (float)m_BoundingPoint.Y, (float)m_fRadius * 2, (float)m_fRadius * 2, m_fStartAngle, m_fSweepAngle); _canvas.DrawPie(PenEdges, (float)m_BoundingPoint.X, (float)m_BoundingPoint.Y, (float)m_fRadius * 2, (float)m_fRadius * 2, m_fStartAngle, m_fSweepAngle); //----------------------------- // Draw the edges //----------------------------- _canvas.DrawLine(PenEdges, RescaledPointO.X, RescaledPointO.Y, RescaledPointA.X, RescaledPointA.Y); _canvas.DrawLine(PenEdges, RescaledPointO.X, RescaledPointO.Y, RescaledPointB.X, RescaledPointB.Y); //----------------------------- // Draw handlers //----------------------------- if (_bSelected) { PenEdges.Width = 2; } _canvas.DrawEllipse(PenEdges, GetRescaledHandleRectangle(1)); _canvas.DrawEllipse(PenEdges, GetRescaledHandleRectangle(2)); _canvas.DrawEllipse(PenEdges, GetRescaledHandleRectangle(3)); //---------------------------- // Draw Measure //---------------------------- // We try to be inside the pie, so we compute the bissectrice and do some trigo. // We start the text on the bissectrice, at a distance of iTextRadius. Point TextOrigin = GetTextPosition(); SolidBrush fontBrush = new SolidBrush(m_InfosStyle.GetFadingForeColor(fOpacityFactor)); int angle = (int)Math.Floor(-m_fSweepAngle); _canvas.DrawString("α=" + angle.ToString() + "°", m_InfosStyle.GetInternalFont(), fontBrush, TextOrigin); } }
private void DrawText(Graphics _canvas, double _fFadingFactor) { int iOffsetX = 0; int iOffsetY = 0; if (m_bBackgroundIsRelative) { // see comment in DrawBackground iOffsetX = m_RescaledLocation.X; iOffsetY = m_RescaledLocation.Y; } // TODO: we should be able to get a font at the right size given a multiplicator somehow. // and use GetInternalFont(double) Font f = m_TextDecoration.GetInternalFont(); Font fontText = new Font(f.FontFamily, (float)m_fRescaledFontSize, f.Style); _canvas.DrawString(" " + m_TextInfos[0], fontText, new SolidBrush(m_TextDecoration.GetFadingForeColor(_fFadingFactor)), new Point(RescaledBackground.X + iOffsetX + 5, RescaledBackground.Y + iOffsetY + 3)); }
public override void Draw(Graphics _canvas, double _fStretchFactor, bool _bSelected, long _iCurrentTimestamp, Point _DirectZoomTopLeft) { double fOpacityFactor = m_InfosFading.GetOpacityFactor(_iCurrentTimestamp); if (fOpacityFactor > 0) { // Rescale the points. m_fStretchFactor = _fStretchFactor; m_DirectZoomTopLeft = new Point(_DirectZoomTopLeft.X, _DirectZoomTopLeft.Y); RescaleCoordinates(m_fStretchFactor, m_DirectZoomTopLeft); // This method may be used from worker threads and shouldn't touch UI controls. // -> The textbox will not be modified here. if (!m_bEditMode) { DrawBackground(_canvas, fOpacityFactor); SolidBrush fontBrush = new SolidBrush(m_TextStyle.GetFadingForeColor(fOpacityFactor)); Font fontText = m_TextStyle.GetInternalFont((float)m_fStretchFactor); _canvas.DrawString(m_Text, fontText, fontBrush, new Point(m_RescaledBackground.X + 5, m_RescaledBackground.Y + 3)); } } }