-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
140 lines (123 loc) · 4.49 KB
/
MainWindow.xaml.cs
File metadata and controls
140 lines (123 loc) · 4.49 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shapes;
namespace ReciteHelper.DataCollect
{
public partial class MainWindow : Window
{
private int currentStep = 1;
public MainWindow()
{
InitializeComponent();
NavigateToStep(1);
}
private void StepNavigation_Click(object sender, MouseButtonEventArgs e)
{
if (sender is Border border && border.Tag is string stepTag)
{
int stepNumber = int.Parse(stepTag);
if (stepNumber <= currentStep || stepNumber == currentStep + 1)
{
NavigateToStep(stepNumber);
}
else
{
MessageBox.Show("请按顺序完成前面的步骤", "提示",
MessageBoxButton.OK, MessageBoxImage.Information);
}
}
}
public void NavigateToStep(int stepNumber)
{
UpdateStepVisuals(stepNumber);
switch (stepNumber)
{
case 1:
ContentFrame.Navigate(new Pages.Preface());
break;
case 2:
ContentFrame.Navigate(new Pages.Notice());
break;
case 3:
ContentFrame.Navigate(new Pages.CollectInformation());
break;
case 4:
ContentFrame.Navigate(new Pages.SpeedTest());
break;
case 5:
ContentFrame.Navigate(new Pages.Answer());
break;
}
currentStep = stepNumber;
}
private void UpdateStepVisuals(int activeStep)
{
ResetAllSteps();
SetStepActive(activeStep, true);
for (int i = 1; i < activeStep; i++)
{
SetStepCompleted(i);
}
}
private void ResetAllSteps()
{
for (int i = 1; i <= 5; i++)
{
SetStepPending(i);
}
}
private void SetStepActive(int step, bool isActive)
{
var circle = FindName($"Step{step}Circle") as Ellipse;
var text = FindName($"Step{step}Text") as TextBlock;
var check = FindName($"Step{step}Check") as TextBlock;
if (circle != null && text != null && check != null)
{
if (isActive)
{
circle.Stroke = (SolidColorBrush)FindResource("CurrentStepColor");
circle.Fill = (SolidColorBrush)FindResource("CurrentStepColor");
text.Foreground = (SolidColorBrush)FindResource("CurrentStepColor");
text.FontWeight = FontWeights.Bold;
check.Visibility = Visibility.Collapsed;
}
}
}
private void SetStepCompleted(int step)
{
var circle = FindName($"Step{step}Circle") as Ellipse;
var text = FindName($"Step{step}Text") as TextBlock;
var check = FindName($"Step{step}Check") as TextBlock;
if (circle != null && text != null && check != null)
{
circle.Stroke = (SolidColorBrush)FindResource("CompletedStepColor");
circle.Fill = (SolidColorBrush)FindResource("CompletedStepColor");
text.Foreground = (SolidColorBrush)FindResource("CompletedStepColor");
check.Visibility = Visibility.Visible;
}
}
private void SetStepPending(int step)
{
var circle = FindName($"Step{step}Circle") as Ellipse;
var text = FindName($"Step{step}Text") as TextBlock;
var check = FindName($"Step{step}Check") as TextBlock;
if (circle != null && text != null && check != null)
{
circle.Stroke = (SolidColorBrush)FindResource("PendingStepColor");
circle.Fill = Brushes.Transparent;
text.Foreground = (SolidColorBrush)FindResource("PendingStepColor");
text.FontWeight = FontWeights.SemiBold;
check.Visibility = Visibility.Collapsed;
}
}
public void GoToNextStep()
{
if (currentStep < 5)
{
NavigateToStep(currentStep + 1);
}
}
}
}