From fffd85ecb5228a84b091a6083599e873960aadd4 Mon Sep 17 00:00:00 2001 From: syneffort Date: Wed, 12 Jul 2023 18:06:18 +0900 Subject: [PATCH] address book by mvvm pattern --- .../AddressBook_MVVMSample.csproj | 108 ++++++++++++++++ .../AddressBook_MVVMSample/App.config | 6 + .../AddressBook_MVVMSample/App.xaml | 9 ++ .../AddressBook_MVVMSample/App.xaml.cs | 17 +++ .../Command/DelegateCommand.cs | 38 ++++++ .../AddressBook_MVVMSample/MainWindow.xaml | 52 ++++++++ .../AddressBook_MVVMSample/MainWindow.xaml.cs | 121 ++++++++++++++++++ .../AddressBook_MVVMSample/Model/Person.cs | 77 +++++++++++ .../Properties/AssemblyInfo.cs | 55 ++++++++ .../Properties/Resources.Designer.cs | 71 ++++++++++ .../Properties/Resources.resx | 117 +++++++++++++++++ .../Properties/Settings.Designer.cs | 30 +++++ .../Properties/Settings.settings | 7 + .../SubWindow/AddViewWindow.xaml | 62 +++++++++ .../SubWindow/AddViewWindow.xaml.cs | 107 ++++++++++++++++ .../ViewModel/AddViewModel.cs | 12 ++ PacticeSolution/PacticeSolution.sln | 6 + 17 files changed, 895 insertions(+) create mode 100644 PacticeSolution/AddressBook_MVVMSample/AddressBook_MVVMSample.csproj create mode 100644 PacticeSolution/AddressBook_MVVMSample/App.config create mode 100644 PacticeSolution/AddressBook_MVVMSample/App.xaml create mode 100644 PacticeSolution/AddressBook_MVVMSample/App.xaml.cs create mode 100644 PacticeSolution/AddressBook_MVVMSample/Command/DelegateCommand.cs create mode 100644 PacticeSolution/AddressBook_MVVMSample/MainWindow.xaml create mode 100644 PacticeSolution/AddressBook_MVVMSample/MainWindow.xaml.cs create mode 100644 PacticeSolution/AddressBook_MVVMSample/Model/Person.cs create mode 100644 PacticeSolution/AddressBook_MVVMSample/Properties/AssemblyInfo.cs create mode 100644 PacticeSolution/AddressBook_MVVMSample/Properties/Resources.Designer.cs create mode 100644 PacticeSolution/AddressBook_MVVMSample/Properties/Resources.resx create mode 100644 PacticeSolution/AddressBook_MVVMSample/Properties/Settings.Designer.cs create mode 100644 PacticeSolution/AddressBook_MVVMSample/Properties/Settings.settings create mode 100644 PacticeSolution/AddressBook_MVVMSample/SubWindow/AddViewWindow.xaml create mode 100644 PacticeSolution/AddressBook_MVVMSample/SubWindow/AddViewWindow.xaml.cs create mode 100644 PacticeSolution/AddressBook_MVVMSample/ViewModel/AddViewModel.cs diff --git a/PacticeSolution/AddressBook_MVVMSample/AddressBook_MVVMSample.csproj b/PacticeSolution/AddressBook_MVVMSample/AddressBook_MVVMSample.csproj new file mode 100644 index 0000000..0ec7847 --- /dev/null +++ b/PacticeSolution/AddressBook_MVVMSample/AddressBook_MVVMSample.csproj @@ -0,0 +1,108 @@ + + + + + Debug + AnyCPU + {6A452509-3DEB-41A3-8AA3-8DB4BE948D28} + WinExe + AddressBook_MVVMSample + AddressBook_MVVMSample + v4.5 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + AddViewWindow.xaml + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + MainWindow.xaml + Code + + + Designer + MSBuild:Compile + + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + \ No newline at end of file diff --git a/PacticeSolution/AddressBook_MVVMSample/App.config b/PacticeSolution/AddressBook_MVVMSample/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/PacticeSolution/AddressBook_MVVMSample/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PacticeSolution/AddressBook_MVVMSample/App.xaml b/PacticeSolution/AddressBook_MVVMSample/App.xaml new file mode 100644 index 0000000..cb15f40 --- /dev/null +++ b/PacticeSolution/AddressBook_MVVMSample/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/PacticeSolution/AddressBook_MVVMSample/App.xaml.cs b/PacticeSolution/AddressBook_MVVMSample/App.xaml.cs new file mode 100644 index 0000000..2d97a6e --- /dev/null +++ b/PacticeSolution/AddressBook_MVVMSample/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace AddressBook_MVVMSample +{ + /// + /// App.xaml에 대한 상호 작용 논리 + /// + public partial class App : Application + { + } +} diff --git a/PacticeSolution/AddressBook_MVVMSample/Command/DelegateCommand.cs b/PacticeSolution/AddressBook_MVVMSample/Command/DelegateCommand.cs new file mode 100644 index 0000000..89f45bf --- /dev/null +++ b/PacticeSolution/AddressBook_MVVMSample/Command/DelegateCommand.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace AddressBook_MVVMSample.Command +{ + public class DelegateCommand : ICommand + { + private readonly Action _execute; + private readonly Predicate _canExecute; + + public event EventHandler CanExecuteChanged; + + public DelegateCommand(Action execute, Predicate canExecute) + { + _execute = execute; + _canExecute = canExecute; + } + + public DelegateCommand(Action execute) : this(execute, null) + { + + } + + public bool CanExecute(object parameter) + { + return _canExecute == null ? true : _canExecute(parameter); + } + + public void Execute(object parameter) + { + _execute?.Invoke(parameter); + } + } +} diff --git a/PacticeSolution/AddressBook_MVVMSample/MainWindow.xaml b/PacticeSolution/AddressBook_MVVMSample/MainWindow.xaml new file mode 100644 index 0000000..22f767b --- /dev/null +++ b/PacticeSolution/AddressBook_MVVMSample/MainWindow.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + +