ICommandState Interface

Represents the states of a command for a specific command binding. When a state value is set (eg. Enabled) it can be applied for all of the command sources. By default, no application occurs but this can be overridden if an ICommandStateUpdater is added to the binding by the ICommandBinding.AddStateUpdater method. For example, if the command sources are UI elements (eg. a button and a menu item), then the Enabled or any arbitrary state (eg. text, image, shortcut, etc.) can be applied to the sources as properties.

Definition

Namespace: KGySoft.ComponentModel
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 9.0.0-preview.1
C#
public interface ICommandState : IDictionary<string, Object>, 
	ICollection<KeyValuePair<string, Object>>, IEnumerable<KeyValuePair<string, Object>>, 
	IEnumerable, INotifyPropertyChanged
Implements
ICollectionKeyValuePairString, Object, IDictionaryString, Object, IEnumerableKeyValuePairString, Object, IEnumerable, INotifyPropertyChanged

Remarks

The Enabled state, which is also predefined as a property, has a special function. By setting the Enabled property the execution of the command can be disabled or enabled.

If a binding has no updaters, then the states are not synchronized back to the sources.

A state updater can be added to a binding by the ICommandBinding.AddStateUpdater method. Multiple updaters can be added so if the first one cannot apply a state entry, then the second one will be used as a fallback and so on.

If state entries represent properties on the source you can add the PropertyCommandStateUpdater to the ICommandBinding so changing the Enabled, Text, Image, Shortcut, etc. state entries will change the same properties on the command sources as well.

  Tip

See the Remarks section of the ICommand interface for details and examples about commands.

Properties

AsDynamic Gets the state as a dynamic object so the states can be set by simple property setting syntax.
Enabled Gets or sets whether the command is enabled in the current binding.
Default value: .

Extension Methods

AddRangeKeyValuePairString, Object Adds a collection to the target ICollectionT.
(Defined by CollectionExtensions)
AsThreadSafeKeyValuePairString, Object Returns a LockingCollectionT, which provides a thread-safe wrapper for the specified collection. This only means that if the members are accessed through the returned LockingCollectionT, then the inner state of the wrapped collection remains always consistent and not that all the multi-threading concerns can be ignored.
See the Remarks section of the LockingCollectionT class for details and some examples.
(Defined by CollectionExtensions)
CreatePropertyBinding Creates a special binding for the PropertyChanged event of the specified source, which allows to update the specified targetPropertyName in the targets, when the property of sourcePropertyName changes in the source.
(Defined by Command)
CreatePropertyBinding Creates a special binding for the PropertyChanged event of the specified source, which allows to update the specified targetPropertyName in the targets, when the property of sourcePropertyName changes in the source.
(Defined by Command)
CreatePropertyChangedHandlerBinding Creates a special command binding for the PropertyChanged event of the specified source that invokes the specified handler only when the changed property is among the specified propertyNames.
(Defined by Command)
CreatePropertyChangedHandlerBinding Creates a special command binding for the PropertyChanged event of the specified source that invokes the specified handler only when the changed property is among the specified propertyNames.
(Defined by Command)
CreateSynchronizedPropertyBinding Creates a special binding for the PropertyChanged event of the specified source, which allows to update the specified targetPropertyName in the targets, when the property of sourcePropertyName changes in the source. The target properties will be set using the SynchronizationContext of the thread on which this method was called.
(Defined by Command)
CreateSynchronizedPropertyBinding Creates a special binding for the PropertyChanged event of the specified source, which allows to update the specified targetPropertyName in the targets, when the property of sourcePropertyName changes in the source. The target properties will be set using the SynchronizationContext of the thread on which this method was called.
(Defined by Command)
CreateTwoWayPropertyBinding Creates a pair of special bindings for the PropertyChanged event of the specified source and target, which allow to update the specified targetPropertyName and sourcePropertyName in both directions when any of them changes.
(Defined by Command)
ForEachKeyValuePairString, Object Similarly to the List<T>.ForEach method, processes an action on each element of an enumerable collection.
(Defined by EnumerableExtensions)
GetRandomElementKeyValuePairString, Object Gets a random element from the enumerable source using a new FastRandom instance.
(Defined by EnumerableExtensions)
GetRandomElementKeyValuePairString, Object Gets a random element from the enumerable source using a specified Random instance.
(Defined by EnumerableExtensions)
GetValueOrDefaultTActualValue Tries to get the typed value from a string-object dictionary for the given key.
(Defined by DictionaryExtensions)
GetValueOrDefaultTActualValue Tries to get the typed value from a string-object dictionary for the given key.
See the Examples section of the GetValueOrDefaultTActualValue(IDictionaryString, Object, String, TActualValue) method for some examples.
(Defined by DictionaryExtensions)
IndexOf Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IndexOf Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
IndexOfKeyValuePairString, Object Searches for an element in the source enumeration where the specified predicate returns .
(Defined by EnumerableExtensions)
IndexOfKeyValuePairString, Object Searches for an element in the source enumeration.
(Defined by EnumerableExtensions)
IsNullOrEmpty Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
IsNullOrEmptyKeyValuePairString, Object Determines whether the specified source is or empty (has no elements).
(Defined by EnumerableExtensions)
JoinKeyValuePairString, Object Concatenates the items of the source collection into a new string instance using the specified separator between the items.
(Defined by EnumerableExtensions)
JoinKeyValuePairString, Object Concatenates the items of the source collection into a new string instance using the specified separator between the items.
(Defined by EnumerableExtensions)
ShuffleKeyValuePairString, Object Shuffles an enumerable source (randomizes its elements) using a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleKeyValuePairString, Object Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleKeyValuePairString, Object Shuffles an enumerable source (randomizes its elements) using the provided seed with a new FastRandom instance.
(Defined by EnumerableExtensions)
ShuffleKeyValuePairString, Object Shuffles an enumerable source (randomizes its elements) using a specified Random instance.
(Defined by EnumerableExtensions)
ToCircularListKeyValuePairString, Object Creates a CircularListT from an IEnumerableT.
(Defined by EnumerableExtensions)
ToStringKeyedDictionaryKeyValuePairString, Object Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified keySelector delegate and a comparer.
(Defined by EnumerableExtensions)
ToStringKeyedDictionaryKeyValuePairString, Object, TValue Creates a StringKeyedDictionaryTValue from an IEnumerableT instance using the specified key and value selector delegates and a comparer.
(Defined by EnumerableExtensions)
TryAdd Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddKeyValuePairString, Object Tries to add the specified item to the collection.
(Defined by EnumerableExtensions)
TryAddRange Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryAddRangeKeyValuePairString, Object Tries to add the specified collection to the target collection.
(Defined by EnumerableExtensions)
TryClear Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
TryClearKeyValuePairString, Object Tries to remove all elements from the collection.
(Defined by EnumerableExtensions)
TryGetCount Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetCountKeyValuePairString, Object Tries to get the number of elements in the source enumeration without enumerating it.
(Defined by EnumerableExtensions)
TryGetElementAt Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryGetElementAtKeyValuePairString, Object Tries to get an item at the specified index in the collection.
(Defined by EnumerableExtensions)
TryInsert Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertKeyValuePairString, Object Tries to insert the specified item at the specified index to the collection.
(Defined by EnumerableExtensions)
TryInsertRange Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryInsertRangeKeyValuePairString, Object Tries to insert the specified collection into the target collection.
(Defined by EnumerableExtensions)
TryRemove Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveKeyValuePairString, Object Tries to remove the specified item from to the collection.
(Defined by EnumerableExtensions)
TryRemoveAt Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveAtKeyValuePairString, Object Tries to remove an item at the specified index from the collection.
(Defined by EnumerableExtensions)
TryRemoveRange Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryRemoveRangeKeyValuePairString, Object Tries to remove count amount of items from the specified collection at the specified index.
(Defined by EnumerableExtensions)
TryReplaceRange Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions)
TryReplaceRangeKeyValuePairString, Object Tries to remove count amount of items from the target at the specified index, and to insert the specified collection at the same position. The number of elements in collection can be different from the amount of removed items.
(Defined by EnumerableExtensions)
TrySetElementAt Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)
TrySetElementAtKeyValuePairString, Object Tries to set the specified item at the specified index in the collection.
(Defined by EnumerableExtensions)

See Also