コード例 #1
0
        public override bool DrawPlot(Layer layer, ChartProperty property, bool onlyUpdateLastBar)
        {
            AxisX      cAxisX     = layer.AxisX;
            Rectangle  cRectY     = this.AxisY.AxisRectangle;
            Rectangle4 cLayerRect = new Rectangle4(layer.LayerRectangleWithoutAxisY);

            __cGDI.SaveDC();
            __cGDI.ClipRectangle(layer.LayerRectangleWithoutAxisY);

            int    iOldMode  = __cGDI.SelectTransparent();
            IntPtr iOldFont  = __cGDI.SelectFont(__cSymbolFont);
            IntPtr iOldPen   = __cGDI.SelectPen(new PowerLanguage.PenStyle(property.TradeLineColor, 1, (int)__uPattern));
            IntPtr iNameFont = __cLegendFont.ToHfont();

            if (onlyUpdateLastBar)
            {
                if (__cPrevTrade != null)
                {
                    DrawTradeInfo(__cPrevTrade, cAxisX, property, iNameFont, cLayerRect, cRectY.Top);
                }
            }
            else
            {
                this.RefreshAxisY(property);

                int iStartIndex          = cAxisX.BarNumber;
                int iEndIndex            = iStartIndex + cAxisX.BarCount - 1;
                HashSet <ITrade> cTrades = __cTrades.GetTradeObjects(iStartIndex, iEndIndex);
                foreach (ITrade cTrade in cTrades)
                {
                    DrawTradeInfo(cTrade, cAxisX, property, iNameFont, cLayerRect, cRectY.Top);
                    __cPrevTrade = cTrade;
                }
            }

            __cGDI.RemoveObject(iNameFont);
            __cGDI.RemoveObject(__cGDI.SelectPen(iOldPen));
            __cGDI.RemoveObject(__cGDI.SelectFont(iOldFont));

            if (layer.Drawable)
            {
                this.DrawLegend(layer.LegendIndex, property);
            }
            __cGDI.ClearTransparent(iOldMode);
            __cGDI.RestoreDC();
            return(true);
        }
コード例 #2
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);
            }
        }