PageRenderTime 46ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/Data.cs

https://bitbucket.org/rstarkov/tankiconmaker
C# | 91 lines | 67 code | 15 blank | 9 comment | 0 complexity | 9e1ab62cd296432a65a1c97cb5ce20ba MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-3.0, CC-BY-SA-3.0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using WotDataLib;
  6. namespace TankIconMaker
  7. {
  8. class Tank : WotTank
  9. {
  10. private Action<string> _addWarning;
  11. /// <param name="addWarning">
  12. /// The method to be used to add warnings about this tank's rendering.</param>
  13. public Tank(WotTank tank, Action<string> addWarning)
  14. : base(tank)
  15. {
  16. _addWarning = addWarning;
  17. }
  18. public Tank(string tankId, int tier, Country country, Class class_, Category category)
  19. : base(tankId, country, tier, class_, category, Enumerable.Empty<KeyValuePair<ExtraPropertyId, string>>(), null)
  20. {
  21. }
  22. /// <summary>
  23. /// Adds a warning about this tank's rendering. The user will see a big warning icon telling them to look for
  24. /// warnings on specific tanks, and each image with warnings will have a little warning icon shown in it.</summary>
  25. public virtual void AddWarning(string warning)
  26. {
  27. _addWarning(warning);
  28. }
  29. }
  30. /// <summary>Used to test makers for bugs in handling missing data.</summary>
  31. class TestTank : Tank
  32. {
  33. /// <summary>Constructor.</summary>
  34. public TestTank(string tankId, int tier, Country country, Class class_, Category category, WotContext context)
  35. : base(tankId, tier, country, class_, category)
  36. {
  37. TankId = tankId;
  38. Tier = tier;
  39. Country = country;
  40. Class = class_;
  41. Category = category;
  42. Context = context;
  43. }
  44. public string PropertyValue;
  45. public BitmapBase LoadedImage;
  46. public override string this[string name] { get { return PropertyValue; } }
  47. public override string this[ExtraPropertyId property] { get { return PropertyValue; } }
  48. public override void AddWarning(string warning) { }
  49. }
  50. /// <summary>Represents one of the built-in tank image styles.</summary>
  51. [TypeConverter(typeof(ImageBuiltInStyleTranslation.Conv))]
  52. enum ImageBuiltInStyle
  53. {
  54. Contour,
  55. ThreeD,
  56. ThreeDLarge,
  57. Country,
  58. Class
  59. }
  60. class TimGameInstallation : GameInstallation, INotifyPropertyChanged
  61. {
  62. private TimGameInstallation() { } // for Classify
  63. public TimGameInstallation(string path)
  64. : base(path)
  65. {
  66. }
  67. public override void Reload()
  68. {
  69. base.Reload();
  70. PropertyChanged(this, new PropertyChangedEventArgs("DisplayName"));
  71. }
  72. /// <summary>The value displayed in the drop-down.</summary>
  73. public string DisplayName { get { return (GameVersionName ?? "?") + ": " + Path; } }
  74. public event PropertyChangedEventHandler PropertyChanged = (_, __) => { };
  75. }
  76. }