/// <summary> /// 詳細ビューを更新します。 /// </summary> private void UpdateDetailView(int equipmentID) { DetailView.SuspendLayout(); DetailView.Rows.Clear(); //装備数カウント var eqs = KCDatabase.Instance.Equipments.Values.Where(eq => eq.EquipmentID == equipmentID); var countlist = new IDDictionary <DetailCounter>(); foreach (var eq in eqs) { var c = countlist[DetailCounter.CalculateID(eq)]; if (c == null) { countlist.Add(new DetailCounter(eq.Level, eq.AircraftLevel)); c = countlist[DetailCounter.CalculateID(eq)]; } c.countAll++; c.countRemain++; c.countRemainPrev++; } //装備艦集計 foreach (var ship in KCDatabase.Instance.Ships.Values) { foreach (var eq in ship.AllSlotInstance.Where(s => s != null && s.EquipmentID == equipmentID)) { countlist[DetailCounter.CalculateID(eq)].countRemain--; } foreach (var c in countlist.Values) { if (c.countRemain != c.countRemainPrev) { int diff = c.countRemainPrev - c.countRemain; c.equippedShips.Add(ship.NameWithLevel + (diff > 1 ? (" x" + diff) : "")); c.countRemainPrev = c.countRemain; } } } // 基地航空隊 - 配備中の装備を集計 foreach (var corps in KCDatabase.Instance.BaseAirCorps.Values) { foreach (var sq in corps.Squadrons.Values.Where(sq => sq != null && sq.EquipmentID == equipmentID)) { countlist[DetailCounter.CalculateID(sq.EquipmentInstance)].countRemain--; } foreach (var c in countlist.Values) { if (c.countRemain != c.countRemainPrev) { int diff = c.countRemainPrev - c.countRemain; c.equippedShips.Add(string.Format("#{0} {1}{2}", corps.MapAreaID, corps.Name, diff > 1 ? (" x" + diff) : "")); c.countRemainPrev = c.countRemain; } } } // 基地航空隊 - 配置転換中の装備を集計 foreach (var eq in KCDatabase.Instance.RelocatedEquipments.Values .Select(v => v.EquipmentInstance) .Where(eq => eq != null && eq.EquipmentID == equipmentID)) { countlist[DetailCounter.CalculateID(eq)].countRemain--; } foreach (var c in countlist.Values) { if (c.countRemain != c.countRemainPrev) { int diff = c.countRemainPrev - c.countRemain; c.equippedShips.Add("配置転換中" + (diff > 1 ? (" x" + diff) : "")); c.countRemainPrev = c.countRemain; } } //行に反映 var rows = new List <DataGridViewRow>(eqs.Count()); foreach (var c in countlist.Values) { if (c.equippedShips.Count() == 0) { c.equippedShips.Add(""); } foreach (var s in c.equippedShips) { var row = new DataGridViewRow(); row.CreateCells(DetailView); row.SetValues(c.level, c.aircraftLevel, c.countAll, c.countRemain, s); rows.Add(row); } } DetailView.Rows.AddRange(rows.ToArray()); DetailView.Sort(DetailView_AircraftLevel, ListSortDirection.Ascending); DetailView.Sort(DetailView_Level, ListSortDirection.Ascending); DetailView.ResumeLayout(); Text = EncycloRes.EquipmentList + " - " + KCDatabase.Instance.MasterEquipments[equipmentID].Name; }
/// <summary> /// 詳細ビューを更新します。 /// </summary> private void UpdateDetailView(int equipmentID) { DetailView.SuspendLayout(); DetailView.Rows.Clear(); //装備数カウント var eqs = KCDatabase.Instance.Equipments.Values.Where(eq => eq.EquipmentID == equipmentID); var countlist = new IDDictionary <DetailCounter>(); foreach (var eq in eqs) { var c = countlist[eq.Level]; if (c == null) { countlist.Add(new DetailCounter(eq.Level)); c = countlist[eq.Level]; } c.countAll++; c.countRemain++; c.countRemainPrev++; } //装備艦集計 foreach (var ship in KCDatabase.Instance.Ships.Values) { foreach (var eq in ship.SlotInstance.Where(s => s != null && s.EquipmentID == equipmentID)) { countlist[eq.Level].countRemain--; } foreach (var c in countlist.Values) { if (c.countRemain != c.countRemainPrev) { int diff = c.countRemainPrev - c.countRemain; c.equippedShips.Add(ship.NameWithLevel + (diff > 1 ? (" x" + diff) : "")); c.countRemainPrev = c.countRemain; } } } //行に反映 var rows = new List <DataGridViewRow>(eqs.Count()); foreach (var c in countlist.Values) { if (c.equippedShips.Count() == 0) { c.equippedShips.Add(""); } foreach (var s in c.equippedShips) { var row = new DataGridViewRow(); row.CreateCells(DetailView); row.SetValues(c.level, c.countAll, c.countRemain, s); rows.Add(row); } } DetailView.Rows.AddRange(rows.ToArray()); DetailView.Sort(DetailView_Level, ListSortDirection.Ascending); DetailView.ResumeLayout(); Text = EncycloRes.EquipmentList + " - " + KCDatabase.Instance.MasterEquipments[equipmentID].Name; }