EffectsPane.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using System.Collections.Generic;
  2. namespace MeidoPhotoStudio.Plugin
  3. {
  4. public class EffectsPane : BasePane
  5. {
  6. private readonly Dictionary<string, BasePane> effectPanes = new Dictionary<string, BasePane>();
  7. private readonly List<string> effectList = new List<string>();
  8. private readonly SelectionGrid effectToggles;
  9. private BasePane currentEffectPane;
  10. public BasePane this[string effectUI]
  11. {
  12. private get => effectPanes[effectUI];
  13. set
  14. {
  15. effectPanes[effectUI] = value;
  16. effectList.Add(effectUI);
  17. effectToggles.SetItems(Translation.GetArray("effectsPane", effectList), 0);
  18. }
  19. }
  20. public EffectsPane()
  21. {
  22. effectToggles = new SelectionGrid(new[] { "dummy" /* thicc */ });
  23. effectToggles.ControlEvent += (s, a) => SetEffectPane(effectList[effectToggles.SelectedItemIndex]);
  24. }
  25. protected override void ReloadTranslation()
  26. {
  27. effectToggles.SetItems(Translation.GetArray("effectsPane", effectList));
  28. }
  29. private void SetEffectPane(string effectUI)
  30. {
  31. currentEffectPane = effectPanes[effectUI];
  32. currentEffectPane.UpdatePane();
  33. }
  34. public override void UpdatePane() => currentEffectPane.UpdatePane();
  35. public override void Draw()
  36. {
  37. MpsGui.Header("Effects");
  38. MpsGui.WhiteLine();
  39. effectToggles.Draw();
  40. MpsGui.BlackLine();
  41. currentEffectPane.Draw();
  42. }
  43. }
  44. }