コード例 #1
0
        /// <summary>
        /// Gets the <see cref="IClickAction"/> associated with a shortcut.
        /// </summary>
        /// <param name="shortcut">The shortcut for which an <see cref="IClickAction"/> is to be found.</param>
        /// <returns>An <see cref="IClickAction"/> or null.</returns>
        public IClickAction GetKeyboardAction(KeyboardButtonShortcut shortcut)
        {
            if (shortcut == null || shortcut.IsEmpty)
            {
                return(null);
            }

            var actions = (IActionSet) new ActionSet();

            foreach (var tool in _tools.Keys)
            {
                actions = actions.Union(tool.Actions);
            }

            var clickActions = actions.OfType <IClickAction>().ToList();

            // precedence is given to actions on the viewer keyboard site
            return(((FindClickAction(shortcut, ImageViewerComponent.KeyboardSite, clickActions)
                    // if not defined, give consideration to the viewer context menu
                     ?? FindClickAction(shortcut, ImageViewerComponent.ContextMenuSite, clickActions))
                    // if still not found, search the global toolbars
                    ?? FindClickAction(shortcut, _globalToolbarActionSite, clickActions))
                   // then the global menus
                   ?? FindClickAction(shortcut, _globalMenusActionSite, clickActions)
                   // and finally any other site in our toolset that hasn't already been covered
                   //TODO (CR Orion): do we even have to order by site? Free-for-all is probably ok at this point.
                   ?? clickActions.Where(a => !_defaultSites.Contains(a.Path.Site))
                   .OrderBy(a => a.Path.Site)
                   .FirstOrDefault(a => shortcut.Equals(a.KeyStroke)));
        }
コード例 #2
0
        private static IClickAction FindClickAction(KeyboardButtonShortcut shortcut, string @namespace, string site, IActionSet actionSet)
        {
            var actions = ActionModelRoot.CreateModel(@namespace, site, actionSet).GetActionsInOrder();

            foreach (var action in actions)
            {
                var clickAction = action as IClickAction;
                if (clickAction != null && shortcut.Equals(clickAction.KeyStroke))
                {
                    return(clickAction);
                }
            }

            return(null);
        }
コード例 #3
0
	    private static IClickAction FindClickAction(KeyboardButtonShortcut shortcut, string site, IEnumerable<IClickAction> actionSet)
		{
            //This used to use the ActionModel to create them in the right order, but a properly configured action model
            //shouldn't have repeated keyboard shortcuts, at least not within the same site.
            return actionSet.FirstOrDefault(a => a.Path.Site == site && shortcut.Equals(a.KeyStroke));
		}
コード例 #4
0
	    /// <summary>
	    /// Gets the <see cref="IClickAction"/> associated with a shortcut.
	    /// </summary>
	    /// <param name="shortcut">The shortcut for which an <see cref="IClickAction"/> is to be found.</param>
	    /// <returns>An <see cref="IClickAction"/> or null.</returns>
	    public IClickAction GetKeyboardAction(KeyboardButtonShortcut shortcut)
	    {
	        if (shortcut == null || shortcut.IsEmpty)
	            return null;

	        var actions = (IActionSet) new ActionSet();
	        foreach (var tool in _tools.Keys)
	            actions = actions.Union(tool.Actions);

	        var clickActions = actions.OfType<IClickAction>().ToList();
	        // precedence is given to actions on the viewer keyboard site
	        return ((FindClickAction(shortcut, ImageViewerComponent.KeyboardSite, clickActions)
	                    // if not defined, give consideration to the viewer context menu
                        ?? FindClickAction(shortcut, ImageViewerComponent.ContextMenuSite, clickActions))
	                    // if still not found, search the global toolbars
	                    ?? FindClickAction(shortcut, _globalToolbarActionSite, clickActions))
	                    // then the global menus
	                    ?? FindClickAction(shortcut, _globalMenusActionSite, clickActions)
	                    // and finally any other site in our toolset that hasn't already been covered
	                    //TODO (CR Orion): do we even have to order by site? Free-for-all is probably ok at this point.
	                    ?? clickActions.Where(a => !_defaultSites.Contains(a.Path.Site))
                            .OrderBy(a => a.Path.Site)
	                        .FirstOrDefault(a => shortcut.Equals(a.KeyStroke));
	    }
コード例 #5
0
 private static IClickAction FindClickAction(KeyboardButtonShortcut shortcut, string site, IEnumerable <IClickAction> actionSet)
 {
     //This used to use the ActionModel to create them in the right order, but a properly configured action model
     //shouldn't have repeated keyboard shortcuts, at least not within the same site.
     return(actionSet.FirstOrDefault(a => a.Path.Site == site && shortcut.Equals(a.KeyStroke)));
 }
コード例 #6
0
ファイル: ViewerShortcutManager.cs プロジェクト: nhannd/Xian
		private static IClickAction FindClickAction(KeyboardButtonShortcut shortcut, string @namespace, string site, IActionSet actionSet)
		{
			var actions = ActionModelRoot.CreateModel(@namespace, site, actionSet).GetActionsInOrder();
			foreach (var action in actions)
			{
				var clickAction = action as IClickAction;
				if (clickAction != null && shortcut.Equals(clickAction.KeyStroke))
						return clickAction;
			}

			return null;
		}