コード例 #1
0
        public void Draw(XGraphics gfx)
        {
            TransformsProvider tp = new TransformsProvider(gfx);
            XFont       font      = new XFont(this._fontFamilyName, this._fontSize, this._fontStyle);
            XSolidBrush brush     = new XSolidBrush(XColor.FromName(this._fontColorName));

            if (this._rect == XRect.Empty)
            {
                double x = tp.CmsToPts(this._x);
                double y = tp.CmsToPts(this._y);
                gfx.DrawString(this._text, font, brush, x, y, XStringFormat.TopLeft);
            }
            else
            {
                XRect rect = tp.FromCmsToPts(this._rect);
                gfx.DrawString(this._text, font, brush, rect, this._format);
            }
        }
コード例 #2
0
        public new void Draw(XGraphics gfx)
        {
            TransformsProvider tp = new TransformsProvider(gfx);
            XFont       font      = new XFont(this.FontFamilyName, this.FontSize, this.FontStyle);
            XSolidBrush brush     = new XSolidBrush(XColor.FromName(this.FontColorName));
            string      txt       = string.Format("{0} {1}", this._prefix, DateTime.Today.ToShortDateString());

            if (base.Rect == XRect.Empty)
            {
                double x = tp.CmsToPts(this.X);
                double y = tp.CmsToPts(this.Y);
                gfx.DrawString(txt, font, brush, x, y, XStringFormat.TopLeft);
            }
            else
            {
                XRect rect = tp.FromCmsToPts(base.Rect);
                gfx.DrawString(txt, font, brush, rect, base.Format);
            }
        }
コード例 #3
0
        public void Draw(XGraphics gfx, object param)
        {
            TransformsProvider tp = new TransformsProvider(gfx);
            XFont       font      = new XFont(this.FontFamilyName, this.FontSize, this.FontStyle);
            XSolidBrush brush     = new XSolidBrush(XColor.FromName(this.FontColorName));
            string      s         = string.Empty;

            if (param is DBNull)
            {
                s = string.Format("{0} {1} {2}", this._prefix, string.Empty, this._subfix);
            }
            if (param is string)
            {
                switch (_bindPropertyFormat)
                {
                case ValueParsingOption.None:
                    s = string.Format("{0} {1} {2}", this._prefix, param, this._subfix).Trim();
                    break;

                case ValueParsingOption.ParseInteger:
                    int intVal;
                    if (int.TryParse((string)param, out intVal))
                    {
                        s = string.Format("{0} {1} {2}", this._prefix, intVal.ToString("#,###"), this._subfix).Trim();
                    }
                    else
                    {
                        s = string.Format("{0} {1} {2}", this._prefix, param, this._subfix).Trim();
                    }
                    break;

                case ValueParsingOption.ParseFloat:
                    double      floatVal;
                    CultureInfo culture = null;
                    try
                    {
                        culture = CultureInfo.GetCultureInfo(this._bindPropertyCultureName);
                    }
                    catch
                    {
                        //Do nothing
                    }
                    if (culture == null)
                    {
                        s = string.Format("{0} {1} {2}", this._prefix, param, this._subfix).Trim();
                    }
                    else
                    {
                        if (double.TryParse((string)param, NumberStyles.AllowDecimalPoint | NumberStyles.AllowThousands, culture, out floatVal))
                        {
                            s = string.Format("{0} {1} {2}", this._prefix, floatVal.ToString("#,###.##"), this._subfix).Trim();
                        }
                        else
                        {
                            s = string.Format("{0} {1} {2}", this._prefix, param, this._subfix).Trim();
                        }
                    }
                    break;
                }
            }
            if (param is int)
            {
                int intVal = (int)param;
                s = string.Format("{0} {1} {2}", this._prefix, (intVal).ToString("#,###"), this._subfix).Trim();
            }
            if ((param is double) || (param is float))
            {
                double floatVal = (double)param;
                s = string.Format("{0} {1} {2}", this._prefix, floatVal.ToString("#,###.##"), this._subfix).Trim();
            }

            if (base.Rect == XRect.Empty)
            {
                double x = tp.CmsToPts(this.X);
                double y = tp.CmsToPts(this.Y);
                gfx.DrawString(s, font, brush, x, y, XStringFormat.TopLeft);
            }
            else
            {
                XRect rect = tp.FromCmsToPts(base.Rect);
                gfx.DrawString(s, font, brush, rect, base.Format);
            }
        }
コード例 #4
0
        public void Draw(XGraphics gfx, double mapSF)
        {
            if (_visible)
            {
                TransformsProvider tp        = new TransformsProvider(gfx);
                double             x         = 0.0;
                double             y         = 0.0;
                double             width     = this._intervalSize * mapSF;
                XBrush             fillColor = new XSolidBrush(XColor.FromName(this._fillColorName));
                XFont  font          = new XFont(_fontFamilyName, _fontSize, _fontStyle);
                XBrush fontColor     = new XSolidBrush(XColor.FromName(this._fontColorName));
                XRect  firstInterval = XRect.Empty;
                switch (Anchor)
                {
                case AnchorType.TopLeft:
                    x = tp.CmsToPts(this._x);
                    y = tp.CmsToPts(_y) + font.Height;
                    break;

                case AnchorType.BottomLeft:
                    x = tp.CmsToPts(this._x);
                    y = tp.CmsToPts(_y) - this._height;
                    break;

                case AnchorType.TopRight:
                    x = tp.CmsToPts(this._x) - (width * this._numIntervals) - (font.Size * 1.5) - ((this._unit.Length + 1) * font.Size);
                    y = tp.CmsToPts(_y) + font.Height;
                    break;

                case AnchorType.BottomRight:
                    x = tp.CmsToPts(this._x) - (width * this._numIntervals) - (font.Size * 1.5) - ((this._unit.Length + 1) * font.Size);
                    y = tp.CmsToPts(_y) - this._height;
                    break;

                default:
                    x = tp.CmsToPts(this._x);
                    y = tp.CmsToPts(_y) - this._height;
                    break;
                }
                for (int i = 0; i <= this._numIntervals - 1; i++)
                {
                    if (i == 0)
                    {
                        firstInterval = new XRect(x, y, width, this._height);
                        gfx.DrawRectangle(new XPen(XColors.Black), firstInterval);
                    }
                    else
                    {
                        if (i % 2 == 0)
                        {
                            gfx.DrawRectangle(new XPen(XColors.Black), x + (width * i), y, width, this._height);
                        }
                        else
                        {
                            gfx.DrawRectangle(new XPen(XColors.Black), fillColor, x + (width * i), y, width, this._height);
                        }
                    }
                }
                x = firstInterval.Left;
                y = firstInterval.Top - font.Height;
                for (int i = 1; i <= this._numIntervals; i++)
                {
                    gfx.DrawString((this._intervalSize * i).ToString(), font, fontColor, x + (width * i), y, XStringFormat.TopCenter);
                }
                gfx.DrawString(this._unit, font, fontColor, x + (width * this._numIntervals) + (font.Size * 1.5), y, XStringFormat.TopLeft);
            }
        }