Skip to content

Commit

Permalink
More buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
buldo committed May 24, 2024
1 parent b81577c commit 8cbe6e5
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/EfuseManager/EfuseManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
<PackageReference Include="MvvmDialogs" Version="9.1.2" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions src/EfuseManager/Locator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using MvvmDialogs;

namespace EfuseManager
{
public static class Locator
{
public static IDialogService DialogService { get; } = new DialogService();
}
}
14 changes: 14 additions & 0 deletions src/EfuseManager/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -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">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
Expand Down Expand Up @@ -41,5 +44,16 @@
Margin="2, 0, 0, 0"
Command="{Binding WriteCommand}">Write</Button>
</Grid>
<StackPanel
Grid.Row="1"
Orientation="Horizontal"
Margin="0,2,2,0">
<Button
Margin="2,0,0,0"
Command="{Binding ReadFileCommand}">Read file</Button>
<Button
Margin="2,0,0,0"
Command="{Binding WriteFileCommand}">Write file</Button>
</StackPanel>
</Grid>
</Window>
2 changes: 1 addition & 1 deletion src/EfuseManager/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
41 changes: 39 additions & 2 deletions src/EfuseManager/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -12,21 +13,28 @@

using Microsoft.Extensions.Logging.Abstractions;

using MvvmDialogs;

using Rtl8812auNet;
using Rtl8812auNet.Rtl8812au.Enumerations;

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);
}
Expand All @@ -35,8 +43,12 @@ public MainViewModel()

public RelayCommand ReadCommand { get; }

public RelayCommand ReadFileCommand { get; }

public RelayCommand WriteCommand { get; }

public RelayCommand WriteFileCommand { get; }

public ObservableCollection<DeviceViewModel> Devices { get; } = new();

public DeviceViewModel? SelectedDevice
Expand All @@ -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()
Expand All @@ -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()
{
Expand Down

0 comments on commit 8cbe6e5

Please sign in to comment.