This repository has been archived by the owner on Jul 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.xaml.cs
64 lines (52 loc) · 1.53 KB
/
App.xaml.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
using System.Collections.ObjectModel;
using System.IO;
using System.Xml.Serialization;
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
namespace WakeOnLan
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class App : Application
{
private string ConfigPath;
public App()
{
InitializeComponent();
try
{
LoadConfig();
}
catch
{
}
var nav = new NavigationPage(new MainPage());
NavigationPage.SetHasNavigationBar(nav, false);
MainPage = nav;
}
private void LoadConfig()
{
ConfigPath = Path.Combine(Tizen.Applications.Application.Current.DirectoryInfo.Data, "config.xml");
if (!File.Exists(ConfigPath))
return;
using (var sr = new StreamReader(ConfigPath))
{
var serializer = new XmlSerializer(typeof(ObservableCollection<LanPc>));
LanPc.List = (ObservableCollection<LanPc>)serializer.Deserialize(sr);
}
}
protected override void OnStart()
{
}
protected override void OnSleep()
{
using (var sw = new StreamWriter(ConfigPath))
{
var serializer = new XmlSerializer(typeof(ObservableCollection<LanPc>));
serializer.Serialize(sw, LanPc.List);
}
}
protected override void OnResume()
{
}
}
}