Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Commit

Permalink
More documentation
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/shortcuts@4609 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
  • Loading branch information
sandrejev committed Aug 6, 2009
1 parent 9b86c2f commit d0d39c4
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 43 deletions.
Expand Up @@ -221,8 +221,8 @@ public void BindingsChangedHandler(object sender, NotifyBindingsChangedEventArgs
|| (args.Action == NotifyBindingsChangedAction.NamedInstanceModified && OwnerInstanceName == args.UIElementName)
|| (args.Action == NotifyBindingsChangedAction.RoutedUICommandModified && routedCommandName == args.RoutedCommandName)
|| (args.Action == NotifyBindingsChangedAction.NamedTypeModified && OwnerTypeName == args.TypeName)
|| (args.Action == NotifyBindingsChangedAction.GroupAttachmendsModified && ((OwnerTypeName != null && OwnerTypes.Any(t1 => args.AttachedInstances.Any(t2 => t1 == t2.GetType())))
|| (OwnerInstanceName != null && OwnerInstances.Any(t1 => args.AttachedInstances.Any(t2 => t1 == t2)))))
|| (args.Action == NotifyBindingsChangedAction.GroupAttachmendsModified && ((OwnerTypeName != null && OwnerTypes.Any(t1 => args.GroupHandledInstances.Any(t2 => t1 == t2.GetType())))
|| (OwnerInstanceName != null && OwnerInstances.Any(t1 => args.GroupHandledInstances.Any(t2 => t1 == t2)))))
) {
GenerateBindings();

Expand Down
Expand Up @@ -217,6 +217,12 @@ public static void RegisterCommandBindings(object caller, string path)
}
}

/// <summary>
/// Register all input bindings from collection of <see cref="InputBindingDescriptor" />s
/// found through given path
/// </summary>
/// <param name="caller">Caller object</param>
/// <param name="path">Path to collection of <see cref="InputBindingDescriptor" />s</param>
public static void RegisterInputBindings(object caller, string path)
{
var descriptors = AddInTree.BuildItems<InputBindingDescriptor>(path, caller, false);
Expand Down
Expand Up @@ -7,98 +7,173 @@

namespace ICSharpCode.Core.Presentation
{
/// <summary>
/// Represent a method that will handle <see cref="ICSharpCode.Core.Presentation.CommandManager.BindingsChanged" /> event
/// </summary>
public delegate void NotifyBindingsChangedEventHandler(object sender, NotifyBindingsChangedEventArgs args);

/// <summary>
/// Provides data for <see cref="ICSharpCode.Core.Presentation.CommandManager.BindingsChanged" /> event
/// </summary>
public class NotifyBindingsChangedEventArgs : EventArgs
{
private ICollection<BindingInfoTemplate> _modifiedBindingInfoTemplates;
private string _routedCommandName;
private string _typeName;
private ICollection<Type> _oldNamedTypes;
private ICollection<Type> _newNamedTypes;
private string _uiElementName;
private ICollection<UIElement> _oldNamedUIElements;
private ICollection<UIElement> _newNamedUIElements;
private ICollection<UIElement> _attachedInstances;
private BindingGroupCollection _modifiedGroups;
private NotifyBindingsChangedAction _action;

/// <summary>
/// Gets collection of templates which can identify changed
/// <see cref="CommandBindingInfo" /> and <see cref="InputBindingInfo" /> objects
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.BindingInfoModified" />
/// </summary>
public ICollection<BindingInfoTemplate> ModifiedBindingInfoTemplates
{
get {
return _modifiedBindingInfoTemplates;
}
}

private string _routedCommandName;
/// <summary>
/// Gets name of changed named <see cref="System.Windows.Input.RoutedUICommand" /> as registered using
/// <see cref="CommandManager.RegisterRoutedUICommand" />
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.RoutedUICommandModified" />
/// </summary>
public string RoutedCommandName
{
get {
return _routedCommandName;
}
}

private string _typeName;
/// <summary>
/// Gets name of modified named <see cref="Type" /> as registered using <see cref="CommandManager.RegisterNamedUIType" />
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.NamedTypeModified" />
/// </summary>
public string TypeName
{
get {
return _typeName;
}
}

private ICollection<Type> _oldNamedTypes;
/// <summary>
/// Gets collection of types associated with name provided in <see cref="NotifyBindingsChangedEventArgs.TypeName" />
/// before the modification event
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.NamedTypeModified" />
/// </summary>
public ICollection<Type> OldNamedTypes
{
get {
return _oldNamedTypes;
}
}

private ICollection<Type> _newNamedTypes;

/// <summary>
/// Gets collection of types associated with name provided in <see cref="NotifyBindingsChangedEventArgs.TypeName" />
/// after the modification event
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.NamedTypeModified" />
/// </summary>
public ICollection<Type> NewNamedTypes
{
get {
return _newNamedTypes;
}
}

private string _uiElementName;

/// <summary>
/// Gets name of modified named <see cref="UIElement" /> instance as registered using <see cref="CommandManager.RegisterNamedUIElement" />
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.NamedInstanceModified" />
/// </summary>
public string UIElementName
{
get {
return _uiElementName;
}
}

private ICollection<UIElement> _oldNamedUIElements;

/// <summary>
/// Gets collection of <see cref="UIElement" /> instances associated with name provided in <see cref="NotifyBindingsChangedEventArgs.UIElementName" /> property
/// before the modification event
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.NamedInstanceModified" />
/// </summary>
public ICollection<UIElement> OldNamedUIElements
{
get {
return _oldNamedUIElements;
}
}

private ICollection<UIElement> _newNamedUIElements;

/// <summary>
/// Gets collection of <see cref="UIElement" /> instances associated with name provided in <see cref="NotifyBindingsChangedEventArgs.UIElementName" /> property
/// after the modification event
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.NamedInstanceModified" />
/// </summary>
public ICollection<UIElement> NewNamedUIElements
{
get {
return _newNamedUIElements;
}
}

private ICollection<UIElement> _attachedInstances;
public ICollection<UIElement> AttachedInstances
/// <summary>
/// Gets collection of collection of modified <see cref="BindingInfoGroup" />
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.GroupAttachmendsModified" />
/// </summary>
public BindingGroupCollection ModifiedGroups
{
get {
return _attachedInstances;
return _modifiedGroups;
}
}

private BindingGroupCollection _groups;
public BindingGroupCollection Groups
/// <summary>
/// Gets collection of instances whose <see cref="UIElement.CommandBindings" />
/// and <see cref="UIElement.InputBindings" /> collections are controled by
/// groups provided in <see cref="NotifyBindingsChangedEventArgs.ModifiedGroups" /> property
///
/// Provided only when <see cref="NotifyBindingsChangedEventArgs.Action" /> is equal to <see cref="NotifyBindingsChangedAction.GroupAttachmendsModified" />
/// </summary>
public ICollection<UIElement> GroupHandledInstances
{
get {
return _groups;
return _attachedInstances;
}
}

private NotifyBindingsChangedAction _action;
/// <summary>
/// Gets action that caused an event
/// </summary>
public NotifyBindingsChangedAction Action
{
get {
return _action;
}
}

/// <summary>
/// Initializes new instance of <see cref="NotifyBindingsChangedEventArgs" /> that describes
/// <see cref="NotifyBindingsChangedAction.EnforceUpdates" /> event
/// </summary>
/// <param name="action">The action that caused this event. This can only be set to <see cref="NotifyBindingsChangedAction.EnforceUpdates" /></param>
public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action)
{
if(action != NotifyBindingsChangedAction.EnforceUpdates) {
Expand All @@ -113,6 +188,14 @@ public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action)
_action = action;
}

/// <summary>
/// Initializes new instance of <see cref="NotifyBindingsChangedEventArgs" /> that describes
/// <see cref="NotifyBindingsChangedAction.NamedTypeModified" /> event
/// </summary>
/// <param name="action">The action that caused this event. This can only be set to <see cref="NotifyBindingsChangedAction.NamedTypeModified" /></param>
/// <param name="elementName">Registered <see cref="Type" /> name (Can be different from <see cref="System.Type.Name")</param>
/// <param name="oldElements">Collection of <see cref="Type" />s associated with provided name before modification</param>
/// <param name="newElements">Collection of <see cref="Type" />s associated with provided name after modification</param>
public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, string typeName, ICollection<Type> oldTypes, ICollection<Type> newTypes)
{
if(action != NotifyBindingsChangedAction.NamedTypeModified) {
Expand Down Expand Up @@ -154,6 +237,16 @@ public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, string
_newNamedTypes = newTypesArray;
}



/// <summary>
/// Initializes new instance of <see cref="NotifyBindingsChangedEventArgs" /> that describes
/// <see cref="NotifyBindingsChangedAction.NamedInstanceModified" /> event
/// </summary>
/// <param name="action">The action that caused this event. This can only be set to <see cref="NotifyBindingsChangedAction.NamedInstanceModified" /></param>
/// <param name="elementName"><see cref="UIElement" /> instance name</param>
/// <param name="oldElements">Collection of <see cref="UIElement" /> instances associated with provided name before modification</param>
/// <param name="newElements">Collection of <see cref="UIElement" /> instances associated with provided name after modification</param>
public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, string elementName, ICollection<UIElement> oldElements, ICollection<UIElement> newElements)
{
if(action != NotifyBindingsChangedAction.NamedInstanceModified) {
Expand Down Expand Up @@ -195,6 +288,13 @@ public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, string
_newNamedUIElements = newElementsArray;
}


/// <summary>
/// Initializes new instance of <see cref="NotifyBindingsChangedEventArgs" /> that describes
/// <see cref="NotifyBindingsChangedAction.RoutedUICommandModified" /> event
/// </summary>
/// <param name="action">The action that caused this event. This can only be set to <see cref="NotifyBindingsChangedAction.RoutedUICommandModified" /></param>
/// <param name="routedCommandName">Registered or unregistered <see cref="RoutedUICommand" /> name</param>
public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, string routedCommandName)
{
if(action != NotifyBindingsChangedAction.RoutedUICommandModified) {
Expand All @@ -214,6 +314,12 @@ public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, string
_routedCommandName = routedCommandName;
}

/// <summary>
/// Initializes new instance of <see cref="NotifyBindingsChangedEventArgs" /> that describes
/// <see cref="NotifyBindingsChangedAction.BindingInfoModified" /> event
/// </summary>
/// <param name="action">The action that caused this event. This can only be set to <see cref="NotifyBindingsChangedAction.BindingInfoModified" /></param>
/// <param name="templates">Collection of <see cref="BindingInfoTemplate" />s describing modified <see cref="CommandBindingInfo" />s or <see cref="InputBindingInfo" />s</param>
public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, IEnumerable<BindingInfoTemplate> templates)
{
if(action != NotifyBindingsChangedAction.BindingInfoModified) {
Expand All @@ -233,6 +339,14 @@ public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, IEnume
_modifiedBindingInfoTemplates = new HashSet<BindingInfoTemplate>(templates);
}


/// <summary>
/// Initializes new instance of <see cref="NotifyBindingsChangedEventArgs" /> that describes
/// <see cref="NotifyBindingsChangedAction.GroupAttachmendsModified" /> change event
/// </summary>
/// <param name="action">The action that caused this event. This can only be set to <see cref="NotifyBindingsChangedAction.GroupAttachmendsModified" /></param>
/// <param name="groups">Modified groups</param>
/// <param name="attachedInstances">Collection instances (un)registered in <see cref="BindingGroup" /></param>
public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, BindingGroupCollection groups, ICollection<UIElement> attachedInstances)
{
if(action != NotifyBindingsChangedAction.GroupAttachmendsModified) {
Expand All @@ -253,20 +367,47 @@ public NotifyBindingsChangedEventArgs(NotifyBindingsChangedAction action, Bindin
}

_action = action;
_groups = new BindingGroupCollection();
_groups.AddRange(groups);
_modifiedGroups = new BindingGroupCollection();
_modifiedGroups.AddRange(groups);
_attachedInstances = new HashSet<UIElement>(attachedInstances);
}

}

/// <summary>
/// Describes the action that caused a <see cref="ICSharpCode.Core.Presentation.CommandManager.BindingsChanged" /> event.
/// </summary>
public enum NotifyBindingsChangedAction
{
/// <summary>
/// Implicitly enforce executing all handlers
/// </summary>
EnforceUpdates,

/// <summary>
/// Binding info modified
/// </summary>
BindingInfoModified,

/// <summary>
/// Named instance modfied (new <see cref="UIElement" /> added/removed)
/// </summary>
NamedInstanceModified,

/// <summary>
/// Named type modfied (new <see cref="Type" /> added/removed)
/// </summary>
NamedTypeModified,

/// <summary>
/// <see cref="RoutedUICommand" /> registered/unregistered
/// </summary>
RoutedUICommandModified,

/// <summary>
/// Groups modified (group attached/detached to binding info or new <see cref="UIElement" />
/// is registered to be handled by <see cref="BindingGroup" />
/// </summary>
GroupAttachmendsModified
}
}

0 comments on commit d0d39c4

Please sign in to comment.