Ejemplo n.º 1
0
        private void DoDrawGrid(GraphicsEx g, Pen pen, RectF area)
        {
            foreach (var element in m_currentState.XPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x, y, x, 0);
            }

            foreach (var element in m_currentState.YPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, 0, y, x, y);
            }
        }
Ejemplo n.º 2
0
        private void DoDrawAxes(GraphicsEx g, Pen pen, Brush brush, RectF area)
        {
            float w = (float)this.Width;
            float h = (float)this.Height;

            g.DrawLine(pen, 0, h - cBottomOffset, w, h - cBottomOffset);
            g.DrawLine(pen, w - cArrowOffset, h - cBottomOffset - cArrowOffset / 2, w, h - cBottomOffset);
            g.DrawLine(pen, w - cArrowOffset, h - cBottomOffset + cArrowOffset / 2, w, h - cBottomOffset);

            foreach(var element in m_currentState.XPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x, y - cArrowSize, x, y + cArrowSize);
                g.DrawString(element.X.ToString(), this.Font, brush, x - cLeftOffset, y + cBottomOffset / 3);
            }

            g.DrawLine(pen, w - cRightOffset, 0, w - cRightOffset, h);
            g.DrawLine(pen, w - cRightOffset - cArrowOffset / 2, cArrowOffset, w - cRightOffset, 0);
            g.DrawLine(pen, w - cRightOffset + cArrowOffset / 2, cArrowOffset, w - cRightOffset, 0);

            foreach (var element in m_currentState.YPhysicalDashes)
            {
                float x = g.TransformX(element.X);
                float y = g.TransformY(element.Y);

                g.DrawLine(pen, x - cArrowSize, y, x + cArrowSize, y);
                g.DrawString(element.Y.ToString(m_parameters.PriceFormat), this.Font, brush, x, y + +cBottomOffset / 3);
            }
        }
Ejemplo n.º 3
0
        private void DoDrawData(GraphicsEx g)
        {
            m_currentState.Refresh(m_settings);
            RectF area = m_currentState.PhysicalArea;

            float w = (float)this.Width - cLeftOffset - cRightOffset;
            float h = (float)this.Height - cBottomOffset - cTopOffset;

            float kx = w / area.Width;
            float ky = h / area.Height;

            RectF physical = area;

            RectF logical = new RectF(cLeftOffset, cTopOffset, cLeftOffset + w, cTopOffset + h);

            g.Physical = physical;
            g.Logical = logical;

            int count = m_currentState.Graphs.Count;
            for (int index = 0; index < count; ++index)
            {
                Graph graph = m_currentState.Graphs[index];
                Color bidColor = m_settings.Lines[index].BidColor;
                Color askColor = m_settings.Lines[index].AskColor;
                DrawLine(g, graph, bidColor, askColor);
            }

            using (Pen pen = new Pen(m_settings.ForegroundColor))
            {
                using (Brush brush = new SolidBrush(m_settings.ForegroundColor))
                {
                    DoDrawAxes(g, pen, brush, area);
                }
                if (m_settings.Grid)
                {
                    pen.DashPattern = new float[] { 10, 10 };
                    pen.Width = 0.5F;
                    DoDrawGrid(g, pen, area);
                }
            }
        }
Ejemplo n.º 4
0
        private void CalculateArea()
        {
            RectF area = new RectF();
            area.MinX = -(float)m_quotes.Interval;

            float yMin = float.MaxValue;
            float yMax = float.MinValue;

            QuoteEx last = m_quotes.Last;
            if (null != last.Quote)
            {
                yMin = (float)Math.Min(last.Quote.Bid, last.Quote.Ask);
                yMax = (float)Math.Max(last.Quote.Bid, last.Quote.Ask);
            }

            foreach (var element in m_quotes.Items)
            {
                float bid = (float)element.Quote.Bid;
                float ask = (float)element.Quote.Ask;

                if (bid < yMin)
                {
                    yMin = bid;
                }
                if (bid > yMax)
                {
                    yMax = bid;
                }

                if (ask < yMin)
                {
                    yMin = ask;
                }
                if (ask > yMax)
                {
                    yMax = ask;
                }
            }

            foreach (var element in Graphs)
            {
                float? min = element.CalculateMinimum();
                float? max = element.CalculateMaximum();

                if (min.HasValue)
                {
                    yMin = Math.Min(yMin, min.Value);
                }

                if (max.HasValue)
                {
                    yMax = Math.Max(yMax, max.Value);
                }
            }

            area.MinY = (float)MathEx.RoundDown(yMin, m_parameters.RoundingStepOfPrice);
            area.MaxY = (float)MathEx.RoundUp(yMax, m_parameters.RoundingStepOfPrice);

            this.PhysicalArea = area;
        }