Update
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
using FileReadAndWrite.Model;
|
||||
using FileReadAndWrite.Service;
|
||||
using FileReadAndWrite.View;
|
||||
|
||||
namespace FileReadAndWrite.ViewModel;
|
||||
|
||||
public class AppDataFilePageVM : INotifyPropertyChanged {
|
||||
private readonly FileService _fileService;
|
||||
|
||||
private string _appDataFileContent = "";
|
||||
public string AppDataFileContent {
|
||||
get => _appDataFileContent;
|
||||
set {
|
||||
_appDataFileContent = value;
|
||||
OnPropertyChanged(nameof(AppDataFileContent));
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand LoadAppDataFileCmd { get; }
|
||||
public ICommand SaveAppDataFileCmd { get; }
|
||||
|
||||
public AppDataFilePageVM(FileService fileService) {
|
||||
_fileService = fileService;
|
||||
|
||||
LoadAppDataFileCmd = new Command(async () => await LoadAppDataFile());
|
||||
SaveAppDataFileCmd = new Command(async () => await SaveAppDataFile());
|
||||
}
|
||||
|
||||
public async Task LoadAppDataFile(){
|
||||
AppDataFileContent = await _fileService.LoadFromFile();
|
||||
}
|
||||
|
||||
public async Task SaveAppDataFile(){
|
||||
await _fileService.SaveToFile(AppDataFileContent);
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
public void OnPropertyChanged(string propertyName) {
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ public class MainViewModel : INotifyPropertyChanged {
|
||||
}
|
||||
|
||||
private async Task EnterAppDataFile(){
|
||||
await _navigation.PushAsync(new AppDataFilePage());
|
||||
await _navigation.PushAsync(new AppDataFilePage(_fileService));
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Input;
|
||||
using FileReadAndWrite.Model;
|
||||
using FileReadAndWrite.Service;
|
||||
using FileReadAndWrite.View;
|
||||
|
||||
namespace FileReadAndWrite.ViewModel;
|
||||
|
||||
public class RawFilePageVM : INotifyPropertyChanged {
|
||||
private readonly FileService _fileService;
|
||||
|
||||
private string _rawFileContent = "";
|
||||
public string RawFileContent {
|
||||
get => _rawFileContent;
|
||||
set {
|
||||
_rawFileContent = value;
|
||||
OnPropertyChanged(nameof(RawFileContent));
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand LoadRawFileCmd { get; }
|
||||
|
||||
public RawFilePageVM(FileService fileService) {
|
||||
_fileService = fileService;
|
||||
|
||||
LoadRawFileCmd = new Command(async () => await LoadRawFile());
|
||||
}
|
||||
|
||||
public async Task LoadRawFile(){
|
||||
RawFileContent = await _fileService.LoadAsset("data.txt");
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
public void OnPropertyChanged(string propertyName) {
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user