public PresetFleetWindowViewModel() { this.Title = "함대 프리셋"; this.LoadFleets(); this.SelectedFleet = this.Fleets.FirstOrDefault(); }
public void DeleteFleet(PresetFleetData fleet) { this.Fleets = this.Fleets .Where(x => x != fleet) .ToArray(); if (this.SelectedFleet == fleet) { this.SelectedFleet = this.Fleets.FirstOrDefault(); } SaveFleets(); }
public void AddFleet(PresetFleetData fleet) { this.Fleets = this.Fleets .Concat(new PresetFleetData[] { fleet }) .ToArray(); if (this.SelectedFleet == null) { this.SelectedFleet = this.Fleets.FirstOrDefault(); } SaveFleets(); }
public void AddFleet(PresetFleetData fleet) { var list = this.Fleets.ToList(); list.Add(fleet); this.Fleets = list.ToArray(); if (this.SelectedFleet == null) { this.SelectedFleet = this.Fleets.FirstOrDefault(); } SaveFleets(); }
public void AddByFleet(string data) { int deckid; if (!int.TryParse(data, out deckid)) { return; } if (deckid > 0) { var KanColleFleets = KanColleClient.Current.Homeport.Organization.Fleets; if (KanColleClient.Current.IsStarted == false || KanColleFleets.Count < deckid || KanColleFleets[deckid].Ships.Count() < 1) { return; } var fleet = KanColleClient.Current.Homeport.Organization.Fleets.Where(x => x.Value.Id == deckid).Single().Value; var ships = fleet.Ships; var item = new PresetFleetData(); List <string> shipDataList = new List <string>(); foreach (var ship in ships) { shipDataList.Add(string.Format( "{0}\t{1}\t{2}", ship.Id, string.Join(",", ship.Slots.Where(x => x.Equipped).Select(x => x.Item.Id)), (ship.ExSlotExists && ship.ExSlot.Equipped) ? ship.ExSlot.Item.Id : -1 )); } item.Deserialize( string.Format( "{0}\t{1}", string.IsNullOrEmpty(this.FleetName) ? fleet.Name : this.FleetName, string.Join("\t", shipDataList) ) ); this._ViewModel.AddFleet(item); Messenger.Raise(new WindowActionMessage(WindowAction.Close, "Close")); } }
public void LoadFleets() { var list = new List <PresetFleetData>(); if (File.Exists(RecordPath)) { var lines = File.ReadAllText(RecordPath) .Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { var item = new PresetFleetData(); item.Deserialize(line); list.Add(item); } } this.Fleets = list.ToArray(); this.SelectedFleet = this.Fleets.FirstOrDefault(); }
public PresetFleetDeleteWindowViewModel(PresetFleetWindowViewModel viewmodel, PresetFleetData targetfleet) { this._ViewModel = viewmodel; this._TargetFleet = targetfleet; }