コード例 #1
0
 public static void UnregisterChordsConsumer(int index)
 {
     if (0 > index || index >= ChordMessageFilter.Current.chordsConsumers.Count)
     {
         return;
     }
     ChordMessageFilter.UnregisterChordsConsumer(ChordMessageFilter.Current.chordsConsumers[index]);
 }
コード例 #2
0
 public static bool UnregisterInstance()
 {
     if (ChordMessageFilter.filterInstances.ContainsKey(Thread.CurrentThread.ManagedThreadId))
     {
         return(ChordMessageFilter.UnregisterInstance(ChordMessageFilter.filterInstances[Thread.CurrentThread.ManagedThreadId]));
     }
     return(false);
 }
コード例 #3
0
        bool IMessageFilter.PreFilterMessage(ref Message msg)
        {
            if (msg.Msg < 256 || msg.Msg > 264)
            {
                return(false);
            }
            int wparam = (int)msg.WParam;

            this.SetModifiers(wparam, true);
            if (msg.Msg == 256 || msg.Msg == 260)
            {
                if ((msg.LParam.ToInt32() >> 16 & (int)ushort.MaxValue & 16384) <= 0 && !ChordMessageFilter.constants.Contains(wparam))
                {
                    Keys keys = ChordMessageFilter.IsValidKey((Keys)wparam);
                    this.stack.Push(keys);
                    if (this.keyMapActivated)
                    {
                        this.tipsStack.Push(keys);
                    }
                }
                if (this.IsRuntimeChord())
                {
                    if (this.ProccessChord())
                    {
                        this.keyMapActivatedInstance = (IComponentTreeHandler)null;
                        this.stack.Clear();
                        ChordMessageFilter.previousKeyCode = wparam;
                        return(true);
                    }
                }
                else if (wparam == 18 || wparam == 121)
                {
                    this.isAltKeyDown = true;
                }
            }
            if (msg.Msg == 257 || msg.Msg == 261)
            {
                if ((wparam == 18 || wparam == 121) && (this.stack.Count == 0 && this.isAltKeyDown))
                {
                    this.InvokeKeyMaps();
                }
                this.isAltKeyDown = false;
                this.SetModifiers(wparam, false);
                if (!this.chordModifier.ShiftModifier && !this.chordModifier.ControlModifier && !this.chordModifier.AltModifier)
                {
                    this.chordModifier = (ChordModifier)null;
                    this.stack.Clear();
                    if ((wparam == 18 || wparam == 121) && ChordMessageFilter.previousKeyCode != 17)
                    {
                        ChordMessageFilter.previousKeyCode = wparam;
                        return(this.ProccessKeyMaps());
                    }
                }
            }
            ChordMessageFilter.previousKeyCode = wparam;
            return(false);
        }
コード例 #4
0
 /// <summary>
 /// Initializes a new instance of the ChordMessageFilter class.
 /// </summary>
 /// <returns>Instance of the ChordMessageFilter class</returns>
 public static ChordMessageFilter CreateInstance()
 {
     if (!InstanceCreated)
     {
         ChordMessageFilter.filterInstance = new ChordMessageFilter();
         InstanceCreated = true;
     }
     return(ChordMessageFilter.filterInstance);
 }
コード例 #5
0
 internal virtual void RemoveShortcutsSupport()
 {
     if (this.chordMessageFilter == null)
     {
         return;
     }
     ChordMessageFilter.UnregisterChordsConsumer(this);
     this.chordMessageFilter = (ChordMessageFilter)null;
 }
コード例 #6
0
 internal virtual void AddShortcutsSupport()
 {
     try
     {
         this.chordMessageFilter = ChordMessageFilter.CreateInstance();
         ChordMessageFilter.RegisterChordsConsumer(this);
     }
     finally
     {
     }
 }
コード例 #7
0
 public static void UnregisterChordsConsumer(Shortcuts consumer)
 {
     if (ChordMessageFilter.Current.chordsConsumers.Contains(consumer))
     {
         ChordMessageFilter.Current.chordsConsumers.Remove(consumer);
     }
     if (ChordMessageFilter.Current.chordsConsumers.Count != 0)
     {
         return;
     }
     ChordMessageFilter.UnregisterInstance();
 }
コード例 #8
0
        public static void RegisterChordsConsumer(Shortcuts consumer)
        {
            if (Current.chordsConsumers.Count == 0)
            {
                ChordMessageFilter.RegisterInstance();
            }

            if (!Current.chordsConsumers.Contains(consumer))
            {
                Current.chordsConsumers.Add(consumer);
            }
        }
コード例 #9
0
 internal virtual void RemoveShortcutsSupport()
 {
     try
     {
         if (this.chordMessageFilter != null)
         {
             ChordMessageFilter.UnregisterChordsConsumer(this);
             this.chordMessageFilter = null;
         }
     }
     finally
     {
     }
 }
コード例 #10
0
        public static ChordMessageFilter CreateInstance()
        {
            if (ChordMessageFilter.filterInstances == null)
            {
                ChordMessageFilter.filterInstances = new Dictionary <int, ChordMessageFilter>();
            }
            if (ChordMessageFilter.filterInstances.ContainsKey(Thread.CurrentThread.ManagedThreadId))
            {
                return(ChordMessageFilter.filterInstances[Thread.CurrentThread.ManagedThreadId]);
            }
            ChordMessageFilter chordMessageFilter = new ChordMessageFilter();

            ChordMessageFilter.filterInstances.Add(Thread.CurrentThread.ManagedThreadId, chordMessageFilter);
            return(chordMessageFilter);
        }
コード例 #11
0
 public static bool UnregisterInstance(ChordMessageFilter filterInstance)
 {
     try
     {
         if (!ChordMessageFilter.registeredFilters.Contains(filterInstance))
         {
             return(false);
         }
         ChordMessageFilter.registeredFilters.Remove(filterInstance);
         Application.RemoveMessageFilter((IMessageFilter)filterInstance);
         return(true);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error while unregistering ChordMessageFilter instance", ex);
     }
 }
コード例 #12
0
 internal static bool RegisterInstance(ChordMessageFilter filterInstance)
 {
     try
     {
         if (ChordMessageFilter.registeredFilters.Contains(filterInstance))
         {
             return(false);
         }
         ChordMessageFilter.registeredFilters.Add(filterInstance);
         Application.AddMessageFilter((IMessageFilter)filterInstance);
         return(true);
     }
     catch (Exception ex)
     {
         throw new ApplicationException("Error while registering ChordMessageFilter instance", ex);
     }
 }
コード例 #13
0
 public static void ClearChordsConsumers()
 {
     ChordMessageFilter.Current.chordsConsumers.Clear();
     ChordMessageFilter.UnregisterInstance();
 }