forked from xzvfinet/OneLevelJson
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAsset.cs
More file actions
43 lines (37 loc) · 1.05 KB
/
Asset.cs
File metadata and controls
43 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Drawing;
using System.Windows.Forms;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace OneLevelJson
{
public enum AssetType
{
Image
}
public class Asset
{
[JsonConstructorAttribute]
public Asset(AssetType type, string name)
{
Type = type;
Name = name;
Number = Number + 1;
string projectDirectory = Document.Directory ?? Application.StartupPath;
switch (Type)
{
case AssetType.Image:
Image img = Image.FromFile(projectDirectory + MainForm.ImageDataDirectory+@"\"+Name);
Data = img;
ImageSize = img.Size;
break;
}
}
public static int Number { get; set; }
[JsonConverter(typeof (StringEnumConverter))]
public AssetType Type { get; set; }
public string Name { get; set; }
[JsonIgnore]
public readonly object Data;
public Size ImageSize;
}
}