forked from TroyFernandes/MusicBeeChromecast
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettings.cs
More file actions
74 lines (57 loc) · 1.83 KB
/
Settings.cs
File metadata and controls
74 lines (57 loc) · 1.83 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
using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
namespace MusicBeePlugin
{
public partial class Settings : Form
{
private static string SettingsPath { get; set; }
public Settings(string @path)
{
SettingsPath = path;
InitializeComponent();
ReadSettings();
}
private void folderBrowserDialog1_HelpRequest(object sender, EventArgs e)
{
}
public void CreateSettings()
{
using (var writer = new XmlTextWriter(SettingsPath + @"\MB_Chromecast_Settings.xml", Encoding.UTF8))
{
writer.Formatting = Formatting.Indented;
//Write the root element
writer.WriteStartElement("settings");
//Write sub-elements
writer.WriteElementString("server_port", ((int)serverPortSelect.Value).ToString());
// end the root element
writer.WriteEndElement();
}
}
private void ReadSettings()
{
if (File.Exists(SettingsPath + @"\MB_Chromecast_Settings.xml"))
{
XmlDocument doc = new XmlDocument();
doc.Load(SettingsPath + @"\MB_Chromecast_Settings.xml");
var temp = doc.GetElementsByTagName("server_port")[0].InnerText;
if (!string.IsNullOrEmpty(temp))
{
serverPortSelect.Value = Convert.ToDecimal(temp);
}
}
}
private void closeText_Click(object sender, EventArgs e)
{
this.Close();
}
private void saveText_Click(object sender, EventArgs e)
{
CreateSettings();
this.Close();
}
}
}