⇤ ← Revision 1 as of 2012-09-18 22:32:59
Size: 1110
Comment:
|
Size: 1112
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 7: | Line 7: |
{{{#!csharp | {{{ #!csharp |
Chat Server and WPF Client
Client
For the client code I used WPF and the MVVM pattern. From the bottom up the first thing I used is a DelegateCommand
using System; using System.Windows.Input; namespace ChatClient { class DelegateCommand : ICommand { private readonly Predicate<object> _canExecute; private readonly Action<object> _execute; public event EventHandler CanExecuteChanged; public DelegateCommand(Action<object> execute, Predicate<object> canExecute) { _execute = execute; _canExecute = canExecute; } public bool CanExecute(object parameter) { return _canExecute == null || _canExecute(parameter); } public void Execute(object parameter) { _execute(parameter); } public void RaiseCanExecuteChanged() { if (CanExecuteChanged != null) { CanExecuteChanged(this, EventArgs.Empty); } } } }