コード例 #1
0
        private void ShipStatusLevel_Paint(object sender, PaintEventArgs e)
        {
            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical);
            //e.Graphics.DrawRectangle( Pens.Magenta, new Rectangle( basearea.X, basearea.Y, basearea.Width - 1, basearea.Height - 1 ) );


            //*/

            //alignment.bottom

            Point p = new Point(basearea.X, basearea.Bottom - TextSizeCache.Height);

            TextRenderer.DrawText(e.Graphics, Text, SubFont, new Rectangle(p, TextSizeCache), SubFontColor, TextFormatText);
            //e.Graphics.DrawRectangle( Pens.Orange, new Rectangle( p, TextSizeCache ) );

            p.X += TextSizeCache.Width;
            p.Y  = basearea.Bottom - ValueSizeCache.Height;
            TextRenderer.DrawText(e.Graphics, Value.ToString(), MainFont, new Rectangle(p, ValueSizeCache), MainFontColor, TextFormatValue);
            //e.Graphics.DrawRectangle( Pens.Orange, new Rectangle( p, ValueSizeCache ) );


            p.X = basearea.Right - Math.Max(TextNextSizeCache.Width, ValueNextSizeCache.Width);
            p.Y = basearea.Bottom - TextNextSizeCache.Height - ValueNextSizeCache.Height + (int)(SubFont.Size / 2.0);
            if (TextNext != null)
            {
                TextRenderer.DrawText(e.Graphics, TextNext, SubFont, new Rectangle(p, TextNextSizeCache), SubFontColor, TextFormatText);
                //e.Graphics.DrawRectangle( Pens.Orange, new Rectangle( p, TextNextSizeCache ) );
            }

            p.Y = basearea.Bottom - ValueNextSizeCache.Height + 1;
            if (TextNext != null)
            {
                if (TextValueNext == "")
                {
                    TextRenderer.DrawText(e.Graphics, ValueNext.ToString(), SubFont, new Rectangle(p, ValueNextSizeCache), SubFontColor, TextFormatText);
                }
                else
                {
                    TextRenderer.DrawText(e.Graphics, TextValueNext, SubFont, new Rectangle(p, ValueNextSizeCache), SubFontColor, TextFormatText);
                }
                //e.Graphics.DrawRectangle( Pens.Orange, new Rectangle( p, ValueNextSizeCache ) );
            }
        }
コード例 #2
0
        private void ShipStatusLevel_Paint(object sender, PaintEventArgs e)
        {
            Size maxsize = new Size(int.MaxValue, int.MaxValue);

            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical);
            //e.Graphics.DrawRectangle( Pens.Magenta, new Rectangle( basearea.X, basearea.Y, basearea.Width - 1, basearea.Height - 1 ) );

            Size sz_value     = TextRenderer.MeasureText(Math.Max(Value, MaximumValue).ToString(), MainFont, maxsize, TextFormatValue);
            Size sz_text      = TextRenderer.MeasureText(Text, SubFont, maxsize, TextFormatText);
            Size sz_textnext  = TextRenderer.MeasureText(TextNext, SubFont, maxsize, TextFormatText);
            Size sz_valuenext = TextRenderer.MeasureText(Math.Max(ValueNext, MaximumValueNext).ToString(), SubFont, maxsize, TextFormatText);


            sz_value.Width -= (int)(MainFont.Size / 2.0);
            if (Text != null && Text.Length > 0)
            {
                sz_text.Width -= (int)(SubFont.Size / 2.0);
            }
            if (TextNext != null && TextNext.Length > 0)
            {
                sz_textnext.Width -= (int)(SubFont.Size / 2.0);
            }
            sz_valuenext.Width -= (int)(SubFont.Size / 2.0);

            if (TextNext == null)
            {
                sz_textnext.Width               =
                    sz_textnext.Height          =
                        sz_valuenext.Width      =
                            sz_valuenext.Height = 0;
            }
            //*/

            //alignment.bottom

            Point p = new Point(basearea.X, basearea.Bottom - sz_text.Height);

            TextRenderer.DrawText(e.Graphics, Text, SubFont, new Rectangle(p, sz_text), SubFontColor, TextFormatText);
            //e.Graphics.DrawRectangle( Pens.Orange, new Rectangle( p, sz_text ) );

            p.X += sz_text.Width;
            p.Y  = basearea.Bottom - sz_value.Height;
            TextRenderer.DrawText(e.Graphics, Value.ToString(), MainFont, new Rectangle(p, sz_value), MainFontColor, TextFormatValue);
            //e.Graphics.DrawRectangle( Pens.Orange, new Rectangle( p, sz_value ) );


            p.X = basearea.Right - Math.Max(sz_textnext.Width, sz_valuenext.Width);
            p.Y = basearea.Bottom - sz_textnext.Height - sz_valuenext.Height + (int)(SubFont.Size / 2.0);
            if (TextNext != null)
            {
                TextRenderer.DrawText(e.Graphics, TextNext, SubFont, new Rectangle(p, sz_textnext), SubFontColor, TextFormatText);
                //e.Graphics.DrawRectangle( Pens.Orange, new Rectangle( p, sz_textnext ) );
            }

            p.Y = basearea.Bottom - sz_valuenext.Height + 1;
            if (TextNext != null)
            {
                TextRenderer.DrawText(e.Graphics, ValueNext.ToString(), SubFont, new Rectangle(p, sz_valuenext), SubFontColor, TextFormatText);
                //e.Graphics.DrawRectangle( Pens.Orange, new Rectangle( p, sz_valuenext ) );
            }
        }