Repository navigation
Expand file tree
/
Copy pathSettingWindow.cs
More file actions
100 lines (89 loc) · 3.05 KB
/
Copy pathSettingWindow.cs
File metadata and controls
100 lines (89 loc) · 3.05 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
92
93
94
95
96
97
98
99
100
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.IO;
using System.Data;
using SQLite;
using System.Collections.ObjectModel;
namespace VRCLogAnalyzer
{
/// <summary>
/// Interaction logic for SettingWindow.xaml
/// </summary>
public partial class SettingWindow : Window
{
private string _appConfigPath;
public SettingWindow()
{
InitializeComponent();
string appPath = App.GetAppPath();
_appConfigPath = System.IO.Path.Combine(appPath, "VRCLogAnalyzer.config");
}
public void Button_Click_OK(object sender, RoutedEventArgs e)
{
ChangeDbPathConfig();
this.Close();
}
private void Window_ContentRendered(object sender, EventArgs e)
{
//設定ファイルは必ず同梱し、ファイルがないパターンはいったん想定外にする
string? dbPathConfig = "AppPath";
System.Xml.XmlDocument appConfig = new System.Xml.XmlDocument();
appConfig.Load(_appConfigPath);
foreach (System.Xml.XmlNode n in appConfig["configuration"]["appSettings"])
{
if (n.Name == "add")
{
if (n.Attributes.GetNamedItem("key").Value == "DbPathChoice")
{
dbPathConfig = n.Attributes.GetNamedItem("value").Value;
}
}
}
if (dbPathConfig == "MyDocuments")
{
DbPathConfigMyDocuments.IsChecked = true;
DbPathConfigAppPath.IsChecked = false;
}
else if (dbPathConfig == "AppPath")
{
DbPathConfigMyDocuments.IsChecked = false;
DbPathConfigAppPath.IsChecked = true;
}
}
public void ChangeDbPathConfig()
{
System.Xml.XmlDocument appConfig = new System.Xml.XmlDocument();
appConfig.Load(_appConfigPath);
string? dbPathConfig = App.GetAppPath();
if ((bool)DbPathConfigMyDocuments.IsChecked == true)
{
dbPathConfig = "MyDocuments";
}
else if ((bool)DbPathConfigAppPath.IsChecked == true)
{
dbPathConfig = "AppPath";
}
foreach (System.Xml.XmlNode n in appConfig["configuration"]["appSettings"])
{
if (n.Name == "add")
{
if (n.Attributes.GetNamedItem("key").Value == "DbPathChoice")
n.Attributes.GetNamedItem("value").Value = dbPathConfig;
}
}
appConfig.Save(_appConfigPath);
}
}
}