Tom Han

Tom Han

  • NA
  • 4
  • 1.1k

Loop through image resources with key press

Nov 13 2019 7:26 AM
I would like to iterate through resource images upon keyboard press.
 
For example, when keyboard key F8 is pressed the images associated in that respective folder (Folder 1) changes live in all six views.
 
Curently I have six .xaml theme files which I change the image manually by editing Image Source=, see structure below:
  • Game.xaml (Game Theme)
  • Option.xaml (Option Theme)
  • Pause.xaml (Pause Theme)
  • Platform.xaml (Platform Theme)
  • Startup.xaml (Startup Theme)
  • Shutdown.xaml (Startup Theme)
  1. <Image Source="/imageChanger;Component/Images/Themes/Folder 1/Game Theme/Background.png" />
  1. <Image Source="/imageChanger;Component/Images/Themes/Folder 1/Option Theme/Background.png" />
  1. <Image Source="/imageChanger;Component/Images/Themes/Folder 1/Pause Theme/Background.png" />
  1. <Image Source="/imageChanger;Component/Images/Themes/Folder 1/Platform Theme/Background.png" />
  1. <Image Source="/imageChanger;Component/Images/Themes/Folder 1/Startup Theme/Startup.png" />
  1. <Image Source="/imageChanger;Component/Images/Themes/Folder 1/Startup Theme/Shutdown.png" />
I was thinking something like a settings.ini or settings.json file and retain and changes, see example below.
  1. #  
  2. # CONFIGURATION  
  3. #  
  4.   
  5. {  
  6. "Set Default": "F1",  
  7. "Next": "F2", (Folder 1 is default but 'Next' starts the cycle in sequence from whichever is selected)  
  8. "Previous": "F3"  
  9. }  
  10.   
  11. #  
  12. # CYCLE BACKGROUND IMAGE  
  13. #  
  14.   
  15. {  
  16. "Folder 1": true, (Set as default first)  
  17. "Folder 2": false,  
  18. "Folder 3": false,  
  19. "Folder 4": false,  
  20. "Folder 5": false,  
  21. "Folder 6": false,  
  22. "Folder 7": false,  
  23. "Folder 8": false,  
  24. "Folder 9": false,  
  25. "Folder 10": false,  
  26. "Folder 11": false,  
  27. "Folder 12": false,  
  28. "Folder 13": false,  
  29. "Folder 14": false,  
  30. "Folder 15": false,  
  31. "Folder 16": false,  
  32. "Folder 17": false,  
  33. "Folder 18": false   
  34. }  

Answers (1)