Ejemplo n.º 1
0
        public void ResetBackground(double _fStretchFactor, Point _DirectZoomTopLeft)
        {
            // Scale and shift background before drawing.

            // 1. Unscaled values
            Button   but    = new Button();
            Graphics g      = but.CreateGraphics();
            SizeF    bgSize = g.MeasureString(" " + m_TextInfos[0] + " ", m_TextDecoration.GetInternalFont());

            g.Dispose();
            Background.Width  = (int)bgSize.Width + 8;
            Background.Height = (int)bgSize.Height + 4;

            // 2. Scaled values.
            Rescale(_fStretchFactor, _DirectZoomTopLeft);
        }
Ejemplo n.º 2
0
        public DrawingText(int x, int y, int width, int height, long _iTimestamp, long _iAverageTimeStampsPerFrame)
        {
            m_Text                = "";          //KTS 04MAY2019 Changed from " " to "" to eliminate extra space at start of each line.
            m_TextboxColor        = Color.White; // Color.LightSteelBlue;
            m_BackgroundRectangle = new Rectangle(x, y, width, height);
            m_TextStyle           = new InfosTextDecoration("Arial", m_iDefaultFontSize, FontStyle.Bold, Color.White, Color.CornflowerBlue);

            m_InfosFading = new InfosFading(_iTimestamp, _iAverageTimeStampsPerFrame);
            m_bEditMode   = false;

            // Textbox initialization.
            m_TextBox              = new TextBox();
            m_TextBox.Visible      = false;
            m_TextBox.BackColor    = m_TextboxColor;
            m_TextBox.BorderStyle  = BorderStyle.None;
            m_TextBox.Text         = m_Text;
            m_TextBox.Font         = m_TextStyle.GetInternalFont();
            m_TextBox.Multiline    = true;
            m_TextBox.TextChanged += new EventHandler(TextBox_TextChanged);


            m_fStretchFactor    = 1.0;
            m_DirectZoomTopLeft = new Point(0, 0);
            RescaleCoordinates(m_fStretchFactor, m_DirectZoomTopLeft);
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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));
                }
            }
        }