Exemplo n.º 1
0
 private void Ok()
 {
     if (string.IsNullOrWhiteSpace(Eyepiece.Name))
     {
         ViewManager.ShowMessageBox("$EyepieceWindow.WarningTitle", "$EyepieceWindow.EmptyNameWarningMessage");
     }
     else if (Eyepieces.Any(t => t.Name == Eyepiece.Name && t.Id != Eyepiece.Id))
     {
         ViewManager.ShowMessageBox("$EyepieceWindow.WarningTitle", "$EyepieceWindow.NameAlreadyExistsWarningMessage");
     }
     else
     {
         Close(true);
     }
 }
Exemplo n.º 2
0
 private void DeleteEquipment(Type equipmentType)
 {
     if (ViewManager.ShowMessageBox("$FovSettingsVM.WarningTitle", "$FovSettingsVM.DeleteEquipmentMessage", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         if (equipmentType == typeof(Telescope))
         {
             Telescopes.Remove(Telescope);
             TelescopeId = Guid.Empty;
             NotifyPropertyChanged(nameof(Telescopes), nameof(TelescopeId));
             Calculate();
             SaveEquipment();
         }
         else if (equipmentType == typeof(Eyepiece))
         {
             Eyepieces.Remove(Eyepiece);
             EyepieceId = Guid.Empty;
             NotifyPropertyChanged(nameof(Eyepieces), nameof(EyepieceId));
             Calculate();
             SaveEquipment();
         }
         else if (equipmentType == typeof(Camera))
         {
             Cameras.Remove(Camera);
             CameraId = Guid.Empty;
             NotifyPropertyChanged(nameof(Cameras), nameof(CameraId));
             Calculate();
             SaveEquipment();
         }
         else if (equipmentType == typeof(Binocular))
         {
             Binoculars.Remove(Binocular);
             BinocularId = Guid.Empty;
             NotifyPropertyChanged(nameof(Binoculars), nameof(BinocularId));
             Calculate();
             SaveEquipment();
         }
     }
 }
Exemplo n.º 3
0
 private void EditEquipment(Type equipmentType, bool isNew)
 {
     if (equipmentType == typeof(Telescope))
     {
         var vm = ViewManager.CreateViewModel <TelescopeVM>();
         vm.Telescopes = Telescopes;
         if (!isNew)
         {
             vm.Telescope.CopyFrom(Telescope);
         }
         if (ViewManager.ShowDialog(vm) ?? false)
         {
             if (isNew)
             {
                 Telescopes.Add(vm.Telescope);
             }
             TelescopeId = Guid.Empty;
             TelescopeId = vm.Telescope.Id;
             Telescope.CopyFrom(vm.Telescope);
             _Equipment.Telescopes = new ObservableCollection <Telescope>(Telescopes.OrderBy(t => t.Name));
             NotifyPropertyChanged(nameof(Telescopes), nameof(TelescopeId), nameof(Telescope));
             Calculate();
             SaveEquipment();
         }
     }
     else if (equipmentType == typeof(Eyepiece))
     {
         var vm = ViewManager.CreateViewModel <EyepieceVM>();
         vm.Eyepieces = Eyepieces;
         if (!isNew)
         {
             vm.Eyepiece.CopyFrom(Eyepiece);
         }
         if (ViewManager.ShowDialog(vm) ?? false)
         {
             if (isNew)
             {
                 Eyepieces.Add(vm.Eyepiece);
             }
             EyepieceId = Guid.Empty;
             EyepieceId = vm.Eyepiece.Id;
             Eyepiece.CopyFrom(vm.Eyepiece);
             _Equipment.Eyepieces = new ObservableCollection <Eyepiece>(Eyepieces.OrderBy(t => t.Name));
             NotifyPropertyChanged(nameof(Eyepieces), nameof(EyepieceId), nameof(Eyepiece));
             Calculate();
             SaveEquipment();
         }
     }
     else if (equipmentType == typeof(Camera))
     {
         var vm = ViewManager.CreateViewModel <CameraVM>();
         vm.Cameras = Cameras;
         if (!isNew)
         {
             vm.Camera.CopyFrom(Camera);
         }
         if (ViewManager.ShowDialog(vm) ?? false)
         {
             if (isNew)
             {
                 Cameras.Add(vm.Camera);
             }
             CameraId = Guid.Empty;
             CameraId = vm.Camera.Id;
             Camera.CopyFrom(vm.Camera);
             _Equipment.Cameras = new ObservableCollection <Camera>(Cameras.OrderBy(t => t.Name));
             NotifyPropertyChanged(nameof(Cameras), nameof(CameraId), nameof(Camera));
             Calculate();
             SaveEquipment();
         }
     }
     else if (equipmentType == typeof(Binocular))
     {
         var vm = ViewManager.CreateViewModel <BinocularVM>();
         vm.Binoculars = Binoculars;
         if (!isNew)
         {
             vm.Binocular.CopyFrom(Binocular);
         }
         if (ViewManager.ShowDialog(vm) ?? false)
         {
             if (isNew)
             {
                 Binoculars.Add(vm.Binocular);
             }
             BinocularId = Guid.Empty;
             BinocularId = vm.Binocular.Id;
             Binocular.CopyFrom(vm.Binocular);
             _Equipment.Binoculars = new ObservableCollection <Binocular>(Binoculars.OrderBy(t => t.Name));
             NotifyPropertyChanged(nameof(Binoculars), nameof(BinocularId), nameof(Binocular));
             Calculate();
             SaveEquipment();
         }
     }
 }