Пример #1
0
 public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value != null)
     {
         string category = value as string;
         return(CategoryIdHelper.CategoryToId(category));
     }
     else
     {
         return(0);
     }
 }
Пример #2
0
 public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     if (value != null)
     {
         int id = (int)value;
         return(CategoryIdHelper.IdToCategory(id));
     }
     else
     {
         return(string.Empty);
     }
 }
        public SpaceMonkeyCoreViewModel()
        {
            string apiKey = string.Empty;

            using (StreamReader reader = new StreamReader("secrets.json"))
            {
                string    json    = reader.ReadToEnd();
                SmSecrets secrets = JsonConvert.DeserializeObject <SmSecrets>(json);
                apiKey = secrets.ApiKey;
            }
            this.NextIndex           = 0;
            this.Satellites          = new List <SmSatellite>();
            this.DisplayedSatellites = new ObservableCollection <SatelliteCardViewModel>();
            this.Categories          = new ObservableCollection <string>(CategoryIdHelper.GetCategories());
            this.Scales = new ObservableCollection <string>(ScaleFactorHelper.GetScales());
            this.Client = new SpaceMonkeyWebClient(apiKey);
            this.GetSatellitesCommand = new RelayCommand(this.GetSatellites);
            this.BakeAllCommand       = new RelayCommand(this.BakeAll);
            this.SearchRadius         = 70;
            this.CategoryId           = 0;
            this.ScaleFactor          = 0.001;
            Instance = this;
        }