/// <summary> /// Work out number of systems where our influence moved up, down or remained unchanged /// </summary> void CalculateSystemMovements() { var SystemsUpdatedSinceTick = DarkEchoSystems.Where(x => x.VisitsToday > 0).ToList(); var SystemsNotUpdatedSinceTick = DarkEchoSystems.Where(x => x.VisitsToday == 0).ToList(); if (DateTime.Compare(DateTime.UtcNow, dataAccess.TickTime) > 0) { SystemsUpdatedSinceTick.Clear(); SystemsUpdatedSinceTick = DarkEchoSystems.Where(x => x.Updated > dataAccess.TickTime).ToList(); SystemsUp = SystemsUpdatedSinceTick.Count(x => x.InfluenceChange > 0.0); SystemsDown = SystemsUpdatedSinceTick.Count(x => x.InfluenceChange < 0.0); } else { // For systems that have not been updated we can use the displayed influence change value SystemsUp = SystemsNotUpdatedSinceTick.Count(x => x.InfluenceChange > 0.0); SystemsDown = SystemsNotUpdatedSinceTick.Count(x => x.InfluenceChange < 0.0); // For systems that have been updated use the calculated hidden change value. SystemsUp = SystemsUp + SystemsUpdatedSinceTick.Count(x => x.InfluenceChangePrev > 0.0); SystemsDown = SystemsDown + SystemsUpdatedSinceTick.Count(x => x.InfluenceChangePrev < 0.0); } SystemsNoChange = DarkEchoSystems.Count - (SystemsUp + SystemsDown); }
/// <summary> /// Fires every 100ms to check if a DB update has been received. /// Would be better to deal with this in the dependency event but proved unreliable /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void UpdateTimer_Tick(object sender, EventArgs e) { if (dataAccess.SystemUpdated) { UpdatedDisplayDESystems = displayDESystems.FindAll(x => x.Updated); foreach (var deSystem in UpdatedDisplayDESystems) { var index = DarkEchoSystems.IndexOf(DarkEchoSystems.First(x => x.StarSystemName == deSystem.StarSystem)); DarkEchoSystems[index] = dataAccess.BuildDisplayLine(deSystem); DarkEchoSystems[index].HighLight = true; Task.Delay(7500).ContinueWith(t => ClearHightlight(index)); } foreach (var deSystem in UpdatedDisplayDESystems) { dataAccess.displayDESystems[ dataAccess.displayDESystems.FindIndex(x => x.StarSystem == deSystem.StarSystem)].Updated = false; } dataAccess.SystemUpdated = false; dataAccess.CalculateAverageChange(); DisplayFactionInfAvgAndChange(); CalculateSystemMovements(); } }
public OxyPlotChartViewModel(List <DESystemsForDisplay> displayDESystems, string SystemToDisplay) { RightArrow = helper.Convert(DETrackerWPF.Properties.Resources.rightArrow); LeftArrow = helper.Convert(DETrackerWPF.Properties.Resources.leftArrow); _deSystems = displayDESystems; DarkEchoSystems = _deSystems.Select(x => x.StarSystem).ToList(); GenerateDataLIsts(); if (SystemToDisplay.Length > 0) { SelectedSystemIndex = DarkEchoSystems.IndexOf(SystemToDisplay); } PlotModel = new PlotModel { Title = "Faction Performance" }; PlotModel.LegendPlacement = LegendPlacement.Outside; PlotModel.LegendPosition = LegendPosition.RightTop; PlotModel.LegendBackground = OxyColor.FromAColor(200, OxyColors.White); PlotModel.LegendBorder = OxyColors.Black; PlotModel.TitleHorizontalAlignment = TitleHorizontalAlignment.CenteredWithinView; PlotModel.TitleFontSize = 24; PlotModel.TitlePadding = 20; PlotModel.TitleColor = OxyColors.MidnightBlue; }
/// <summary> /// Grab all systems that we control or have a presence in and build the Datagrid line /// </summary> /// <param name="_deSystemsForDisplay"></param> /// <returns></returns> private void GetListViewData() { BindableCollection <DarkEchoSystemsModel> lvdList = new BindableCollection <DarkEchoSystemsModel>(); foreach (var sd in dataAccess.displayDESystems) { DarkEchoSystems.Add(dataAccess.BuildDisplayLine(sd)); } }