-
Notifications
You must be signed in to change notification settings - Fork 5
/
Configuration.cs
92 lines (72 loc) · 1.91 KB
/
Configuration.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
using System;
using System.IO;
using System.Xml;
using System.Xml.Serialization;
namespace CameraPrefsApp
{
/// <summary>
/// This Configuration class is basically just a set of
/// properties with a couple of static methods to manage
/// the serialization to and deserialization from a
/// simple XML file.
/// </summary>
[Serializable]
[XmlRoot("config")]
public class Configuration
{
[XmlArray("cameras")]
[XmlArrayItem("camera")]
public CameraPrefs[] Cameras;
[XmlElement("trueColorEnabled")]
public Boolean TrueColorEnabled = false;
public static void Serialize(string file, Configuration c)
{
XmlSerializer xs = new XmlSerializer(c.GetType());
StreamWriter writer = File.CreateText(file);
xs.Serialize(writer, c);
writer.Flush();
writer.Close();
}
public static Configuration Deserialize(string file)
{
XmlSerializer xs = new XmlSerializer(typeof(Configuration));
StreamReader reader = File.OpenText(file);
Configuration c = (Configuration)xs.Deserialize(reader);
reader.Close();
return c;
}
}
[Serializable]
[XmlRoot("camera")]
public class CameraPrefs
{
[XmlAttribute("name")]
public String Name;
[XmlAttribute("autoExposure")]
public Boolean AutoExposure;
[XmlAttribute("autoFocus")]
public Boolean AutoFocus;
[XmlAttribute("autoWhiteBalance")]
public Boolean AutoWhiteBalance;
/*
*/
[XmlAttribute("focus")]
public int Focus;
[XmlAttribute("pan")]
public int Pan;
[XmlAttribute("tilt")]
public int Tilt;
[XmlAttribute("zoom")]
public int Zoom;
[XmlAttribute("brightness")]
public int Brightness;
[XmlAttribute("contrast")]
public int Contrast;
//[XmlAttribute("exposure")]
//public int Exposure;
[XmlAttribute("saturation")]
public int Saturation;
[XmlAttribute("whiteBalance")]
public int WhiteBalance;
}
}