Esempio n. 1
0
        public void Draw(IAffineTransformMatrix <T> Position, RendererBase <T> renderer)
        {
            T TextHeight = m_Position[1].Subtract(20);
            T Range      = (m_DataViewMaxY.Subtract(m_DataViewMinY));
            ConvTransform <T> TransformedLinesToDraw;
            ConvStroke <T>    StrockedTransformedLinesToDraw;

            RoundedRect <T>   BackGround            = new RoundedRect <T>(m_Position[0], m_Position[1].Subtract(1), m_Position[0].Add(m_Width), m_Position[1].Subtract(1).Add(m_Height).Add(2), M.New <T>(5));
            ConvTransform <T> TransformedBackGround = new ConvTransform <T>(BackGround, Position);

            renderer.Render(TransformedBackGround, new RGBA_Bytes(0, 0, 0, .5));

            // if the 0 line is within the window than draw it.
            if (m_DataViewMinY.LessThan(0) && m_DataViewMaxY.GreaterThan(0))
            {
                m_LinesToDraw.RemoveAll();
                m_LinesToDraw.MoveTo(m_Position[0],
                                     m_Position[1].Add(m_DataViewMinY.Negative().Multiply(M.New <T>(m_Height).Divide(Range))));


                m_LinesToDraw.LineTo(m_Position[0].Add((double)m_Width),
                                     m_Position[1].Add(m_DataViewMinY.Negative().Multiply(M.New <T>((double)m_Height).Divide(Range))));

                TransformedLinesToDraw         = new ConvTransform <T>(m_LinesToDraw, Position);
                StrockedTransformedLinesToDraw = new ConvStroke <T>(TransformedLinesToDraw);
                renderer.Render(StrockedTransformedLinesToDraw, new RGBA_Bytes(0, 0, 0, 1));
            }

            T MaxMax     = M.New <T>(-999999999);
            T MinMin     = M.New <T>(999999999);
            T MaxAverage = M.Zero <T>();

            foreach (KeyValuePair <String, HistoryData> historyKeyValue in m_DataHistoryArray)
            {
                HistoryData history = historyKeyValue.Value;
                m_LinesToDraw.RemoveAll();
                MaxMax     = M.Max(MaxMax, history.GetMaxValue());
                MinMin     = M.Min(MinMin, history.GetMinValue());
                MaxAverage = M.Max(MaxAverage, history.GetAverageValue());
                for (int i = 0; i < m_Width - 1; i++)
                {
                    if (i == 0)
                    {
                        m_LinesToDraw.MoveTo(m_Position[0].Add(i),
                                             m_Position[1].Add(history.GetItem(i).Subtract(m_DataViewMinY).Multiply(M.New <T>(m_Height).Divide(Range))));
                    }
                    else
                    {
                        m_LinesToDraw.LineTo(m_Position[0].Add(i),
                                             m_Position[1].Add(history.GetItem(i).Subtract(m_DataViewMinY).Multiply(M.New <T>((double)m_Height).Divide(Range))));
                    }
                }

                TransformedLinesToDraw         = new ConvTransform <T>(m_LinesToDraw, Position);
                StrockedTransformedLinesToDraw = new ConvStroke <T>(TransformedLinesToDraw);
                renderer.Render(StrockedTransformedLinesToDraw, history.m_Color);

                String Text = historyKeyValue.Key + ": Min:" + MinMin.ToString("0.0") + " Max:" + MaxMax.ToString("0.0");
                renderer.DrawString(Text, m_Position[0], TextHeight.Subtract(m_Height));
                TextHeight.SubtractEquals(20);
            }

            RoundedRect <T> BackGround2 = new RoundedRect <T>(
                m_Position[0],
                m_Position[1].Subtract(1),
                m_Position[0].Add((double)m_Width),
                m_Position[1].Subtract(1 + m_Height + 2), M.New <T>(5));

            ConvTransform <T> TransformedBackGround2        = new ConvTransform <T>(BackGround2, Position);
            ConvStroke <T>    StrockedTransformedBackGround = new ConvStroke <T>(TransformedBackGround2);

            renderer.Render(StrockedTransformedBackGround, new RGBA_Bytes(0.0, 0, 0, 1));

            //renderer.Color = BoxColor;
            //renderer.DrawRect(m_Position.x, m_Position.y - 1, m_Width, m_Height + 2);
        }