public SystemHistoryViewModel(Int64 systemAddress, List <DESystemsForDisplay> deSystemsForDisplay) { _displayDESystems = deSystemsForDisplay; DeLogo = helper.Convert(DETrackerWPF.Properties.Resources.DELogo); Info = helper.Convert(DETrackerWPF.Properties.Resources.InfoBlue); Analytics = helper.Convert(DETrackerWPF.Properties.Resources.analytics); EliteBGS = helper.Convert(DETrackerWPF.Properties.Resources.EliteBGS); DESystemsForDisplay selectedSystem = dataAccess.ReadUpdatedSystem(systemAddress.ToString()); ActiveStarSystem = selectedSystem.StarSystem; DisplayHistoryData(selectedSystem, ""); //if (selectedSystem.SysFaction == null) //{ // selectedSystem.SysFaction = new SystemFaction(); // selectedSystem.SysFaction.Name = string.Empty; //} HeaderSummary = string.Format("Star System: {0} | Population: {1:###,###,###,###} | Controlling Faction: {2} | Government: {3}\r\nAlligence: {4} | Economies: {5} | Security: {6}", selectedSystem.StarSystem, selectedSystem.Population, selectedSystem.SysFaction.Name, Helper.Clean(selectedSystem.SystemGovernment), selectedSystem.SystemAllegiance, Helper.Clean(selectedSystem.SystemEconomy) + "/" + Helper.Clean(selectedSystem.SystemSecondEconomy), Helper.Clean(selectedSystem.SystemSecurity)); // var FactionsInSystem = selectedSystem.FactionHistory[selectedSystem.FactionHistory.Count - 1].Factions.Count; Factions.Clear(); foreach (FullFactionData Faction in selectedSystem.FactionHistory[selectedSystem.FactionHistory.Count - 1].Factions) { // Dump Pilots' Federation Local Branch if (Faction.Name.Contains("Federation Local Branch")) { continue; } FactionModel f = new FactionModel(); f.FactionName = Faction.Name; f.GovernmentaAllegiance = Faction.Government + " / " + Faction.Allegiance; Faction1 = new ObservableCollection <SystemsFactionsHistory>(SystemHistory.Where(x => x.FactionName == Faction.Name)); f.FactionHistory = new ObservableCollection <DisplayFactionHist>(BuildHistory(Faction1)); Factions.Add(f); // Sort the Headers FactionHeadersModel fh = new FactionHeadersModel(); fh.InfHeader = "Inf"; fh.ChgHeader = "Chg"; fh.StateHeader = "Active States"; FactionHeaders.Add(fh); } // Reverse the faction list so Dark Echo are the first column Factions.Reverse(); }
static public void Run() { Console.WriteLine("------------Memento------------"); ComputerSystem computerSystem = new ComputerSystem("4.12"); SystemHistory history = new SystemHistory(); history.Points.Push(computerSystem.CreateSystemPoint()); computerSystem.Version = "5.01"; Console.WriteLine("New Version: " + computerSystem.Version); computerSystem.RestoreSystem(history.Points.Pop()); Console.WriteLine("Version after restore: " + computerSystem.Version); }
/// <summary> /// /// </summary> /// <param name="DESystem"></param> /// <param name="stateToDisplay"></param> public void DisplayHistoryData(DESystemsForDisplay DESystem, string stateToDisplay) { // Get the history list and reverse sort so latest is first. List <DESystemsHistory> sysHist = new List <DESystemsHistory>(DESystem.FactionHistory); sysHist = sysHist.OrderByDescending(r => r.timestamp).ToList(); foreach (var fhr in sysHist) { TimeSpan span = DateTime.Today.Subtract(fhr.timestamp.Date); if (!ShellViewModel.DisplayFullHistory) { if ((int)span.TotalDays > 30) { continue; } } // Sort the Dates HistoryDatesList hdl = new HistoryDatesList(); hdl.HistDate = fhr.timestamp.ToShortDateString(); HistDates.Add(hdl); SystemsFactionsHistory sfh = new SystemsFactionsHistory(); sfh.FactionHist = new ObservableCollection <FactionHistData>(); sfh.UpdatedAt = fhr.timestamp; // Get the index to the current history record var histIndex = sysHist.FindIndex(m => m.timestamp == fhr.timestamp); // Create temp list of factions and sort in influence order List <FullFactionData> fhs = new List <FullFactionData>(fhr.Factions); // Dump "Pilots Federation Local Branch" from the new list fhs.RemoveAll(x => x.Name.Contains("Federation Local Branch")); foreach (var fullFactionData in fhs) { SystemsFactionsHistory sysFactionHist = new SystemsFactionsHistory(); sysFactionHist.FactionHist = new ObservableCollection <FactionHistData>(); sysFactionHist.FactionName = fullFactionData.Name; sysFactionHist.UpdatedAt = fhr.timestamp; FactionHistData factionHistoryData = new FactionHistData(); factionHistoryData.fInf = fullFactionData.Influence; if (fullFactionData.ActiveStates != null) { fullFactionData.ActiveStates = AddSpaces(fullFactionData.ActiveStates); factionHistoryData.ActiveStates = new ObservableCollection <States>(fullFactionData.ActiveStates); } if (fullFactionData.PendingStates != null) { fullFactionData.PendingStates = AddSpaces(fullFactionData.PendingStates); factionHistoryData.PendingStates = new ObservableCollection <States>(fullFactionData.PendingStates); } if (fullFactionData.RecoveringStates != null) { fullFactionData.RecoveringStates = AddSpaces(fullFactionData.RecoveringStates); factionHistoryData.RecoveringStates = new ObservableCollection <States>(fullFactionData.RecoveringStates); } sysFactionHist.FactionHist.Add(factionHistoryData); SystemHistory.Add(sysFactionHist); } SystemHistory.Add(sfh); } }