Ejemplo n.º 1
0
        /// <summary>
        /// Handles change in mouse clipboard.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="args">Event arguments.</param>
        private void OnMouseClipboardOwnerChanged(object sender, OwnerChangeArgs args)
        {
            if (!Settings.Instance[Settings.Keys.Core.MouseClipboard].AsBoolean())
                return;

            if (this.mouseClipboard.WaitIsTextAvailable())
            {
                lock (this.timerLock)
                {
                    if (this.timer != null)
                    {
                        this.timer.Change(MouseClipboardDelay, System.Threading.Timeout.Infinite);
                    }
                    else
                    {
                        this.timer = new Timer((o) =>
                        {
                            lock (this.timerLock)
                            {
                                Gtk.Application.Invoke((s, e) => this.OnMouseTextReceived(this.mouseClipboard, this.mouseClipboard.WaitForText()));
                                this.timer.Dispose();
                                this.timer = null;
                            }
                        }, null, MouseClipboardDelay, System.Threading.Timeout.Infinite);
                    }
                }
            }
            else
            {
                if (this.MouseItem != null)
                    this.SetAsMouseContent(this.MouseItem);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Handles change in keyboard clipboard.
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="args">Event arguments.</param>
        private void OnKeyboardClipboardOwnerChanged(object sender, OwnerChangeArgs args)
        {
            if (!Settings.Instance[Settings.Keys.Core.KeyboardClipboard].AsBoolean())
                return;

            if (Settings.Instance[Settings.Keys.Core.Images].AsBoolean() && this.keyboardClipboard.WaitIsImageAvailable())
            {
                this.OnKeyboardImageReceived(this.keyboardClipboard, this.keyboardClipboard.WaitForImage());
            }
            else if (this.keyboardClipboard.WaitIsTargetAvailable(Targets.Atoms[Targets.File]))
            {
                this.OnKeyboardContentReceived(this.keyboardClipboard, this.keyboardClipboard.WaitForContents(Targets.Atoms[Targets.File]));
            }
            else if (this.keyboardClipboard.WaitIsTargetAvailable(Targets.Atoms[Targets.Html]))
            {
                this.OnKeyboardContentReceived(this.keyboardClipboard, this.keyboardClipboard.WaitForContents(Targets.Atoms[Targets.Html]));
            }
            else if (this.keyboardClipboard.WaitIsTextAvailable())
            {
                this.OnKeyboardTextReceived(this.keyboardClipboard, this.keyboardClipboard.WaitForText());
            }
            else if (args != null && args.Event.Reason == OwnerChange.Close)
            {
                if (this.KeyboardItem != null)
                    this.SetAsKeyboardContent(this.KeyboardItem);
            }
        }