-
Notifications
You must be signed in to change notification settings - Fork 0
/
WillDelete.xaml.cs
61 lines (59 loc) · 2.32 KB
/
WillDelete.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
using System;
using System.Collections.Generic;
using System.IO;
using Windows.Foundation;
using Windows.Storage;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
// https://go.microsoft.com/fwlink/?LinkId=234238 上介绍了“内容对话框”项模板
namespace CountDown_Day {
public sealed partial class WillDelete : ContentDialog {
int argid = -1;
public WillDelete() {
this.InitializeComponent();
}
private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) {
List<countdown_schedule> schedules = new List<countdown_schedule>();
foreach (var v in MainPage.schedules) {
schedules.Add(v);
}
StorageFolder localfolder = ApplicationData.Current.LocalFolder;
string[] ori = File.ReadAllLines(localfolder.Path + "\\config.ini");
File.Delete(localfolder.Path + "\\config.ini");
int i = 0;
foreach (var v in schedules) {
if (v.ID == argid) {
string filename = v.filename;
MainPage.schedules.Remove(v);
File.Delete(filename);
}
else {
File.AppendAllText(localfolder.Path + "\\config.ini", ori[i] + "\n");
}
i++;
}
for (i = 0; i < MainPage.schedules.Count; i++) {
MainPage.schedules[i].ID = i;
}
App.Main?.ReLoadItems();
}
private void ContentDialog_SecondaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) {
}
public IAsyncOperation<ContentDialogResult> ShowAsyncN(int i) {
argid = i;
return this.ShowAsync();
}
private void ContentDialog_Loaded(object sender, RoutedEventArgs e) {
List<countdown_schedule> schedules = MainPage.schedules;
if (argid == -1)
throw new Exception();
else {
foreach (var v in schedules) {
if (v.ID == argid) {
this.TTil.Text = "确定要删除" + v.Name + "嘛?";
}
}
}
}
}
}