public void SetText(string text) { if (!WinClipboard.SetText(text)) { ISLogger.Write("WindowsClipboardMonitor: Failed to set text: Win32 code {0}", Marshal.GetLastWin32Error().ToString("X")); return; } }
//Writes a string to the clipboard //--This method needs be invoked on the dedicated desktop thread! private void SetClipboard(string text) { ignoreClipboardData = true; if (!WinClipboard.SetText(text)) { ISLogger.Write("Failed to set clipboard text: Win32 code {0}", Marshal.GetLastWin32Error().ToString("X")); return; } ISLogger.Write("Clipboard text set"); }
private void C_ClipboardTextCopied(object sender, string cbText) { if (cbText == null) { ISLogger.Write("Warning: Copied null string from clipboard"); return; } //ISLogger.Write($"{(sender as ConnectedClient).ClientName} copied {e}"); ignoreClipboard = true; if (!WinClipboard.SetText(cbText)) { ISLogger.Write("IsServer: Failed to set clipboard text"); } ConnectedClient senderClient = sender as ConnectedClient; foreach (var client in clientMan.AllClients) { if (client != senderClient && client != ConnectedClient.LocalHost) { client?.SetClipboardText(cbText); } } }