-
Notifications
You must be signed in to change notification settings - Fork 0
/
MiniData.cs
82 lines (72 loc) · 2.32 KB
/
MiniData.cs
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
using System;
using System.Collections.Generic;
namespace PaperMiniMaker {
public class MiniArt {
public string Url {get; set;}
}
public enum MiniSize {
Tiny, Small, Medium, Large, Huge, Gargantuan
}
public static class MiniSizeMethods {
public static string Description(this MiniSize size) {
return size switch {
MiniSize.Tiny => "Tiny: 12mm (0.5\")",
MiniSize.Small => "Small: 25mm (1\")",
MiniSize.Medium => "Medium: 25mm (1\")",
MiniSize.Large => "Large: 50mm (2\")",
MiniSize.Huge => "Huge: 76mm (3\")",
MiniSize.Gargantuan => "Gargantuan: 102mm (4\")",
_ => size.ToString()
};
}
public static double BaseSizeInches (this MiniSize size) {
return size switch {
MiniSize.Tiny => 0.5,
MiniSize.Small => 1,
MiniSize.Medium => 1,
MiniSize.Large => 2,
MiniSize.Huge => 3,
MiniSize.Gargantuan => 4,
_ => 1
};
}
public static string CssClass (this MiniSize size) {
return size switch {
MiniSize.Tiny => "size-tiny",
MiniSize.Small => "size-small",
MiniSize.Medium => "size-medium",
MiniSize.Large => "size-large",
MiniSize.Huge => "size-huge",
MiniSize.Gargantuan => "size-gargantuan",
_ => "size-medium"
};
}
}
public class Mini {
public string Name {get; set;}
public MiniSize Size {get; set;}
public MiniArt FrontArt {get; set;}
public MiniArt ReverseArt {get; set;}
public float Scale {get; set;} = 1;
private int _replicas;
public int Replicas {
get => _replicas;
set => _replicas = Math.Max(1, value);
}
public Mini Clone() {
return new Mini{
Name = this.Name,
Size = this.Size,
FrontArt = this.FrontArt == null ? null : new MiniArt {
Url = this.FrontArt.Url
},
ReverseArt = this.ReverseArt == null ? null : new MiniArt {
Url = this.ReverseArt.Url
},
Scale = this.Scale,
Replicas = this.Replicas
};
}
public MiniArt GetReverseArt() => ReverseArt != null && !string.IsNullOrEmpty(ReverseArt.Url) ? ReverseArt : FrontArt;
}
}