/// <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); } } }
private void OnClipboardChanged(object sender, OwnerChangeArgs a) { var atom = Gdk.Atom.Intern("application/x-copysharp-ignore", false); GetClipboard().RequestContents(atom, (clipboard1, data) => { if (data.Length == -1) { GetClipboard().RequestText( (clipboard2, text) => RaiseClipboardTextChanged(text)); } }); }
/// <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); } } }
private void Clipboard_OwnerChange(object o, OwnerChangeArgs args) { ContentChanged?.Invoke(this, args); }
/* Event members */ private void OnOwnerChange(object o, OwnerChangeArgs args) { Base.Ui.Menus.SetCutCopySensitivity(IsCutCopyAvailable(o as Clipboard)); }