diff --git a/CRSim/App.xaml.cs b/CRSim/App.xaml.cs index c187c62..3d11e1e 100644 --- a/CRSim/App.xaml.cs +++ b/CRSim/App.xaml.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +using CRSim.WebsiteSimulator; +using System.Diagnostics; namespace CRSim { @@ -45,6 +46,8 @@ namespace CRSim services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/CRSim/CRSim.csproj b/CRSim/CRSim.csproj index 5a6eef3..7fb4aaf 100644 --- a/CRSim/CRSim.csproj +++ b/CRSim/CRSim.csproj @@ -54,6 +54,7 @@ + @@ -80,6 +81,9 @@ Designer + + Designer + Designer diff --git a/CRSim/MainWindow.xaml b/CRSim/MainWindow.xaml index 1d246d0..d3f8001 100644 --- a/CRSim/MainWindow.xaml +++ b/CRSim/MainWindow.xaml @@ -48,7 +48,12 @@ - + + + + + + diff --git a/CRSim/ViewModels/WebsiteSimulatorPageViewModel.cs b/CRSim/ViewModels/WebsiteSimulatorPageViewModel.cs new file mode 100644 index 0000000..d3cb5a3 --- /dev/null +++ b/CRSim/ViewModels/WebsiteSimulatorPageViewModel.cs @@ -0,0 +1,27 @@ +using CRSim.WebsiteSimulator; + +namespace CRSim.ViewModels; + +public partial class WebsiteSimulatorPageViewModel(IDialogService _dialogService, Simulator _simulator) : ObservableObject +{ + public string PageTitle = "12306模拟"; + + [RelayCommand] + public async Task StartSimulation() + { + try + { + await _simulator.Start(); + } + catch (Exception e) + { + await _dialogService.ShowMessageAsync("认证失败", e.Message); + } + } + + [RelayCommand] + public void StopSimulation() + { + _simulator.Stop(); + } +} \ No newline at end of file diff --git a/CRSim/Views/WebsiteSimulatorPage.xaml b/CRSim/Views/WebsiteSimulatorPage.xaml new file mode 100644 index 0000000..7c94049 --- /dev/null +++ b/CRSim/Views/WebsiteSimulatorPage.xaml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + +