private async Task PreloadDays(DateTime referenceDate, int days) { if (days < 0) { MinimumDateLoaded = referenceDate.AddDays(days); } if (days > 0) { MaximumDateLoaded = referenceDate.AddDays(days); } var start = IntHelper.GetMin(0, days); var end = IntHelper.GetMax(0, days); for (var i = start; i <= end; i++) { if (i != 0) { var loadDate = referenceDate.AddDays(i).GetClosestUtcZeroTime(); var model = SolarSystem.Helpers.Seeder.CelestialObjectSeedHelper.GetSunPosition(loadDate); await DataLoader.LoadAsync(DataLoading.Preload, model).ConfigureAwait(false); } } }
private async Task Preload(DateTime referenceDate) { var loadThreshold = 10 * DaySkip; var loadBoundary = IntHelper.GetMax(10 * DaySkip, DataConnectionHelper.GetPositionDaysForDataConnection()); if (loadThreshold <= 0) { loadThreshold = loadBoundary; } if (referenceDate.AddDays(loadThreshold) > MaximumDateLoaded) { await PreloadDays(MaximumDateLoaded, loadBoundary).ConfigureAwait(false); } if (referenceDate.AddDays(-loadThreshold) < MinimumDateLoaded) { await PreloadDays(MinimumDateLoaded, -loadBoundary).ConfigureAwait(false); } }
private static DrawParameterModel GetDrawParameters(SKImageInfo info, IEnumerable <CelestialDrawModel> orbits, ObjectCollectionLayout objectCollectionLayout) { var maxCanvasWidth = info.Width; var maxCanvasHeight = info.Height; int maxCanvas; var maximumOrbitRadius = orbits.Max(x => x.Radius); int centreX; int centreY; var orientation = DrawOrientation.Horizontal; if (objectCollectionLayout == ObjectCollectionLayout.Position) { centreX = (int)Math.Floor(maxCanvasWidth / (double)2); centreY = (int)Math.Floor(maxCanvasHeight / (double)2); maxCanvas = IntHelper.GetMin(centreX, centreY); } else { if (maxCanvasHeight > maxCanvasWidth) { orientation = DrawOrientation.Vertical; } centreX = orientation == DrawOrientation.Horizontal ? 0 : (int)Math.Floor((double)maxCanvasWidth / 2); centreY = orientation == DrawOrientation.Vertical ? maxCanvasHeight : (int)Math.Floor((double)maxCanvasHeight / 2); maxCanvas = IntHelper.GetMax(maxCanvasWidth, maxCanvasHeight); } var orbitFactor = (int)Math.Floor((maxCanvas - SunRadius) / maximumOrbitRadius); return(new DrawParameterModel(objectCollectionLayout, orientation, centreX, centreY, orbitFactor)); }