- .NET 8.0 WPF 프로젝트 생성 - MVVM 패턴 적용 (CommunityToolkit.Mvvm) - 의존성 주입 구현 (Microsoft.Extensions.DependencyInjection) - 로그인/회원관리/회원등록 화면 구현 - 테마 전환 기능 (Dark/Light) - 다국어 지원 (한국어/영어) - 세련된 로그인 UI 디자인 - CLAUDE.md 및 History.md 문서화 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
63 lines
1.5 KiB
C#
63 lines
1.5 KiB
C#
using System.Windows;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using WPFBeginner.Services;
|
|
using WPFBeginner.Views;
|
|
|
|
namespace WPFBeginner.ViewModels;
|
|
|
|
public partial class LoginViewModel : ObservableObject
|
|
{
|
|
private readonly ISettingsService _settingsService;
|
|
|
|
[ObservableProperty]
|
|
private string _userId = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private string _password = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private string _errorMessage = string.Empty;
|
|
|
|
[ObservableProperty]
|
|
private bool _hasError;
|
|
|
|
public string WelcomeMessage => _settingsService.CurrentLanguage == "en-US"
|
|
? "Welcome"
|
|
: "환영합니다";
|
|
|
|
public LoginViewModel(ISettingsService settingsService)
|
|
{
|
|
_settingsService = settingsService;
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void Login(Window window)
|
|
{
|
|
var settings = _settingsService.Settings.Login;
|
|
|
|
if (UserId == settings.User && Password == settings.Password)
|
|
{
|
|
HasError = false;
|
|
ErrorMessage = string.Empty;
|
|
|
|
var mainWindow = new MainWindow();
|
|
mainWindow.Show();
|
|
window.Close();
|
|
}
|
|
else
|
|
{
|
|
HasError = true;
|
|
ErrorMessage = _settingsService.CurrentLanguage == "en-US"
|
|
? "Invalid ID or Password"
|
|
: "아이디 또는 비밀번호가 틀렸습니다";
|
|
}
|
|
}
|
|
|
|
[RelayCommand]
|
|
private void Close(Window window)
|
|
{
|
|
Application.Current.Shutdown();
|
|
}
|
|
}
|