示例#1
0
        /// <summary>
        ///    繪製 AxisX 座標軸
        /// </summary>
        /// <param name="axis">AxisX 座標軸</param>
        /// <param name="property">Chart 屬性參數</param>
        public override void DrawAxisX(AxisX axis, ChartProperty property)
        {
            uint   uPattern    = 0xaaaaaaaa;         //格線樣式(Gdi.cs 內的 SelectPen 方法有定義格式, 格式皆由 Plugin 設計者自由規劃)
            int    iOldBKColor = __cGDI.SelectBackground(property.BackgroundColor);
            IntPtr cOldPen     = __cGDI.SelectPen(new PowerLanguage.PenStyle(property.GridColor, 1, (int)uPattern));
            IntPtr cGridPen    = __cGDI.SelectPen(new PowerLanguage.PenStyle(property.ForeColor, 1));
            IntPtr cOldFont    = __cGDI.SelectFont(property.AxisFont);

            List <AxisXLabel> cAxises = axis.CalculateAxisScale();
            Rectangle         cRect   = axis.AxisRectangle;

            __cGDI.FillRectangle(property.BackgroundColor, cRect.Left, cRect.Top, cRect.Width, cRect.Height);

            int iCount = cAxises.Count;

            for (int i = 0; i < iCount; i++)
            {
                AxisXLabel cLabel     = cAxises[i];
                AxisXUnit  cUnit      = axis.ConvertBarNumberToWidth(cLabel.BarNumber);
                int        iAbsWidth  = cRect.Left + cUnit.CenterPoint;
                int        iCharWidth = iAbsWidth + axis.FontMetrics.Width * 11;           //MM/dd HH:mm (11 chars)
                if (iCharWidth < cRect.Width)
                {
                    __cGDI.DrawLine(iAbsWidth, cRect.Top, iAbsWidth, cRect.Top + 5);
                    __cGDI.DrawString(cLabel.Time.ToString((i == 0) ? "yyyy/MM/dd" : "MM/dd HH:mm"), property.ForeColor, iAbsWidth, cRect.Top + 5);

                    if (property.IsShowGrid)
                    {
                        //繪製格線(因為 AxisX 軸在最下方, 格線往上延伸即可)
                        IntPtr cAxisPen = __cGDI.SelectPen(cGridPen);
                        __cGDI.DrawLine(iAbsWidth, 0, iAbsWidth, cRect.Top);
                        __cGDI.SelectPen(cAxisPen);
                    }
                }
            }

            __cGDI.RemoveObject(cGridPen);
            __cGDI.RemoveObject(__cGDI.SelectPen(cOldPen));
            __cGDI.RemoveObject(__cGDI.SelectFont(cOldFont));
            __cGDI.SelectBackground(iOldBKColor);
        }