/
MarginSettings.cs
62 lines (47 loc) · 1.34 KB
/
MarginSettings.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
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Threading.Tasks;
namespace DinkToPdf
{
public class MarginSettings
{
public Unit Unit { get; set; }
public double? Top { get; set; }
public double? Bottom { get; set; }
public double? Left { get; set; }
public double? Right { get; set; }
public MarginSettings()
{
Unit = Unit.Millimeters;
}
public MarginSettings(double top, double right, double bottom, double left) : this()
{
Top = top;
Bottom = bottom;
Left = left;
Right = right;
}
public string GetMarginValue(double? value)
{
if (!value.HasValue)
{
return null;
}
string strUnit = "in";
switch (Unit)
{
case Unit.Inches: strUnit = "in";
break;
case Unit.Millimeters: strUnit = "mm";
break;
case Unit.Centimeters: strUnit = "cm";
break;
default: strUnit = "in";
break;
}
return value.Value.ToString("0.##", CultureInfo.InvariantCulture) + strUnit;
}
}
}