Files
lagerprogramm/ViewModels/MainWindowViewModel.cs
joel.leirer fb1f90a9ca Added Slop
2026-08-25 17:14:54 +02:00

66 lines
1.6 KiB
C#

using System;
using System.IO;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Lagerprogramm.Models;
using Lagerprogramm.Services;
namespace Lagerprogramm.ViewModels;
public partial class MainWindowViewModel : ObservableObject
{
private readonly JsonDataService _dataService;
private readonly AppData _appData;
[ObservableProperty]
private object? _currentView;
[ObservableProperty]
private string _currentViewName = string.Empty;
public MainWindowViewModel()
{
var path = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
"Lagerprogramm",
"data.json");
_dataService = new JsonDataService(path);
_appData = _dataService.Load();
}
[RelayCommand]
private void ShowParts()
{
CurrentView = new PartsViewModel(_dataService, _appData);
CurrentViewName = "Parts";
}
[RelayCommand]
private void ShowAdditions()
{
CurrentView = new AdditionsViewModel(_dataService, _appData);
CurrentViewName = "Additions";
}
[RelayCommand]
private void ShowDeductions()
{
CurrentView = new DeductionsViewModel(_dataService, _appData);
CurrentViewName = "Deductions";
}
[RelayCommand]
private void ShowSettings()
{
CurrentView = new SettingsViewModel(_dataService, _appData);
CurrentViewName = "Settings";
}
[RelayCommand]
private void ShowDesignPreview()
{
CurrentView = new DesignPreviewViewModel();
CurrentViewName = "Design Preview";
}
}