Пример #1
0
        private void ShipStatusHP_Paint(object sender, PaintEventArgs e)
        {
            Size maxsize = new Size(99999, 99999);


            Graphics  g        = e.Graphics;
            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical);
            Size      barSize  = _HPBar.GetPreferredSize(new Size(basearea.Width, 0));



            if (RepairTime != null)
            {
                string timestr = DateTimeHelper.ToTimeRemainString((DateTime)RepairTime);

                Size sz_time = TextRenderer.MeasureText(timestr, MainFont, maxsize, TextFormatTime);

                TextRenderer.DrawText(g, timestr, MainFont, new Rectangle(basearea.X, basearea.Y, basearea.Width, basearea.Height - barSize.Height), RepairFontColor, TextFormatTime);

                /*/
                 * g.DrawRectangle( Pens.Magenta, new Rectangle( basearea.X, basearea.Y, basearea.Width - 1, basearea.Height - BarThickness - BarBackgroundOffset - 1 ) );
                 * //*/
            }
            else
            {
                Size sz_text  = TextRenderer.MeasureText(Text, SubFont, maxsize, TextFormatText);
                Size sz_hpmax = TextRenderer.MeasureText(Math.Max(MaximumValue, MaximumDigit).ToString(), SubFont, maxsize, TextFormatHP);
                Size sz_slash = TextRenderer.MeasureText(" / ", SubFont, maxsize, TextFormatHP);
                Size sz_hpnow = TextRenderer.MeasureText(Math.Max(Value, MaximumDigit).ToString(), MainFont, maxsize, TextFormatHP);

                if (Text.Length > 0)
                {
                    sz_text.Width -= (int)(SubFont.Size / 2.0);
                }
                sz_hpmax.Width -= (int)(SubFont.Size / 2.0);
                sz_slash.Width -= (int)(SubFont.Size / 2.0);
                sz_hpnow.Width -= (int)(MainFont.Size / 2.0);



                Point p = new Point(basearea.X, basearea.Bottom - barSize.Height - sz_text.Height + 1);
                TextRenderer.DrawText(g, Text, SubFont, new Rectangle(p, sz_text), SubFontColor, TextFormatText);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, sz_text ) );

                p.X = basearea.Right - sz_hpmax.Width;
                TextRenderer.DrawText(g, !ShowDifference ? MaximumValue.ToString() : GetDifferenceString(), SubFont, new Rectangle(p, sz_hpmax), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, sz_hpmax ) );

                p.X -= sz_slash.Width;
                TextRenderer.DrawText(g, " / ", SubFont, new Rectangle(p, sz_slash), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, sz_slash ) );

                p.X -= sz_hpnow.Width;
                p.Y  = basearea.Bottom - barSize.Height - sz_hpnow.Height + 1;
                TextRenderer.DrawText(g, Math.Max(Value, 0).ToString(), MainFont, new Rectangle(p, sz_hpnow), MainFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, sz_hpnow ) );
            }

            _HPBar.Paint(g, new Rectangle(basearea.X, basearea.Bottom - barSize.Height, barSize.Width, barSize.Height));
        }
        private void ShipStatusResource_Paint(object sender, PaintEventArgs e)
        {
            const int margin = 3;

            BarFuel.Paint(e.Graphics, new Rectangle(0, margin, this.Width, BarFuel.GetPreferredSize().Height));
            BarAmmo.Paint(e.Graphics, new Rectangle(0, this.Height - margin - BarFuel.GetPreferredSize().Height, this.Width, BarFuel.GetPreferredSize().Height));
        }
Пример #3
0
        private void ShipStatusHP_Paint(object sender, PaintEventArgs e)
        {
            Graphics  g        = e.Graphics;
            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical);
            Size      barSize  = ShowHPBar ? _HPBar.GetPreferredSize(new Size(basearea.Width, 0)) : Size.Empty;



            if (RepairTimeShowMode == ShipStatusHPRepairTimeShowMode.Visible ||
                (RepairTimeShowMode == ShipStatusHPRepairTimeShowMode.MouseOver && _onMouse))
            {
                string timestr = DateTimeHelper.ToTimeRemainString((DateTime)RepairTime);

                var  rect = new Rectangle(basearea.X, basearea.Y, basearea.Width, basearea.Height - barSize.Height);
                Font font;
                if (rect.Width >= RepairTimeSizeCache.Width)
                {
                    font = MainFont;
                }
                else
                {
                    font = SubFont;
                }

                TextRenderer.DrawText(g, timestr, font, rect, RepairFontColor, TextFormatTime);
            }
            else
            {
                Point p = new Point(basearea.X, basearea.Bottom - barSize.Height - Math.Max(TextSizeCache.Height, MaximumValueSizeCache.Height) + 1);
                TextRenderer.DrawText(g, Text, SubFont, new Rectangle(p, TextSizeCache), SubFontColor, TextFormatText);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, TextSizeCache ) );

                p.X = basearea.Right - MaximumValueSizeCache.Width;
                TextRenderer.DrawText(g, !ShowDifference ? MaximumValue.ToString() : GetDifferenceString(), SubFont, new Rectangle(p, MaximumValueSizeCache), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, MaximumValueSizeCache ) );

                p.X -= SlashSizeCache.Width;
                TextRenderer.DrawText(g, SlashText, SubFont, new Rectangle(p, SlashSizeCache), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, SlashSizeCache ) );

                p.X -= ValueSizeCache.Width;
                p.Y  = basearea.Bottom - barSize.Height - ValueSizeCache.Height + 1;
                TextRenderer.DrawText(g, Math.Max(Value, 0).ToString(), MainFont, new Rectangle(p, ValueSizeCache), MainFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, ValueSizeCache ) );
            }

            if (ShowHPBar)
            {
                _HPBar.Paint(g, new Rectangle(basearea.X, basearea.Bottom - barSize.Height, barSize.Width, barSize.Height));
            }
        }
Пример #4
0
        private void ShipStatusHP_Paint(object sender, PaintEventArgs e)
        {
            Graphics  g        = e.Graphics;
            Rectangle basearea = new Rectangle(Padding.Left, Padding.Top, Width - Padding.Horizontal, Height - Padding.Vertical);
            Size      barSize  = _HPBar.GetPreferredSize(new Size(basearea.Width, 0));



            if (RepairTime != null)
            {
                string timestr = DateTimeHelper.ToTimeRemainString((DateTime)RepairTime);

                TextRenderer.DrawText(g, timestr, MainFont, new Rectangle(basearea.X, basearea.Y, basearea.Width, basearea.Height - barSize.Height), RepairFontColor, TextFormatTime);

                /*/
                 * g.DrawRectangle( Pens.Magenta, new Rectangle( basearea.X, basearea.Y, basearea.Width - 1, basearea.Height - BarThickness - BarBackgroundOffset - 1 ) );
                 * //*/
            }
            else
            {
                Point p = new Point(basearea.X, basearea.Bottom - barSize.Height - Math.Max(TextSizeCache.Height, MaximumValueSizeCache.Height) + 1);
                TextRenderer.DrawText(g, Text, SubFont, new Rectangle(p, TextSizeCache), SubFontColor, TextFormatText);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, TextSizeCache ) );

                p.X = basearea.Right - MaximumValueSizeCache.Width;
                TextRenderer.DrawText(g, !ShowDifference ? MaximumValue.ToString() : GetDifferenceString(), SubFont, new Rectangle(p, MaximumValueSizeCache), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, MaximumValueSizeCache ) );

                p.X -= SlashSizeCache.Width;
                TextRenderer.DrawText(g, SlashText, SubFont, new Rectangle(p, SlashSizeCache), SubFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, SlashSizeCache ) );

                p.X -= ValueSizeCache.Width;
                p.Y  = basearea.Bottom - barSize.Height - ValueSizeCache.Height + 1;
                TextRenderer.DrawText(g, Math.Max(Value, 0).ToString(), MainFont, new Rectangle(p, ValueSizeCache), MainFontColor, TextFormatHP);
                //g.DrawRectangle( Pens.Orange, new Rectangle( p, ValueSizeCache ) );
            }

            _HPBar.Paint(g, new Rectangle(basearea.X, basearea.Bottom - barSize.Height, barSize.Width, barSize.Height));
        }