Ejemplo n.º 1
0
        public async Task Initialize(Coordinates centerCoordinates, double vFoVDegrees, double imageWidth, double imageHeight, double imageRotation, CancellationToken ct)
        {
            telescopeMediator.RemoveConsumer(this);

            AnnotateDSO  = true;
            AnnotateGrid = true;

            ViewportFoV = new ViewportFoV(centerCoordinates, vFoVDegrees, imageWidth, imageHeight, imageRotation);

            if (dbConstellations == null)
            {
                dbConstellations = await dbInstance.GetConstellationsWithStars(ct);
            }

            if (dbDSOs == null)
            {
                dbDSOs = (await dbInstance.GetDeepSkyObjects(string.Empty, new DatabaseInteraction.DeepSkyObjectSearchParams(), ct)).ToDictionary(x => x.Id, y => y);
            }

            ConstellationsInViewport.Clear();
            ClearFrameLineMatrix();

            img = new Bitmap((int)ViewportFoV.OriginalWidth, (int)ViewportFoV.OriginalHeight, PixelFormat.Format32bppArgb);

            g = Graphics.FromImage(img);
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
            g.SmoothingMode     = SmoothingMode.AntiAlias;

            FrameLineMatrix.CalculatePoints(ViewportFoV);
            if (ConstellationBoundaries.Count == 0)
            {
                ConstellationBoundaries = await GetConstellationBoundaries();
            }

            telescopeMediator.RegisterConsumer(this);
            Initialized = true;

            UpdateSkyMap();
        }
Ejemplo n.º 2
0
        public FocusTargetsVM(IProfileService profileService, ITelescopeMediator telescopeMediator, IApplicationResourceDictionary resourceDictionary) : base(profileService)
        {
            Title         = "LblManualFocusTargets";
            ImageGeometry = (System.Windows.Media.GeometryGroup)resourceDictionary["FocusTargetsSVG"];

            this.telescopeMediator = telescopeMediator;
            telescopeMediator.RegisterConsumer(this);

            AsyncContext.Run(LoadFocusTargets);

            updateTimer = new Timer(TimeSpan.FromMinutes(1).TotalMilliseconds)
            {
                AutoReset = true
            };
            updateTimer.Elapsed += (sender, args) => CalculateVisibleStars();
            if (IsVisible)
            {
                updateTimer.Start();
            }

            SlewToCoordinatesCommand = new AsyncCommand <bool>(async() => await telescopeMediator.SlewToCoordinatesAsync(SelectedFocusTarget.Coordinates));
        }