forked from SergiyStoyan/PdfDocumentParser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSettingsForm.cs
124 lines (108 loc) · 5.18 KB
/
SettingsForm.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//********************************************************************************************
//Author: Sergiy Stoyan
// s.y.stoyan@gmail.com, sergiy.stoyan@outlook.com, stoyan@cliversoft.com
// http://www.cliversoft.com
//********************************************************************************************
using System;
using System.Windows.Forms;
namespace Cliver.PdfDocumentParser
{
public partial class SettingsForm : Form
{
public SettingsForm()
{
InitializeComponent();
this.Icon = Win.AssemblyRoutines.GetAppIcon();
Text = Program.FullName + ": Settings";
load_settings();
}
void load_settings()
{
AnchorBoxColor.ForeColor = Settings.Appearance.AnchorBoxColor;
AscendantAnchorBoxColor.ForeColor = Settings.Appearance.AscendantAnchorBoxColor;
SelectionBoxColor.ForeColor = Settings.Appearance.SelectionBoxColor;
TableBoxColor.ForeColor = Settings.Appearance.TableBoxColor;
SelectionBoxBorderWidth.Value = (decimal)Settings.Appearance.SelectionBoxBorderWidth;
AnchorBoxBorderWidth.Value = (decimal)Settings.Appearance.AnchorBoxBorderWidth;
AscendantAnchorBoxBorderWidth.Value = (decimal)Settings.Appearance.SelectionBoxBorderWidth;
TableBoxBorderWidth.Value = (decimal)Settings.Appearance.TableBoxBorderWidth;
PdfPageImageResolution.Value = Settings.Constants.PdfPageImageResolution;
CoordinateDeviationMargin.Value = (decimal)Settings.Constants.CoordinateDeviationMargin;
OcrConfig.Text = Settings.Constants.OcrConfig.ToStringByJson();
InitialSearchRectangleMargin.Value = (decimal)Settings.Constants.InitialSearchRectangleMargin;
}
private void bCancel_Click(object sender, EventArgs e)
{
Close();
}
private void bSave_Click(object sender, EventArgs e)
{
try
{
AppearanceSettings appearance = Settings.Appearance.CreateClone();
appearance.AnchorBoxColor = AnchorBoxColor.ForeColor;
appearance.AscendantAnchorBoxColor = AscendantAnchorBoxColor.ForeColor;
appearance.SelectionBoxColor = SelectionBoxColor.ForeColor;
appearance.TableBoxColor = TableBoxColor.ForeColor;
appearance.SelectionBoxBorderWidth = (float)SelectionBoxBorderWidth.Value;
appearance.AnchorBoxBorderWidth = (float)AnchorBoxBorderWidth.Value;
appearance.AscendantAnchorBoxBorderWidth = (float)AscendantAnchorBoxBorderWidth.Value;
appearance.TableBoxBorderWidth = (float)TableBoxBorderWidth.Value;
ConstantsSettings constants = Settings.Constants.CreateClone();
constants.PdfPageImageResolution = (int)PdfPageImageResolution.Value;
constants.CoordinateDeviationMargin = (float)CoordinateDeviationMargin.Value;
//constants.OcrConfig = Serialization.Json.Deserialize<Ocr.Config>(OcrConfig.Text);
constants.InitialSearchRectangleMargin = (int)InitialSearchRectangleMargin.Value;
Settings.Appearance = appearance;
Settings.Appearance.Save();
Settings.Constants = constants;
Settings.Constants.Save();
Message.Warning("Some settings may require restarting the application in order to come into effect.", this);
Close();
}
catch (Exception ex)
{
Message.Error2(ex, this);
}
}
private void bReset_Click(object sender, EventArgs e)
{
Settings.Appearance.Reset();
Settings.Constants.Reset();
load_settings();
}
private void About_Click(object sender, EventArgs e)
{
AboutBox ab = new AboutBox();
ab.ShowDialog();
}
private void SelectionBoxColor_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
cd.Color = Settings.Appearance.SelectionBoxColor;
if (cd.ShowDialog() == DialogResult.OK)
SelectionBoxColor.ForeColor = cd.Color;
}
private void AnchorMasterBoxColor_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
cd.Color = Settings.Appearance.AnchorBoxColor;
if (cd.ShowDialog() == DialogResult.OK)
AnchorBoxColor.ForeColor = cd.Color;
}
private void AnchorSecondaryBoxColor_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
cd.Color = Settings.Appearance.AscendantAnchorBoxColor;
if (cd.ShowDialog() == DialogResult.OK)
AscendantAnchorBoxColor.ForeColor = cd.Color;
}
private void TableBoxColor_Click(object sender, EventArgs e)
{
ColorDialog cd = new ColorDialog();
cd.Color = Settings.Appearance.TableBoxColor;
if (cd.ShowDialog() == DialogResult.OK)
TableBoxColor.ForeColor = cd.Color;
}
}
}