IntegerSlider.cs 791 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using wf.ui;
  3. namespace config.ui
  4. {
  5. public class IntegerSlider : NGUISlider<int>
  6. {
  7. protected int srcValue
  8. {
  9. get
  10. {
  11. return (this.onGetValue == null) ? 0 : this.onGetValue();
  12. }
  13. set
  14. {
  15. if (this.onSetValue != null)
  16. {
  17. this.onSetValue(value);
  18. }
  19. }
  20. }
  21. public override float srcValueToSliderValue
  22. {
  23. get
  24. {
  25. return (float)Math.Round((double)((float)this.srcValue / 100f), 2, MidpointRounding.AwayFromZero);
  26. }
  27. }
  28. public override int sliderValueToSrcValue
  29. {
  30. get
  31. {
  32. return (int)Math.Ceiling((double)(this.slider.value * 100f));
  33. }
  34. }
  35. protected override void OnChangeSliderValue()
  36. {
  37. this.srcValue = this.sliderValueToSrcValue;
  38. }
  39. public Func<int> onGetValue;
  40. public Action<int> onSetValue;
  41. }
  42. }