forked from xzvfinet/OneLevelJson
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDocument.cs
More file actions
55 lines (49 loc) · 1.68 KB
/
Document.cs
File metadata and controls
55 lines (49 loc) · 1.68 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
44
45
46
47
48
49
50
51
52
53
54
55
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
namespace OneLevelJson
{
public class Document
{
public Document() : this("noname", 1920, 1080) {}
public Document(string name, int width, int height)
{
Name = name;
Assets = new List<Asset>();
Components = new List<Component>();
Width = width;
Height = height;
}
public void AddAsset(Asset asset)
{
// TODO assetList에 같은 이름의 asset이 있는지 중복 검사를 해야 한다.
Assets.Add(asset);
}
public void RemoveAsset(Asset asset)
{
Assets.Remove(asset);
}
public void AddComponent(string name, Point location)
{
Asset asset = Assets.Find(x => x.Name == name);
string id = "component" + Components.Count;
Components.Add(new Component(asset, id, location));
}
public void RemoveComponent(string id)
{
Components.Remove(Components.Find(x => x.Id == id));
}
public void ReNameComponent(string id, string newId)
{
Component comp = Components.Find(x => x.Id == id);
if (comp != null) comp.SetId(newId);
}
// TODO Save할때 static 변수도 나가는지 확인
public static string Directory { get; set; }
public string Name { get; private set; }
public int Width { get; private set; }
public int Height { get; private set; }
public List<Asset> Assets { get; private set; }
public List<Component> Components { get; private set; }
}
}