Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
DisabledCommand.cs
Go to the documentation of this file.
1 // Copyright (c) 2014 Silicon Studio Corp. (http://siliconstudio.co.jp)
2 // This file is distributed under GPL v3. See LICENSE.md for details.
3 using System;
4 
5 namespace SiliconStudio.Presentation.Commands
6 {
7  /// <summary>
8  /// This class represents a command that is always disabled and does nothing when executed.
9  /// </summary>
10  /// <remarks>This class is a singleton, you can access to the instance via the static property <see cref="Instance"/>.</remarks>
11  public sealed class DisabledCommand : ICommandBase
12  {
13  static DisabledCommand()
14  {
15  Instance = new DisabledCommand();
16  }
17 
18  /// <summary>
19  /// Gets a singleton instance of the <see cref="DisabledCommand"/>
20  /// </summary>
21  public static DisabledCommand Instance { get; private set; }
22 
23  /// <summary>
24  /// Initializes a new instance of the <see cref="DisabledCommand"/> class.
25  /// </summary>
26  private DisabledCommand()
27  {
28  }
29 
30  /// <inheritdoc/>
31  public bool IsEnabled { get { return false; } set { if (value == false) throw new InvalidOperationException("The IsEnabled property of the DisabledCommand cannot be modified"); } }
32 
33  /// <inheritdoc/>
34  public event EventHandler CanExecuteChanged
35  {
36  add { }
37  remove { }
38  }
39 
40  /// <inheritdoc/>
41  public bool CanExecute(object parameter)
42  {
43  return false;
44  }
45 
46  /// <inheritdoc/>
47  public void Execute(object parameter)
48  {
49  throw new InvalidOperationException("The DisabledCommand cannot be executed.");
50  }
51 
52  /// <inheritdoc/>
53  public void Execute()
54  {
55  throw new InvalidOperationException("The DisabledCommand cannot be executed.");
56  }
57  }
58 }
An interface representing an implementation of ICommand with additional properties.
Definition: ICommandBase.cs:10
void Execute()
Executes the command with a null parameter.
This class represents a command that is always disabled and does nothing when executed.