-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathExplorerSettings.cs
More file actions
91 lines (86 loc) · 3.28 KB
/
ExplorerSettings.cs
File metadata and controls
91 lines (86 loc) · 3.28 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace EV3Explorer
{
public class ExplorerSettings
{
public int windowWidth;
public int windowHeight;
public int splitterPosition;
public String localDirectory;
public Boolean onlyShowPrograms;
public ExplorerSettings()
{
windowWidth = 800;
windowHeight = 600;
splitterPosition = 400;
localDirectory = "";
onlyShowPrograms = false;
}
public void Load()
{
try
{
string fileName = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EV3Basic"), "settings.txt");
System.IO.StreamReader file = new System.IO.StreamReader(fileName);
String line;
while ((line = file.ReadLine()) != null)
{
line = line.Trim();
try
{
if (line.StartsWith("WIDTH=", StringComparison.InvariantCultureIgnoreCase))
{
Int32.TryParse(line.Substring(6).Trim(), out windowWidth);
}
if (line.StartsWith("HEIGHT=", StringComparison.InvariantCultureIgnoreCase))
{
Int32.TryParse(line.Substring(7).Trim(), out windowHeight);
}
if (line.StartsWith("SPLITTER=", StringComparison.InvariantCultureIgnoreCase))
{
Int32.TryParse(line.Substring(9).Trim(), out splitterPosition);
}
if (line.StartsWith("LOCALDIR=", StringComparison.InvariantCultureIgnoreCase))
{
localDirectory = line.Substring(9).Trim();
}
if (line.StartsWith("ONLYSHOWPROGRAMS", StringComparison.InvariantCultureIgnoreCase))
{
onlyShowPrograms = true;
}
}
catch (Exception) { }
}
file.Close();
}
catch (Exception) { }
}
public void Save()
{
try
{
string dir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "EV3Basic");
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
string fileName = Path.Combine(dir, "settings.txt");
System.IO.StreamWriter file = new System.IO.StreamWriter(fileName);
file.WriteLine("WIDTH="+windowWidth);
file.WriteLine("HEIGHT=" + windowHeight);
file.WriteLine("SPLITTER=" + splitterPosition);
file.WriteLine("LOCALDIR=" + localDirectory);
if (onlyShowPrograms)
{
file.WriteLine("ONLYSHOWPROGRAMS");
}
file.Close();
}
catch (Exception) { }
}
}
}