forked from amrali-eg/EncodingChecker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.cs
More file actions
55 lines (47 loc) · 1.38 KB
/
Settings.cs
File metadata and controls
55 lines (47 loc) · 1.38 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
using System;
using System.Collections.ObjectModel;
using System.Windows.Forms;
namespace EncodingChecker
{
[Serializable]
public sealed class Settings
{
public WindowPosition WindowPosition = new WindowPosition();
public RecentDirectories RecentDirectories = new RecentDirectories();
public bool IncludeSubdirectories = true;
public string FileMasks;
public string[] ValidCharsets;
}
[Serializable]
public sealed class WindowPosition
{
public int Left = -1;
public int Top = -1;
public int Width = -1;
public int Height = -1;
public bool Maximized;
public void ApplyTo(Form form)
{
if (Left >= 0 && Top >= 0 && Width > 0 && Height > 0)
form.SetBounds(Left, Top, Width, Height);
}
}
[Serializable]
public sealed class RecentDirectories : Collection<string>
{
protected override void InsertItem(int index, string item)
{
for (int i = Count - 1; i >= 0; i--)
{
if (this[i].Equals(item, StringComparison.OrdinalIgnoreCase))
RemoveAt(i);
}
base.InsertItem(0, item);
if (Count > 10)
{
for (int i = Count - 1; i >= 10; i--)
RemoveAt(i);
}
}
}
}