示例#1
0
        /// ----------------------------------------------------------------------------
        /// <Summary>
        /// Populate the display. We use unbound population because some of the fields
        /// need a little logic to decode (we don't just have a bunch of strings).
        /// </Summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ----------------------------------------------------------------------------
        private void OnLoad(object sender, EventArgs e)
        {
            const int NumColumns = 12;

            this.planetGridView.Columns[8].Name = "Minerals";
            this.planetGridView.AutoSize        = true;

            foreach (Star report in empireState.OwnedStars.Values)
            {
                if (report.Owner == empireState.Id)
                {
                    string[] row = new string[NumColumns];

                    string starbase = "-";
                    if (report.Starbase != null)
                    {
                        starbase = report.Starbase.Name;
                    }

                    int i = 0;
                    row[i++] = report.Name;
                    row[i++] = starbase;
                    row[i++] = report.Colonists.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    row[i++] = report.Capacity(empireState.Race).ToString(System.Globalization.CultureInfo.InvariantCulture);
                    row[i++] = Math.Ceiling(empireState.Race.HabValue(report) * 100).ToString(System.Globalization.CultureInfo.InvariantCulture);
                    row[i++] = report.Mines.ToString(System.Globalization.CultureInfo.InvariantCulture);
                    row[i++] = report.Factories.ToString(System.Globalization.CultureInfo.InvariantCulture);

                    Defenses.ComputeDefenseCoverage(report);
                    row[i++] = Defenses.SummaryCoverage.ToString(System.Globalization.CultureInfo.InvariantCulture);

                    Nova.Common.Resources resources = report.ResourcesOnHand;
                    StringBuilder         text      = new StringBuilder();

                    text.AppendFormat(
                        "{0} {1} {2}",
                        resources.Ironium,
                        resources.Boranium,
                        resources.Germanium);

                    string energy = ((int)resources.Energy).ToString(System.Globalization.CultureInfo.InvariantCulture);

                    row[i++] = text.ToString();

                    resources = report.MineralConcentration;
                    text      = new StringBuilder();

                    text.AppendFormat(
                        "{0} {1} {2}",
                        resources.Ironium,
                        resources.Boranium,
                        resources.Germanium);
                    row[i++] = text.ToString();
                    row[i++] = energy;

                    this.planetGridView.Rows.Add(row);
                }
            }

            this.planetGridView.AutoResizeColumns();
        }