2025-05-29 08:58:58 +08:00
|
|
|
|
using System.Windows;
|
2025-06-10 20:55:39 +08:00
|
|
|
|
using iNKORE.UI.WPF.Modern.Controls;
|
2025-07-02 12:01:20 +08:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2025-06-23 13:42:02 +08:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2025-06-30 14:19:22 +08:00
|
|
|
|
using PMSWPF.Enums;
|
2025-06-30 13:06:51 +08:00
|
|
|
|
using PMSWPF.Helper;
|
2025-06-28 19:32:51 +08:00
|
|
|
|
using PMSWPF.Models;
|
2025-07-02 12:01:20 +08:00
|
|
|
|
using PMSWPF.Services;
|
2025-05-29 08:58:58 +08:00
|
|
|
|
using PMSWPF.ViewModels;
|
|
|
|
|
|
|
2025-06-23 17:01:06 +08:00
|
|
|
|
namespace PMSWPF.Views;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MainView.xaml 的交互逻辑
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public partial class MainView : Window
|
2025-05-29 08:58:58 +08:00
|
|
|
|
{
|
2025-07-02 12:01:20 +08:00
|
|
|
|
private readonly DataServices _dataServices;
|
2025-06-23 17:01:06 +08:00
|
|
|
|
private readonly ILogger<MainView> _logger;
|
2025-06-25 22:33:57 +08:00
|
|
|
|
private MainViewModel _viewModel;
|
2025-06-30 14:19:22 +08:00
|
|
|
|
|
2025-07-02 12:01:20 +08:00
|
|
|
|
public MainView(DataServices dataServices, ILogger<MainView> logger)
|
2025-06-23 17:01:06 +08:00
|
|
|
|
{
|
|
|
|
|
|
InitializeComponent();
|
2025-07-02 12:01:20 +08:00
|
|
|
|
_viewModel = App.Current.Services.GetRequiredService<MainViewModel>();
|
|
|
|
|
|
_dataServices = dataServices;
|
2025-06-25 22:33:57 +08:00
|
|
|
|
_logger = logger;
|
2025-07-02 12:01:20 +08:00
|
|
|
|
DataContext = _viewModel;
|
2025-06-23 17:01:06 +08:00
|
|
|
|
_logger.LogInformation("主界面加载成功");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-05-29 08:58:58 +08:00
|
|
|
|
/// <summary>
|
2025-06-23 17:01:06 +08:00
|
|
|
|
/// 左边菜单项被点击的事件,切换右边的视图
|
2025-05-29 08:58:58 +08:00
|
|
|
|
/// </summary>
|
2025-06-23 17:01:06 +08:00
|
|
|
|
/// <param name="sender"></param>
|
|
|
|
|
|
/// <param name="args"></param>
|
2025-07-02 12:01:20 +08:00
|
|
|
|
private async void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
|
2025-05-29 08:58:58 +08:00
|
|
|
|
{
|
2025-07-02 12:01:20 +08:00
|
|
|
|
var menu = args.SelectedItem as MenuBean;
|
|
|
|
|
|
if (menu != null)
|
2025-05-29 08:58:58 +08:00
|
|
|
|
{
|
2025-07-02 12:01:20 +08:00
|
|
|
|
await _viewModel.MenuSelectionChanged(menu);
|
2025-06-30 14:19:22 +08:00
|
|
|
|
}
|
2025-07-02 12:01:20 +08:00
|
|
|
|
else
|
2025-06-30 14:19:22 +08:00
|
|
|
|
{
|
2025-07-02 12:01:20 +08:00
|
|
|
|
NotificationHelper.ShowMessage("选择的菜单项为空!", NotificationType.Error);
|
2025-06-10 20:55:39 +08:00
|
|
|
|
}
|
2025-05-29 08:58:58 +08:00
|
|
|
|
}
|
2025-06-25 22:33:57 +08:00
|
|
|
|
|
|
|
|
|
|
private async void MainView_OnLoaded(object sender, RoutedEventArgs e)
|
|
|
|
|
|
{
|
|
|
|
|
|
_viewModel.OnLoaded();
|
|
|
|
|
|
}
|
2025-06-23 17:01:06 +08:00
|
|
|
|
}
|