コード例 #1
0
ファイル: Range.cs プロジェクト: ekolis/stars-nova
        /// ----------------------------------------------------------------------------
        /// <summary>
        /// Paint the indicator part of the Bar control and the label displaying the
        /// numeric values.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param>
        /// ----------------------------------------------------------------------------
        private void Bar_Paint(object sender, PaintEventArgs e)
        {
            if (immunityCheckBox.Checked)
            {
                e.Graphics.Clear(Color.Black);
                this.boxSpan.Text = "N/A";
                return;
            }

            int fillHeight = this.bar.Size.Height;
            int fillY      = 0;

            int fillLeft  = (int)((this.boxLeftPosition * this.bar.Size.Width) / GetBoxRange());
            int fillRight = (int)((this.boxRightPosition * this.bar.Size.Width) / GetBoxRange());
            int fillWidth = fillRight - fillLeft;

            // Might Do: Delegate:
            string realRange;

            if (this.units == Gravity.GetUnit())
            {
                realRange = string.Format(
                    "{0}{2} to {1}{2}",
                    Gravity.Format(this.boxLeftPosition),
                    Gravity.Format(this.boxRightPosition),
                    Gravity.GetUnit());
            }
            else if (this.units == "mR")
            {
                realRange = string.Format(
                    "{0}{2} to {1}{2}",
                    this.boxLeftPosition.ToString("F0"),
                    this.boxRightPosition.ToString("F0"),
                    this.units);
            }
            else
            {
                // Temperature
                realRange = string.Format(
                    "{0}{2} to {1}{2}",
                    Temperature.Format(this.boxLeftPosition),
                    Temperature.Format(this.boxRightPosition),
                    Temperature.GetUnit());
            }

            this.boxSpan.Text = realRange;

            e.Graphics.FillRectangle(this.boxBrush, fillLeft, fillY, fillWidth, fillHeight);
        }