-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
113 lines (100 loc) · 2.93 KB
/
MainWindow.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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
using System.Windows;
using System.IO;
using System.Collections.Generic;
using Microsoft.Win32;
using System;
using System.Windows.Input;
using System.Windows.Controls;
namespace 知识点再认器
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
static string filePath = null;
static List<string> lines = new List<string>();
static List<string> backup = new List<string>();
static List<string> notRemberList = new List<string>();
static int max = 0;
static int p = 0;
static Random r = new Random();
public MainWindow()
{
InitializeComponent();
}
private void loadfile(object sender, RoutedEventArgs e)
{
var ofd = new OpenFileDialog();
ofd.Title = "选择知识库";
ofd.Filter = "文本文件|*.txt";
ofd.ShowDialog();
filePath = ofd.FileName;
Startup(File.ReadAllLines(filePath));
progress.Visibility = Visibility.Visible;
GetNextOne(sender, e);
}
private void Startup(string[] lis)
{
lines.Clear();
lines.AddRange(lis);
backup.Clear();
notRemberList.Clear();
max = lines.Count;
p = 0;
model.Text = Models.Text;
}
private void MainWindows_Keydown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Right)
{
GetNextOne(sender, null);
}
else if (e.Key == Key.Left)
{
GetPreviousOne(sender, null);
}
}
private void Save(object sender, RoutedEventArgs e)
{
notRemberList.Add(Card.Text);
}
private void GetNextOne(object sender, RoutedEventArgs e)
{
if (p < max)
{
p++;
int tem = r.Next(0, lines.Count);
progress.Text = $"{p}/{max}";
Card.Text = lines[tem];
backup.Add(lines[tem]);
lines.RemoveAt(tem);
}
else
{
Card.Text = "End";
}
}
private void GetPreviousOne(object sender, RoutedEventArgs e)
{
if (p > 1)
{
p--;
Card.Text = backup[p - 1];
progress.Text = $"{p}/{max}";
lines.Add(backup[p]);
backup.RemoveAt(p);
}
}
private void NewLinesAgain(object sender, RoutedEventArgs e)
{
Startup(notRemberList.ToArray());
GetNextOne(sender, e);
}
private void SameAgain(object sender, RoutedEventArgs e)
{
Startup(File.ReadAllLines(filePath));
GetNextOne(sender, e);
}
}
}