From 8cbe6e57ef09a2e9f3a0a85aec911b8cc99741ca Mon Sep 17 00:00:00 2001 From: Roman Buldygin Date: Fri, 24 May 2024 03:49:44 +0300 Subject: [PATCH] More buttons --- src/EfuseManager/EfuseManager.csproj | 1 + src/EfuseManager/Locator.cs | 9 +++++ src/EfuseManager/MainWindow.xaml | 14 +++++++ src/EfuseManager/MainWindow.xaml.cs | 2 +- src/EfuseManager/ViewModels/MainViewModel.cs | 41 +++++++++++++++++++- 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 src/EfuseManager/Locator.cs diff --git a/src/EfuseManager/EfuseManager.csproj b/src/EfuseManager/EfuseManager.csproj index a695844..345e7ec 100644 --- a/src/EfuseManager/EfuseManager.csproj +++ b/src/EfuseManager/EfuseManager.csproj @@ -14,6 +14,7 @@ + diff --git a/src/EfuseManager/Locator.cs b/src/EfuseManager/Locator.cs new file mode 100644 index 0000000..1f152bd --- /dev/null +++ b/src/EfuseManager/Locator.cs @@ -0,0 +1,9 @@ +using MvvmDialogs; + +namespace EfuseManager +{ + public static class Locator + { + public static IDialogService DialogService { get; } = new DialogService(); + } +} \ No newline at end of file diff --git a/src/EfuseManager/MainWindow.xaml b/src/EfuseManager/MainWindow.xaml index 8e42958..41c36d6 100644 --- a/src/EfuseManager/MainWindow.xaml +++ b/src/EfuseManager/MainWindow.xaml @@ -5,11 +5,14 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:EfuseManager" xmlns:viewModels="clr-namespace:EfuseManager.ViewModels" + xmlns:md="https://github.com/fantasticfiasco/mvvm-dialogs" mc:Ignorable="d" d:DataContext="{d:DesignInstance viewModels:MainViewModel}" + md:DialogServiceViews.IsRegistered="True" Title="MainWindow" Height="450" Width="800"> + @@ -41,5 +44,16 @@ Margin="2, 0, 0, 0" Command="{Binding WriteCommand}">Write + + + + diff --git a/src/EfuseManager/MainWindow.xaml.cs b/src/EfuseManager/MainWindow.xaml.cs index 4eceef2..e0974b8 100644 --- a/src/EfuseManager/MainWindow.xaml.cs +++ b/src/EfuseManager/MainWindow.xaml.cs @@ -33,6 +33,6 @@ private void OnMainWindowClosed(object? sender, EventArgs e) private void OnLoaded(object sender, RoutedEventArgs e) { - DataContext = new MainViewModel(); + DataContext = new MainViewModel(Locator.DialogService); } } \ No newline at end of file diff --git a/src/EfuseManager/ViewModels/MainViewModel.cs b/src/EfuseManager/ViewModels/MainViewModel.cs index d0d2364..193e348 100644 --- a/src/EfuseManager/ViewModels/MainViewModel.cs +++ b/src/EfuseManager/ViewModels/MainViewModel.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Windows; using CommunityToolkit.Mvvm.ComponentModel; using CommunityToolkit.Mvvm.Input; @@ -12,6 +13,8 @@ using Microsoft.Extensions.Logging.Abstractions; +using MvvmDialogs; + using Rtl8812auNet; using Rtl8812auNet.Rtl8812au.Enumerations; @@ -19,14 +22,19 @@ namespace EfuseManager.ViewModels; internal class MainViewModel : ObservableObject, IDisposable { + private readonly IDialogService _dialogService; private readonly WiFiDriver _driver; private DeviceViewModel? _selectedDevice; - public MainViewModel() + public MainViewModel(IDialogService dialogService) { + _dialogService = dialogService; + RefreshCommand = new RelayCommand(ExecuteRefresh); ReadCommand = new RelayCommand(ExecuteRead); WriteCommand = new RelayCommand(ExecuteWrite); + ReadFileCommand = new RelayCommand(ExecuteReadFile); + WriteFileCommand = new RelayCommand(ExecuteWriteFile); _driver = new WiFiDriver(NullLoggerFactory.Instance); } @@ -35,8 +43,12 @@ public MainViewModel() public RelayCommand ReadCommand { get; } + public RelayCommand ReadFileCommand { get; } + public RelayCommand WriteCommand { get; } + public RelayCommand WriteFileCommand { get; } + public ObservableCollection Devices { get; } = new(); public DeviceViewModel? SelectedDevice @@ -49,7 +61,12 @@ public DeviceViewModel? SelectedDevice private void ExecuteWrite() { - throw new NotImplementedException(); + _dialogService.ShowMessageBox( + this, + "Not implemented", + "Not implemented", + MessageBoxButton.OK, + MessageBoxImage.Warning); } private void ExecuteRead() @@ -71,6 +88,26 @@ private void ExecuteRead() var efuseMap = rtlDevice.ReadEfuse(); EfuseMap.LoadData(efuseMap); } + + private void ExecuteWriteFile() + { + _dialogService.ShowMessageBox( + this, + "Not implemented", + "Not implemented", + MessageBoxButton.OK, + MessageBoxImage.Warning); + } + + private void ExecuteReadFile() + { + _dialogService.ShowMessageBox( + this, + "Not implemented", + "Not implemented", + MessageBoxButton.OK, + MessageBoxImage.Warning); + } private void ExecuteRefresh() {