Example #1
0
        private void Event_KeyUp(object sender, KeyEventArgs e)
        {
            ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> > subscribeds = null;
            KeysSubscription k = new KeysSubscription(e.KeyCode, e.Alt, e.Control, e.Shift);

            lock (mKeysSubscriptions)
            {
                if (mKeysSubscriptions.ContainsKey(k))
                {
                    subscribeds = new ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> >(mKeysSubscriptions[k]);
                }
            }

            if (subscribeds != null)
            {
                SubscribedKeyPressEventArgs arg = new SubscribedKeyPressEventArgs(k);
                foreach (EventHandler <SubscribedKeyPressEventArgs> handler in subscribeds)
                {
                    Raiser.CallDelegatorBySync(handler, new object[] { this, arg });
                }
            }
            else
            {
                IRemoteDesktopClientInternal proxy = mProxy;
                if (proxy != null && proxy.IsActive)
                {
                    try
                    {
                        proxy.ClientSendKeyEvent(new KeyboardEventArgs(KeyboardEventTypeEnum.Up, e.KeyCode));
                    }
                    catch (Exception) { }
                }
                //LogKeyEvent(sender, "KEY-UP", e);
            }
        }
Example #2
0
        /// <summary>
        /// Unsubscribe for keys.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        /// <param name="e">The decimal.</param>
        public void UnsubscribeForKeys(KeysSubscription subscription, EventHandler <SubscribedKeyPressEventArgs> e)
        {
            if (subscription == null)
            {
                ThrowHelper.ThrowArgumentNullException("subscription");
            }
            if (e == null)
            {
                ThrowHelper.ThrowArgumentNullException("e");
            }

            lock (mKeysSubscriptions)
            {
                if (mKeysSubscriptions.ContainsKey(subscription))
                {
                    ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> >        list = mKeysSubscriptions[subscription];
                    IEnumeratorSpecialized <EventHandler <SubscribedKeyPressEventArgs> > en   = list.GetEnumerator();
                    while (en.MoveNext())
                    {
                        if (en.Current.Method.Equals(e.Method) && en.Current.Target.Equals(e.Target))
                        {
                            en.Remove();
                            break;
                        }
                    }
                    if (list.Count == 0)
                    {
                        mKeysSubscriptions.Remove(subscription);
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Subscribes for keys.
        /// </summary>
        /// <param name="subscription">The subscription.</param>
        /// <param name="e">The decimal.</param>
        public void SubscribeForKeys(KeysSubscription subscription, EventHandler <SubscribedKeyPressEventArgs> e)
        {
            DoDisposeCheck();

            if (subscription == null)
            {
                ThrowHelper.ThrowArgumentNullException("subscription");
            }
            if (e == null)
            {
                ThrowHelper.ThrowArgumentNullException("e");
            }

            lock (mKeysSubscriptions)
            {
                ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> > subscribers = null;
                if (mKeysSubscriptions.ContainsKey(subscription))
                {
                    subscribers = mKeysSubscriptions[subscription];
                }
                else
                {
                    subscribers = new ListSpecialized <EventHandler <SubscribedKeyPressEventArgs> >();
                    mKeysSubscriptions[subscription] = subscribers;
                }
                subscribers.Add(e);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="SubscribedKeyPressEventArgs" /> class.
 /// </summary>
 /// <param name="subscription">The subscription.</param>
 public SubscribedKeyPressEventArgs(KeysSubscription subscription)
 {
     if (subscription == null)
     {
         ThrowHelper.ThrowArgumentNullException("subscription");
     }
     this.Subscription = subscription;
 }
Example #5
0
        /// <summary>
        /// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, obj))
            {
                return(true);
            }
            if (!this.GetType().Equals(obj.GetType()))
            {
                return(false);
            }

            KeysSubscription s = (KeysSubscription)obj;

            return(this.Key.Equals(s.Key) && this.Alt.Equals(s.Alt) && this.Control.Equals(s.Control) && this.Shift.Equals(s.Shift));
        }