Пример #1
0
        /// <summary>
        /// ShipViewを更新します。
        /// </summary>
        private void ChangeShipView(ImageLabel target)
        {
            if (target == null)
            {
                return;
            }


            int groupID = (int)target.Tag;
            var group   = KCDatabase.Instance.ShipGroup[groupID];


            ApplyGroupData(SelectedTab);


            if (group == null)
            {
                Utility.Logger.Add(3, "エラー:存在しないグループを参照しようとしました。開発者に連絡してください");
                return;
            }
            if (group.GroupID < 0)
            {
                group.Members = group.Members.Intersect(KCDatabase.Instance.Ships.Keys).Union(KCDatabase.Instance.Ships.Keys).Distinct().ToList();
            }


            ShipView.SuspendLayout();

            ShipView.Rows.Clear();

            IEnumerable <ShipData> ships = group.MembersInstance;
            List <DataGridViewRow> rows  = new List <DataGridViewRow>(ships.Count());

            foreach (ShipData ship in ships)
            {
                if (ship == null)
                {
                    continue;
                }
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(ShipView);
                row.SetValues(
                    ship.MasterID,
                    ship.MasterShip.ShipType,
                    ship.MasterShip.Name,
                    ship.Level,
                    ship.ExpTotal,
                    ship.ExpNext,
                    ship.ExpNextRemodel,
                    new Fraction(ship.HPCurrent, ship.HPMax),
                    ship.Condition,
                    new Fraction(ship.Fuel, ship.MasterShip.Fuel),
                    new Fraction(ship.Ammo, ship.MasterShip.Ammo),
                    GetEquipmentString(ship, 0),
                    GetEquipmentString(ship, 1),
                    GetEquipmentString(ship, 2),
                    GetEquipmentString(ship, 3),
                    GetEquipmentString(ship, 4),
                    ship.FleetWithIndex,
                    ship.RepairingDockID == -1 ? ship.RepairTime : -1000 + ship.RepairingDockID,
                    ship.FirepowerBase,
                    ship.FirepowerRemain,
                    ship.TorpedoBase,
                    ship.TorpedoRemain,
                    ship.AABase,
                    ship.AARemain,
                    ship.ArmorBase,
                    ship.ArmorRemain,
                    ship.ASWBase,
                    ship.EvasionBase,
                    ship.LOSBase,
                    ship.LuckBase,
                    ship.LuckRemain,
                    ship.IsLocked,
                    ship.SallyArea
                    );

                row.Cells[ShipView_Name.Index].Tag  = ship.ShipID;
                row.Cells[ShipView_Level.Index].Tag = ship.ExpTotal;

                {
                    DataGridViewCellStyle cs;
                    double hprate = (double)ship.HPCurrent / Math.Max(ship.HPMax, 1);
                    if (hprate <= 0.25)
                    {
                        cs = CSRedRight;
                    }
                    else if (hprate <= 0.50)
                    {
                        cs = CSOrangeRight;
                    }
                    else if (hprate <= 0.75)
                    {
                        cs = CSYellowRight;
                    }
                    else if (hprate < 1.00)
                    {
                        cs = CSGreenRight;
                    }
                    else
                    {
                        cs = CSDefaultRight;
                    }

                    row.Cells[ShipView_HP.Index].Style = cs;
                }
                {
                    DataGridViewCellStyle cs;
                    if (ship.Condition < 20)
                    {
                        cs = CSRedRight;
                    }
                    else if (ship.Condition < 30)
                    {
                        cs = CSOrangeRight;
                    }
                    else if (ship.Condition < Utility.Configuration.Config.Control.ConditionBorder)
                    {
                        cs = CSYellowRight;
                    }
                    else if (ship.Condition < 50)
                    {
                        cs = CSDefaultRight;
                    }
                    else
                    {
                        cs = CSGreenRight;
                    }

                    row.Cells[ShipView_Condition.Index].Style = cs;
                }
                row.Cells[ShipView_Fuel.Index].Style = ship.Fuel < ship.MasterShip.Fuel ? CSYellowRight : CSDefaultRight;
                row.Cells[ShipView_Ammo.Index].Style = ship.Fuel < ship.MasterShip.Fuel ? CSYellowRight : CSDefaultRight;
                {
                    DataGridViewCellStyle cs;
                    if (ship.RepairTime == 0)
                    {
                        cs = CSDefaultRight;
                    }
                    else if (ship.RepairTime < 1000 * 60 * 60)
                    {
                        cs = CSYellowRight;
                    }
                    else if (ship.RepairTime < 1000 * 60 * 60 * 6)
                    {
                        cs = CSOrangeRight;
                    }
                    else
                    {
                        cs = CSRedRight;
                    }

                    row.Cells[ShipView_RepairTime.Index].Style = cs;
                }
                row.Cells[ShipView_FirepowerRemain.Index].Style = ship.FirepowerRemain == 0 ? CSGrayRight : CSDefaultRight;
                row.Cells[ShipView_TorpedoRemain.Index].Style   = ship.TorpedoRemain == 0 ? CSGrayRight : CSDefaultRight;
                row.Cells[ShipView_AARemain.Index].Style        = ship.AARemain == 0 ? CSGrayRight : CSDefaultRight;
                row.Cells[ShipView_ArmorRemain.Index].Style     = ship.ArmorRemain == 0 ? CSGrayRight : CSDefaultRight;
                row.Cells[ShipView_LuckRemain.Index].Style      = ship.LuckRemain == 0 ? CSGrayRight : CSDefaultRight;

                row.Cells[ShipView_Locked.Index].Style = ship.IsLocked ? CSIsLocked : CSDefaultCenter;


                rows.Add(row);
            }

            for (int i = 0; i < rows.Count; i++)
            {
                rows[i].Tag = i;
            }

            ShipView.Rows.AddRange(rows.ToArray());


            {
                int columnCount = ShipView.Columns.Count;
                if (group.ColumnFilter != null)
                {
                    columnCount = Math.Min(columnCount, group.ColumnFilter.Count);
                }
                if (group.ColumnWidth != null)
                {
                    columnCount = Math.Min(columnCount, group.ColumnWidth.Count);
                }


                for (int i = 0; i < columnCount; i++)
                {
                    ShipView.Columns[i].Visible = group.ColumnFilter[i];
                    ShipView.Columns[i].Width   = group.ColumnWidth[i];
                }
            }

            SetColumnAutoSize(group.ColumnAutoSize);
            SetLockShipNameScroll(group.LockShipNameScroll);


            ShipView.ResumeLayout();


            //status bar
            if (KCDatabase.Instance.Ships.Count > 0)
            {
                Status_ShipCount.Text    = string.Format("所属: {0}隻", group.Members.Count);
                Status_LevelTotal.Text   = string.Format("合計Lv: {0}", group.MembersInstance.Where(s => s != null).Sum(s => s.Level));
                Status_LevelAverage.Text = string.Format("平均Lv: {0:F2}", group.Members.Count > 0 ? group.MembersInstance.Where(s => s != null).Average(s => s.Level) : 0);
            }

            SelectedTab           = target;
            SelectedTab.BackColor = TabActiveColor;
        }
Пример #2
0
		public DialogAlbumMasterShip() {
			InitializeComponent();

			Aircrafts = new ImageLabel[] { Aircraft1, Aircraft2, Aircraft3, Aircraft4, Aircraft5 };
			Equipments = new ImageLabel[] { Equipment1, Equipment2, Equipment3, Equipment4, Equipment5 };


			TitleHP.ImageList =
			TitleFirepower.ImageList =
			TitleTorpedo.ImageList =
			TitleAA.ImageList =
			TitleArmor.ImageList =
			TitleASW.ImageList =
			TitleEvasion.ImageList =
			TitleLOS.ImageList =
			TitleLuck.ImageList =
			TitleSpeed.ImageList =
			TitleRange.ImageList =
			Rarity.ImageList =
			Fuel.ImageList =
			Ammo.ImageList =
			TitleBuildingTime.ImageList =
			MaterialFuel.ImageList =
			MaterialAmmo.ImageList =
			MaterialSteel.ImageList =
			MaterialBauxite.ImageList =
			PowerUpFirepower.ImageList =
			PowerUpTorpedo.ImageList =
			PowerUpAA.ImageList =
			PowerUpArmor.ImageList =
			RemodelBeforeLevel.ImageList =
			RemodelBeforeAmmo.ImageList =
			RemodelBeforeSteel.ImageList =
			RemodelAfterLevel.ImageList =
			RemodelAfterAmmo.ImageList =
			RemodelAfterSteel.ImageList =
				ResourceManager.Instance.Icons;

			TitleAirSuperiority.ImageList =
			TitleDayAttack.ImageList =
			TitleNightAttack.ImageList =
			Equipment1.ImageList =
			Equipment2.ImageList =
			Equipment3.ImageList =
			Equipment4.ImageList =
			Equipment5.ImageList =
				ResourceManager.Instance.Equipments;

			TitleHP.ImageIndex = (int)ResourceManager.IconContent.ParameterHP;
			TitleFirepower.ImageIndex = (int)ResourceManager.IconContent.ParameterFirepower;
			TitleTorpedo.ImageIndex = (int)ResourceManager.IconContent.ParameterTorpedo;
			TitleAA.ImageIndex = (int)ResourceManager.IconContent.ParameterAA;
			TitleArmor.ImageIndex = (int)ResourceManager.IconContent.ParameterArmor;
			TitleASW.ImageIndex = (int)ResourceManager.IconContent.ParameterASW;
			TitleEvasion.ImageIndex = (int)ResourceManager.IconContent.ParameterEvasion;
			TitleLOS.ImageIndex = (int)ResourceManager.IconContent.ParameterLOS;
			TitleLuck.ImageIndex = (int)ResourceManager.IconContent.ParameterLuck;
			TitleSpeed.ImageIndex = (int)ResourceManager.IconContent.ParameterSpeed;
			TitleRange.ImageIndex = (int)ResourceManager.IconContent.ParameterRange;
			Fuel.ImageIndex = (int)ResourceManager.IconContent.ResourceFuel;
			Ammo.ImageIndex = (int)ResourceManager.IconContent.ResourceAmmo;
			TitleBuildingTime.ImageIndex = (int)ResourceManager.IconContent.FormArsenal;
			MaterialFuel.ImageIndex = (int)ResourceManager.IconContent.ResourceFuel;
			MaterialAmmo.ImageIndex = (int)ResourceManager.IconContent.ResourceAmmo;
			MaterialSteel.ImageIndex = (int)ResourceManager.IconContent.ResourceSteel;
			MaterialBauxite.ImageIndex = (int)ResourceManager.IconContent.ResourceBauxite;
			PowerUpFirepower.ImageIndex = (int)ResourceManager.IconContent.ParameterFirepower;
			PowerUpTorpedo.ImageIndex = (int)ResourceManager.IconContent.ParameterTorpedo;
			PowerUpAA.ImageIndex = (int)ResourceManager.IconContent.ParameterAA;
			PowerUpArmor.ImageIndex = (int)ResourceManager.IconContent.ParameterArmor;
			RemodelBeforeAmmo.ImageIndex = (int)ResourceManager.IconContent.ResourceAmmo;
			RemodelBeforeSteel.ImageIndex = (int)ResourceManager.IconContent.ResourceSteel;
			RemodelAfterAmmo.ImageIndex = (int)ResourceManager.IconContent.ResourceAmmo;
			RemodelAfterSteel.ImageIndex = (int)ResourceManager.IconContent.ResourceSteel;
			TitleAirSuperiority.ImageIndex = (int)ResourceManager.EquipmentContent.CarrierBasedFighter;
			TitleDayAttack.ImageIndex = (int)ResourceManager.EquipmentContent.Seaplane;
			TitleNightAttack.ImageIndex = (int)ResourceManager.EquipmentContent.Torpedo;

			TableBattle.Visible = false;
			BasePanelShipGirl.Visible = false;


			ControlHelper.SetDoubleBuffered( TableShipName );
			ControlHelper.SetDoubleBuffered( TableParameterMain );
			ControlHelper.SetDoubleBuffered( TableParameterSub );
			ControlHelper.SetDoubleBuffered( TableConsumption );
			ControlHelper.SetDoubleBuffered( TableEquipment );
			ControlHelper.SetDoubleBuffered( TableArsenal );
			ControlHelper.SetDoubleBuffered( TableRemodel );
			ControlHelper.SetDoubleBuffered( TableBattle );

			ControlHelper.SetDoubleBuffered( ShipView );


			//ShipView Initialize
			ShipView.SuspendLayout();

			ShipView_ShipID.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;
			ShipView_ShipType.AutoSizeMode = DataGridViewAutoSizeColumnMode.None;


			ShipView.Rows.Clear();

			List<DataGridViewRow> rows = new List<DataGridViewRow>( KCDatabase.Instance.MasterShips.Values.Count( s => s.Name != "なし" ) );

			foreach ( var ship in KCDatabase.Instance.MasterShips.Values ) {

				if ( ship.Name == "なし" ) continue;

				DataGridViewRow row = new DataGridViewRow();
				row.CreateCells( ShipView );
				row.SetValues( ship.ShipID, KCDatabase.Instance.ShipTypes[ship.ShipType].Name, ship.NameWithClass );
				rows.Add( row );

			}
			ShipView.Rows.AddRange( rows.ToArray() );

			ShipView_ShipID.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;
			ShipView_ShipType.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCellsExceptHeader;

			ShipView.Sort( ShipView_ShipID, ListSortDirection.Ascending );
			ShipView.ResumeLayout();
		}