示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aValue"></param>
        public void AddValue(String aName, LogValue aValue)
        {
            lock (this)
            {
                m_Dirty = true;

                if (m_Time == DateTime.MinValue)
                {
                    m_Time = aValue.Time;
                }

                foreach (PlotterValues Values in m_Values)
                {
                    if (Values.Name == aName)
                    {
                        Values.AddValue(aValue);
                        return;
                    }
                }

                // Not found, add the value
                PlotterValues NewValues = new PlotterValues(aName);
                NewValues.AddValue(aValue);
                m_Values.Add(NewValues);
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="aPlotterValue"></param>
        private void DrawValue(PaintEventArgs Paint, PlotterValues aPlotterValue, int ValueIndex)
        {
            Point PreviousPosition = new Point();
            Point CurrentPosition  = new Point();

            Double aVerticalPosition1 = ((ValueIndex + 0) * m_ValueHeight) + (m_ValueHeight * 0.05);
            Double aVerticalPosition2 = ((ValueIndex + 1) * m_ValueHeight) - (m_ValueHeight * 0.05);

            Double DataHeight = aVerticalPosition2 - aVerticalPosition1;

            // Grid
            DrawValueGrid(Paint, aVerticalPosition1, aVerticalPosition2);

            // Delimiters
            Point DelimPoint_11 = new Point(0, (int)aVerticalPosition1);
            Point DelimPoint_12 = new Point(Width, (int)aVerticalPosition1);

            Point DelimPoint_21 = new Point(0, (int)aVerticalPosition2);
            Point DelimPoint_22 = new Point(Width, (int)aVerticalPosition2);

            Paint.Graphics.DrawLine(m_DelimPen, DelimPoint_11, DelimPoint_12);
            Paint.Graphics.DrawLine(m_DelimPen, DelimPoint_21, DelimPoint_22);

            // Range
            Rectangle TextPosition = new Rectangle();
            String    Minimum      = aPlotterValue.Minimum.ToString();
            String    Maximum      = aPlotterValue.Maximum.ToString();
            Double    LabelHeight  = DataHeight * 0.25;

            TextPosition.X      = 10;
            TextPosition.Y      = (int)(aVerticalPosition1);
            TextPosition.Width  = m_LabelWidth;
            TextPosition.Height = (int)LabelHeight;

            DrawCenteredText(Paint, Maximum, TextPosition, System.Drawing.SystemFonts.CaptionFont, SystemBrushes.ActiveCaptionText);

            TextPosition.X      = 10;
            TextPosition.Y      = (int)(aVerticalPosition1 + LabelHeight * 3.0);
            TextPosition.Width  = m_LabelWidth;
            TextPosition.Height = (int)LabelHeight;

            DrawCenteredText(Paint, Minimum, TextPosition, System.Drawing.SystemFonts.CaptionFont, SystemBrushes.ActiveCaptionText);

            TextPosition.X      = 10;
            TextPosition.Y      = (int)(aVerticalPosition1 + LabelHeight * 1.0);
            TextPosition.Width  = m_LabelWidth;
            TextPosition.Height = (int)(LabelHeight * 2.0);

            DrawCenteredText(Paint, aPlotterValue.Name, TextPosition, System.Drawing.SystemFonts.CaptionFont, SystemBrushes.ActiveCaptionText);

            // Lines
            foreach (LogValue aValue in aPlotterValue.Values)
            {
                Double aNormalizedValue = aPlotterValue.GetNormalizedValue(aValue.Value);

                if (aNormalizedValue != Double.NaN)
                {
                    CurrentPosition.X = (int)TimeToPosition(aValue.Time);
                    CurrentPosition.Y = (int)aVerticalPosition1 + (int)((1.0 - aNormalizedValue) * DataHeight);

                    if (
                        CurrentPosition.X > 0 &&
                        CurrentPosition.X < Width &&
                        CurrentPosition.Y > 0 &&
                        CurrentPosition.Y < Height
                        )
                    {
                        if (PreviousPosition.X != 0 && PreviousPosition.Y != 0)
                        {
                            if (PreviousPosition.X > -1000 && PreviousPosition.X < Width + 1000)
                            {
                                Point PreviousPositionLinear = new Point(PreviousPosition.X, PreviousPosition.Y);
                                Point CurrentPositionLinear  = new Point(CurrentPosition.X, PreviousPosition.Y);
                                Paint.Graphics.DrawLine(m_CurvePen, PreviousPositionLinear, CurrentPositionLinear);

                                Point Mark1 = new Point(CurrentPosition.X + 0, CurrentPosition.Y - 1);
                                Point Mark2 = new Point(CurrentPosition.X + 0, CurrentPosition.Y + 1);
                                Point Mark3 = new Point(CurrentPosition.X - 1, CurrentPosition.Y + 0);
                                Point Mark4 = new Point(CurrentPosition.X + 1, CurrentPosition.Y + 0);

                                Paint.Graphics.DrawLine(m_DotPen, Mark1, Mark2);
                                Paint.Graphics.DrawLine(m_DotPen, Mark3, Mark4);
                            }
                        }
                    }

                    PreviousPosition = CurrentPosition;
                }
            }

            // Markers
            foreach (LogValue aValue in m_Markers)
            {
                CurrentPosition.X = (int)TimeToPosition(aValue.Time);

                if (CurrentPosition.X > 0 && CurrentPosition.X < Width)
                {
                    Point Mark1 = new Point(CurrentPosition.X, 0);
                    Point Mark2 = new Point(CurrentPosition.X, Height);

                    Paint.Graphics.DrawLine(m_MarkerPen, Mark1, Mark2);

                    TextPosition.X      = Mark1.X;
                    TextPosition.Y      = Mark1.Y;
                    TextPosition.Width  = m_LabelWidth;
                    TextPosition.Height = (int)LabelHeight;

                    String Text = aValue.Time.ToLongTimeString();

                    DrawCenteredText(Paint, Text, TextPosition, System.Drawing.SystemFonts.CaptionFont, m_MarkerBrush);
                }
            }
        }