private void BanUseUpdated(object sender, RoutedEventArgs e) { if (view.imageSelection == null || view.imageSelection == "") { return; } PersistentData data = new PersistentData(SettingsLoader.GetCurrentSettingsData()); for (int i = 0; i < data.imageData.Count; i++) { if (data.imageData[i].fileName == view.imageSelection) { DataStructures.ImageData temp = data.imageData[i]; temp.banUse = view.chkBxBanUse; data.imageData[i] = temp; SettingsLoader.changedData = data; SettingsLoader.UpdateSettings(); } } }
private void ComboboxUpdated(object sender, SelectionChangedEventArgs args) { if (view.imageSelection == null || view.imageSelection == "") { return; } PersistentData data = new PersistentData(SettingsLoader.GetCurrentSettingsData()); for (int i = 0; i < data.imageData.Count; i++) { if (data.imageData[i].fileName == view.imageSelection) { DataStructures.ImageData temp = data.imageData[i]; temp.targetDaytime = Helperfunctions.ConvertComboIntToDaytime(view.selectedItemDayTime); temp.targetSeason = Helperfunctions.ConvertComboIntToSeason(view.selectedItemSeason); temp.targetWeather = Helperfunctions.ConvertComboIntToWeather(view.selectedItemWeather); data.imageData[i] = temp; SettingsLoader.changedData = data; SettingsLoader.UpdateSettings(); } } }
public void ImageClicked(Image sender) { string filePath = sender.Source.ToString(); view.imageSelection = filePath; BitmapImage image = new BitmapImage(); image.BeginInit(); image.CacheOption = BitmapCacheOption.OnLoad; image.UriSource = new Uri(filePath); image.EndInit(); SelectedImageBox.Source = image; PersistentData data = SettingsLoader.GetCurrentSettingsData(); for (int i = 0; i < data.imageData.Count(); i++) { if (data.imageData[i].fileName == filePath) { //update displayed imagedata view.selectedItemWeather = Helperfunctions.ConvertWeatherEnumToComboInt(data.imageData[i].targetWeather); view.selectedItemDayTime = Helperfunctions.ConvertDayTimeToComboInt(data.imageData[i].targetDaytime); view.selectedItemSeason = Helperfunctions.ConvertSeasonToComboInt(data.imageData[i].targetSeason); view.chkBxBanUse = data.imageData[i].banUse; return; } } //file has no data yet, write entry DataStructures.ImageData newEntry = new DataStructures.ImageData(); newEntry.fileName = filePath; newEntry.targetDaytime = DataStructures.enumDayTime.DAWN; newEntry.targetSeason = DataStructures.enumSeason.SPRING; newEntry.targetWeather = DataStructures.enumWeather.CLEAR_SKY; newEntry.banUse = false; data.imageData.Add(newEntry); SettingsLoader.changedData.imageData = data.imageData; SettingsLoader.UpdateSettings(); ImageClicked(sender); }