root / trunk / Pithos.Client.WPF / PithosCommand.cs @ 275a059e
History | View | Annotate | Download (1.1 kB)
1 |
// ----------------------------------------------------------------------- |
---|---|
2 |
// <copyright file="PithosCommand.cs" company="Microsoft"> |
3 |
// TODO: Update copyright text. |
4 |
// </copyright> |
5 |
// ----------------------------------------------------------------------- |
6 |
|
7 |
using System.Windows.Input; |
8 |
|
9 |
namespace Pithos.Client.WPF |
10 |
{ |
11 |
using System; |
12 |
using System.Collections.Generic; |
13 |
using System.Linq; |
14 |
using System.Text; |
15 |
|
16 |
/// <summary> |
17 |
/// TODO: Update summary. |
18 |
/// </summary> |
19 |
public class PithosCommand:ICommand |
20 |
{ |
21 |
private Action _action; |
22 |
private Func<bool> _condition; |
23 |
|
24 |
public PithosCommand(Action execute,Func<bool> canExecute=null ) |
25 |
{ |
26 |
_action = execute; |
27 |
_condition = canExecute; |
28 |
|
29 |
} |
30 |
|
31 |
public void Execute(object parameter) |
32 |
{ |
33 |
_action(); |
34 |
} |
35 |
|
36 |
public bool CanExecute(object parameter) |
37 |
{ |
38 |
if (_condition == null) |
39 |
return true; |
40 |
return _condition(); |
41 |
} |
42 |
|
43 |
public event EventHandler CanExecuteChanged; |
44 |
} |
45 |
} |