예제 #1
0
        public static unsafe HotKey Register(byte virtualKey, KeyFlags keyFlags, string description, Action <HotKey> action)
        {
            var hotKey = new HotKey(action);

            hotKey._id = DisplayAPI.RegisterHotKey(
                virtualKey,
                keyFlags,
                description,
                CallbackHolder.HotKeyCallback,
                GCHandle.ToIntPtr(hotKey._handle).ToPointer());
            return(hotKey);
        }
예제 #2
0
        /// <summary>
        /// Register a handler name with a new handler instance.
        /// </summary>
        /// <param name="sHandlerName">The name of the request handler we want the API to use as a look up.</param>
        /// <param name="kHandlerInstance">The instance responsible for handling all these requests.</param>
        /// <returns>The normalised name of the handler.  This is practically just a lower case version of sHandlerName.</returns>
        /// <remarks>This is threadsafe.</remarks>
        public static String RegisterRequestHandler(String sHandlerName, DisplayAPI.IRequest kHandlerInstance)
        {
            // Check we have valid data.
            if (sHandlerName == null || sHandlerName == "") throw new ArgumentNullException("Invalid handler name.");

            // Transform the handler into lower case for the lookups.
            sHandlerName = sHandlerName.ToLower();

            // Add us to the table of registered items.
            mHandlerLock.WaitOne();
            dRequestHandlers[sHandlerName] = kHandlerInstance;
            mHandlerLock.ReleaseMutex();

            // Return the name.
            return sHandlerName;
        }