Example #1
0
        private void MouseWheel(object obj)
        {
            var delta    = ((MouseWheelResult)obj).Delta;
            var stepSize = 2;

            if (delta > 0)
            {
                if (FieldOfView > 1)
                {
                    FieldOfView = Math.Max(1, FieldOfView - stepSize);
                }
            }
            else
            {
                if (FieldOfView < 200)
                {
                    FieldOfView = Math.Min(200, FieldOfView + stepSize);
                }
            }
            CalculateRectangle(SkyMapAnnotator.ChangeFoV(FieldOfView));
        }
Example #2
0
        public FramingAssistantVM(IProfileService profileService, ICameraMediator cameraMediator, ITelescopeMediator telescopeMediator, IApplicationStatusMediator applicationStatusMediator) : base(profileService)
        {
            this.cameraMediator = cameraMediator;
            this.cameraMediator.RegisterConsumer(this);
            this.telescopeMediator         = telescopeMediator;
            this.applicationStatusMediator = applicationStatusMediator;

            Opacity = 0.2;

            SkyMapAnnotator = new SkyMapAnnotator(telescopeMediator);

            var defaultCoordinates = new Coordinates(0, 0, Epoch.J2000, Coordinates.RAType.Degrees);

            DSO = new DeepSkyObject(string.Empty, defaultCoordinates, profileService.ActiveProfile.ApplicationSettings.SkyAtlasImageRepository);

            FramingAssistantSource = profileService.ActiveProfile.FramingAssistantSettings.LastSelectedImageSource;

            CameraPixelSize = profileService.ActiveProfile.CameraSettings.PixelSize;
            FocalLength     = profileService.ActiveProfile.TelescopeSettings.FocalLength;

            _statusUpdate = new Progress <ApplicationStatus>(p => Status = p);

            LoadImageCommand = new AsyncCommand <bool>(async() => { return(await LoadImage()); });
            CancelLoadImageFromFileCommand = new RelayCommand((object o) => { CancelLoadImage(); });
            _progress = new Progress <int>((p) => DownloadProgressValue = p);
            CancelLoadImageCommand         = new RelayCommand((object o) => { CancelLoadImage(); });
            DragStartCommand               = new RelayCommand(DragStart);
            DragStopCommand                = new RelayCommand(DragStop);
            DragMoveCommand                = new RelayCommand(DragMove);
            ClearCacheCommand              = new RelayCommand(ClearCache, (object o) => Cache != null);
            RefreshSkyMapAnnotationCommand = new RelayCommand((object o) => SkyMapAnnotator.UpdateSkyMap(), (object o) => SkyMapAnnotator.Initialized);
            MouseWheelCommand              = new RelayCommand(MouseWheel);

            CoordsFromPlanetariumCommand = new AsyncCommand <bool>(() => Task.Run(CoordsFromPlanetarium));

            DeepSkyObjectSearchVM = new DeepSkyObjectSearchVM();
            DeepSkyObjectSearchVM.PropertyChanged += DeepSkyObjectSearchVM_PropertyChanged;

            SetSequenceCoordinatesCommand = new AsyncCommand <bool>(async(object parameter) => {
                var vm = (ApplicationVM)Application.Current.Resources["AppVM"];
                vm.ChangeTab(ApplicationTab.SEQUENCE);

                var deepSkyObjects = new List <DeepSkyObject>();
                foreach (var rect in CameraRectangles)
                {
                    var name     = rect.Id > 0 ? DSO?.Name + string.Format(" {0} ", Locale.Loc.Instance["LblPanel"]) + rect.Id : DSO?.Name;
                    var dso      = new DeepSkyObject(name, rect.Coordinates, profileService.ActiveProfile.ApplicationSettings.SkyAtlasImageRepository);
                    dso.Rotation = Rectangle.DisplayedRotation;
                    deepSkyObjects.Add(dso);
                }

                bool msgResult = false;
                if (parameter.ToString() == "Replace")
                {
                    msgResult = await vm.SeqVM.SetSequenceCoordiantes(deepSkyObjects);
                }
                else if (parameter.ToString() == "Add")
                {
                    msgResult = await vm.SeqVM.SetSequenceCoordiantes(deepSkyObjects, false);
                }

                ImageParameter = null;
                GC.Collect();
                GC.WaitForPendingFinalizers();
                return(msgResult);
            }, (object o) => Rectangle?.Coordinates != null);

            RecenterCommand = new AsyncCommand <bool>(async() => {
                DSO.Coordinates = Rectangle.Coordinates;
                await LoadImageCommand.ExecuteAsync(null);
                return(true);
            }, (object o) => Rectangle?.Coordinates != null);

            SlewToCoordinatesCommand = new AsyncCommand <bool>(async() => {
                return(await telescopeMediator.SlewToCoordinatesAsync(Rectangle.Coordinates));
            }, (object o) => Rectangle?.Coordinates != null);

            var appSettings = profileService.ActiveProfile.ApplicationSettings;

            appSettings.PropertyChanged += ApplicationSettings_PropertyChanged;

            profileService.ProfileChanged += (object sender, EventArgs e) => {
                appSettings.PropertyChanged -= ApplicationSettings_PropertyChanged;

                this.FocalLength     = profileService.ActiveProfile.TelescopeSettings.FocalLength;
                this.CameraPixelSize = profileService.ActiveProfile.CameraSettings.PixelSize;

                RaisePropertyChanged(nameof(CameraPixelSize));
                RaisePropertyChanged(nameof(FocalLength));
                RaisePropertyChanged(nameof(FieldOfView));
                RaisePropertyChanged(nameof(CameraWidth));
                RaisePropertyChanged(nameof(CameraHeight));
                appSettings = profileService.ActiveProfile.ApplicationSettings;
                appSettings.PropertyChanged += ApplicationSettings_PropertyChanged;
                ApplicationSettings_PropertyChanged(null, null);
            };

            resizeTimer          = new DispatcherTimer(DispatcherPriority.ApplicationIdle, _dispatcher);
            resizeTimer.Interval = TimeSpan.FromMilliseconds(500);
            resizeTimer.Tick    += ResizeTimer_Tick;

            ScrollViewerSizeChangedCommand = new RelayCommand((parameter) => {
                resizeTimer.Stop();
                if (ImageParameter != null && FramingAssistantSource == SkySurveySource.SKYATLAS)
                {
                    resizeTimer.Start();
                }
            });

            profileService.LocationChanged += (object sender, EventArgs e) => {
                DSO = new DeepSkyObject(DSO.Name, DSO.Coordinates, profileService.ActiveProfile.ApplicationSettings.SkyAtlasImageRepository);
            };

            InitializeCache();
        }