예제 #1
0
        public static bool InvokeShortCuts(Key key, ModifierKeys modifiers)
        {
            var tempShortKey = new ShortKey(key, modifiers);

            if (shortCommandSource.ContainsKey(tempShortKey))
            {
                try
                {
                    var now = DateTime.Now.Ticks;
                    if (now - lastTimeSpan < TimeSpan.FromMilliseconds(800).Ticks)
                    {
                        LogExtensions.Info(null, $"Skip shrortCuts {tempShortKey} with duration too small");
                        return(true);
                    }
                    lastTimeSpan = now;
                    LogExtensions.Info(null, "Invoke ShortKey:{0}", tempShortKey);
                    var tempCommand = shortCommandSource[tempShortKey];
                    tempCommand.Execute(null);
                    LogExtensions.Info(null, "Invoke ShortKey:{0} Succ", tempShortKey);
                }
                catch (Exception ex)
                {
                    LogExtensions.Error(null, ex, "Invoke ShortKey:{0} faild", tempShortKey);
                }
                return(true);
            }
            return(false);
        }
예제 #2
0
 /// <summary>
 /// Equalses the specified other.
 /// </summary>
 /// <param name="other">The other.</param>
 /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
 protected bool Equals(ShortKey other)
 {
     return(Key == other.Key && ModifierKey == other.ModifierKey);
 }