示例#1
0
        protected override void DrawLegend(int barNumber, ChartProperty property)
        {
            int       iDecimals    = this.AxisY.Decimals;
            Rectangle cRectY       = this.AxisY.AxisRectangle;
            IntPtr    cOldFont     = __cGDI.SelectFont(__cLegendFont);
            Size      cFontMetrics = __cGDI.MeasureString("0");

            __cGDI.BeginRopDraw();

            List <ITrade> cTrades = __cTrades.GetTradeObject(barNumber);
            int           iRow = 0, iCount = cTrades.Count;

            for (int i = 0; i < iCount; i++)
            {
                ITrade      cTrade      = cTrades[i];
                ITradeOrder cEntry      = cTrade.EntryOrder;
                string      sEntryOrder = string.Format("#{0} {1,-10} {2} at {3} {4}", cEntry.Ticket, cEntry.Action, cEntry.Contracts, Math.Round(cEntry.Price, iDecimals), cEntry.Time.ToString("yyyy-MM-dd HH:mm:ss"));
                __cGDI.DrawRopString(sEntryOrder, this.ChartSetting.LegendColor, cRectY.X - (sEntryOrder.Length * cFontMetrics.Width) - 4, cRectY.Top + ((iRow++ *cFontMetrics.Height) + 2));

                ITradeOrder cExit = cTrade.ExitOrder;
                if (cExit != null)
                {
                    string sExitOrder = string.Format("#{0} {1,-10} {2} at {3} {4}", cExit.Ticket, cExit.Action, cExit.Contracts, Math.Round(cExit.Price, iDecimals), cExit.Time.ToString("yyyy-MM-dd HH:mm:ss"));
                    __cGDI.DrawRopString(sExitOrder, this.ChartSetting.LegendColor, cRectY.X - (sExitOrder.Length * cFontMetrics.Width) - 4, cRectY.Top + ((iRow++ *cFontMetrics.Height) + 2));
                }
            }
            __cGDI.EndRopDraw();
            __cGDI.RemoveObject(__cGDI.SelectFont(cOldFont));
        }
示例#2
0
        protected override void DrawLegend(int barNumber, ChartProperty property)
        {
            Rectangle cRectY    = this.AxisY.AxisRectangle;
            IntPtr    cOldFont  = __cGDI.SelectFont(property.LegendFont);
            int       iDecimals = this.AxisY.Decimals;
            int       iTextY    = ((this.PlotIndex + 1) * __cGDI.MeasureString("0").Height) + 5;
            int       iOffset   = this.ConvertAxisScaleIndexToOffset(barNumber);
            string    sLegend   = string.Format("{0} (O:{1}, H:{2}, L:{3}, C:{4}, V:{5})", __cBars.Time[iOffset].ToString("yyyy/MM/dd HH:mm"), Math.Round(__cBars.Open[iOffset], iDecimals), Math.Round(__cBars.High[iOffset], iDecimals), Math.Round(__cBars.Low[iOffset], iDecimals), Math.Round(__cBars.Close[iOffset], iDecimals), __cBars.Volume[iOffset]);

            __cGDI.BeginRopDraw();
            __cGDI.DrawRopString(sLegend, this.ChartSetting.LegendColor, 5, cRectY.Top + iTextY);
            __cGDI.EndRopDraw();
            __cGDI.RemoveObject(__cGDI.SelectFont(cOldFont));
        }
示例#3
0
        private void DrawTextObject(Layer layer, TextObject textObject, ChartProperty property, bool useROP)
        {
            AxisX     cAxisX = layer.AxisX;
            AxisY     cAxisY = layer.AxisY;
            Rectangle cRectY = cAxisY.AxisRectangle;

            int    iOldBackground = 0;
            IntPtr iOldFont       = IntPtr.Zero;
            bool   bUseBG         = textObject.BGColor != property.BackgroundColor;
            bool   bUseFont       = textObject.FontName != property.TextFont.Name || textObject.Size != property.TextFont.Size;

            if (bUseBG)
            {
                iOldBackground = __cGDI.SelectBackground(textObject.BGColor);
            }
            else
            {
                iOldBackground = __cGDI.SelectTransparent();
            }

            if (bUseFont)
            {
                iOldFont = __cGDI.SelectFont(new Font(textObject.FontName, textObject.Size, textObject.Style));
            }

            int        iX = 0, iY = 0;
            ChartPoint cPoint    = textObject.Location;
            bool       bAbsolute = textObject.AbsolutePosition;

            if (bAbsolute)
            {
                iY = cRectY.Y + (int)cPoint.Price;
                iX = cPoint.BarNumber.Value;
            }
            else
            {
                iY = cRectY.Y + cAxisY.ConvertValueToHeight(cPoint.Price) + 1;
                AxisXUnit cUnit = cAxisX.ConvertBarNumberToWidth(cPoint.BarNumber.Value);
                Size      cSize = __cGDI.MeasureString(textObject.Text);

                iY = CalculateYFromStyle(iY, cSize, textObject.VStyle);
                iX = CalculateXFromStyle(cUnit.CenterPoint, cSize, textObject.HStyle);
            }

            Rectangle cLayerRect = layer.LayerRectangleWithoutAxisY;

            if (useROP || bAbsolute)
            {
                __cGDI.BeginRopDraw();
                __cGDI.DrawRopString(textObject.Text, textObject.Color, iX, iY);
                __cGDI.EndRopDraw();
            }
            else
            {
                __cGDI.DrawString(textObject.Text, textObject.Color, iX, iY);
            }

            if (bUseFont)
            {
                __cGDI.RemoveObject(__cGDI.SelectFont(iOldFont));
            }

            if (bUseBG)
            {
                __cGDI.SelectBackground(iOldBackground);
            }
            else
            {
                __cGDI.ClearTransparent(iOldBackground);
            }
        }