forked from ispysoftware/iSpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMediaDirectoryConfig.cs
121 lines (107 loc) · 3.98 KB
/
MediaDirectoryConfig.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
using System;
using System.IO;
using System.Windows.Forms;
namespace iSpyApplication.Controls
{
public partial class MediaDirectoryConfig : Form
{
public configurationDirectory Config;
public FolderSelectDialog Fsd = new FolderSelectDialog();
public MediaDirectoryConfig()
{
InitializeComponent();
chkStorage.Text = LocRm.GetString("StorageManagement");
gbStorage.Text = LocRm.GetString("StorageManagement");
label9.Text = LocRm.GetString("Mb");
label10.Text = LocRm.GetString("MaxMediaFolderSize");
label11.Text = LocRm.GetString("WhenOver70FullDeleteFiles");
label12.Text = LocRm.GetString("DaysOld0ForNoDeletions");
label1.Text = LocRm.GetString("Directory");
chkStopRecording.Text = LocRm.GetString("StopRecordingOnLimit");
chkArchive.Text = LocRm.GetString("ArchiveInsteadOfDelete");
Text = LocRm.GetString("MediaDirectoryConfiguration");
}
public override sealed string Text
{
get { return base.Text; }
set { base.Text = value; }
}
private void chkStorage_CheckedChanged(object sender, EventArgs e)
{
gbStorage.Enabled = chkStorage.Checked;
}
private void button2_Click(object sender, EventArgs e)
{
if (Directory.Exists(txtMediaDirectory.Text))
{
Config.Enable_Storage_Management = chkStorage.Checked;
Config.Entry = txtMediaDirectory.Text;
Config.MaxMediaFolderSizeMB = (int) txtMaxMediaSize.Value;
Config.DeleteFilesOlderThanDays = (int) txtDaysDelete.Value;
Config.StopSavingOnStorageLimit = chkStopRecording.Checked;
Config.archive = chkArchive.Checked;
if (!Config.Enable_Storage_Management)
Config.StopSavingFlag = false;
DialogResult = DialogResult.OK;
Close();
}
else
{
MessageBox.Show(this, LocRm.GetString("MediaDirectoryNotFound"));
}
}
private void MediaDirectoryConfig_Load(object sender, EventArgs e)
{
gbStorage.Enabled = chkStorage.Checked = Config.Enable_Storage_Management;
txtMediaDirectory.Text = Config.Entry;
txtMaxMediaSize.Value = Config.MaxMediaFolderSizeMB;
txtDaysDelete.Value = Config.DeleteFilesOlderThanDays;
chkStopRecording.Checked = Config.StopSavingOnStorageLimit;
chkArchive.Checked = Config.archive;
}
private void button1_Click(object sender, EventArgs e)
{
string f = GetFolder(Config.Entry);
if (f != "")
txtMediaDirectory.Text = f;
}
private string GetFolder(string initialPath)
{
string f = "";
if (!string.IsNullOrEmpty(initialPath))
{
try
{
Fsd.InitialDirectory = initialPath;
}
catch
{
}
}
if (Fsd.ShowDialog(Handle))
{
bool success = false;
try
{
string path = Fsd.FileName;
if (!path.EndsWith("\\"))
path += "\\";
Directory.CreateDirectory(path + "video");
Directory.CreateDirectory(path + "audio");
success = true;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
if (success)
{
f = Fsd.FileName;
if (!f.EndsWith(@"\"))
f += @"\";
}
}
return f;
}
}
}