LightLayer.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Controls;
  7. using Newtonsoft.Json;
  8. using Newtonsoft.Json.Linq;
  9. using PixiEditor.Helpers;
  10. namespace PixiEditor.Models.Layers
  11. {
  12. [Serializable]
  13. public class LightLayer : BasicLayer
  14. {
  15. private byte[] _layerBytes;
  16. public byte[] LayerBytes
  17. {
  18. get => _layerBytes;
  19. set
  20. {
  21. _layerBytes = value;
  22. RaisePropertyChanged("LayerBytes");
  23. }
  24. }
  25. public LightLayer(int width, int height)
  26. {
  27. LightLayer layer = LayerGenerator.GenerateWithByteArray(width, height);
  28. LayerBytes = layer.LayerBytes;
  29. Width = width;
  30. Height = height;
  31. }
  32. public LightLayer(byte[] layerBytes, int height, int width)
  33. {
  34. LayerBytes = layerBytes;
  35. Width = height;
  36. Height = width;
  37. }
  38. public LightLayer()
  39. {
  40. }
  41. public static LightLayer Deserialize(object value)
  42. {
  43. return JsonConvert.DeserializeObject<LightLayer>(((JObject)value).ToString());
  44. }
  45. }
  46. }