forked from LogExperts/LogExpert
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImportSettingsDialog.cs
More file actions
98 lines (79 loc) · 2.54 KB
/
ImportSettingsDialog.cs
File metadata and controls
98 lines (79 loc) · 2.54 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
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
using LogExpert.Core.Config;
using System.Runtime.Versioning;
namespace LogExpert.UI.Dialogs;
[SupportedOSPlatform("windows")]
internal partial class ImportSettingsDialog : Form
{
#region cTor
public ImportSettingsDialog(ExportImportFlags importFlags)
{
InitializeComponent();
SuspendLayout();
AutoScaleDimensions = new SizeF(96F, 96F);
AutoScaleMode = AutoScaleMode.Dpi;
ImportFlags = importFlags;
FileName = string.Empty;
if (ImportFlags == ExportImportFlags.HighlightSettings)
{
checkBoxHighlightSettings.Checked = true;
checkBoxHighlightSettings.Enabled = false;
checkBoxHighlightFileMasks.Checked = false;
checkBoxHighlightFileMasks.Enabled = false;
checkBoxColumnizerFileMasks.Checked = false;
checkBoxColumnizerFileMasks.Enabled = false;
checkBoxExternalTools.Checked = false;
checkBoxExternalTools.Enabled = false;
checkBoxOther.Checked = false;
checkBoxOther.Enabled = false;
}
ResumeLayout();
}
#endregion
#region Properties
public string FileName { get; private set; }
public ExportImportFlags ImportFlags { get; private set; }
#endregion
#region Events handler
private void OnImportSettingsDialogLoad(object sender, EventArgs e)
{
}
private void OnFileButtonClick(object sender, EventArgs e)
{
OpenFileDialog dlg = new()
{
Title = "Load Settings from file",
DefaultExt = "json",
AddExtension = false,
Filter = "Settings (*.json)|*.json|All files (*.*)|*.*"
};
if (dlg.ShowDialog() == DialogResult.OK)
{
textBoxFileName.Text = dlg.FileName;
}
}
private void OnOkButtonClick(object sender, EventArgs e)
{
FileName = textBoxFileName.Text;
if (ImportFlags != ExportImportFlags.HighlightSettings)
{
foreach (Control ctl in groupBoxImportOptions.Controls)
{
if (ctl.Tag != null)
{
if (((CheckBox)ctl).Checked)
{
ImportFlags |= (ExportImportFlags)long.Parse(ctl.Tag as string ?? string.Empty);
}
}
}
}
else
{
if (checkBoxKeepExistingSettings.Checked)
{
ImportFlags |= ExportImportFlags.KeepExisting;
}
}
}
#endregion
}