diff --git a/PacticeSolution/CommandPatternSample/App.config b/PacticeSolution/CommandPatternSample/App.config new file mode 100644 index 0000000..8e15646 --- /dev/null +++ b/PacticeSolution/CommandPatternSample/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/PacticeSolution/CommandPatternSample/App.xaml b/PacticeSolution/CommandPatternSample/App.xaml new file mode 100644 index 0000000..dcf1550 --- /dev/null +++ b/PacticeSolution/CommandPatternSample/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/PacticeSolution/CommandPatternSample/App.xaml.cs b/PacticeSolution/CommandPatternSample/App.xaml.cs new file mode 100644 index 0000000..7fda16c --- /dev/null +++ b/PacticeSolution/CommandPatternSample/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 CommandPatternSample +{ + /// + /// App.xaml에 대한 상호 작용 논리 + /// + public partial class App : Application + { + } +} diff --git a/PacticeSolution/CommandPatternSample/Command/RelayCommand.cs b/PacticeSolution/CommandPatternSample/Command/RelayCommand.cs new file mode 100644 index 0000000..2773bca --- /dev/null +++ b/PacticeSolution/CommandPatternSample/Command/RelayCommand.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace CommandPatternSample.Command +{ + internal class RelayCommand : ICommand + { + private Func _canExecute; + private Action _executeAction; + + public event EventHandler CanExecuteChanged; + + public RelayCommand(Action executeAction, Func canExeute) + { + _executeAction = executeAction ?? throw new ArgumentNullException("Execute action is not null"); + _canExecute = canExeute; + } + + public RelayCommand(Action executeAction) : this(executeAction, null) + { + + } + + public bool CanExecute(object parameter) + { + bool result = _canExecute == null ? true : _canExecute.Invoke(parameter); + return result; + } + + public void Execute(object parameter) + { + _executeAction.Invoke(parameter); + } + } +} diff --git a/PacticeSolution/CommandPatternSample/CommandPatternSample.csproj b/PacticeSolution/CommandPatternSample/CommandPatternSample.csproj new file mode 100644 index 0000000..5cbfc1c --- /dev/null +++ b/PacticeSolution/CommandPatternSample/CommandPatternSample.csproj @@ -0,0 +1,100 @@ + + + + + Debug + AnyCPU + {D7C77FA4-195E-4247-90B2-C89BF5016FDE} + WinExe + CommandPatternSample + CommandPatternSample + 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 + + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + + 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/CommandPatternSample/MainWindow.xaml b/PacticeSolution/CommandPatternSample/MainWindow.xaml new file mode 100644 index 0000000..cc0693e --- /dev/null +++ b/PacticeSolution/CommandPatternSample/MainWindow.xaml @@ -0,0 +1,28 @@ + + + + + + + + +