private void OnGlobalHookClipboard(object sender, ClipboardChangedEventArgs e) { if (!ClientState.CurrentClientFocused) { //Console.WriteLine("Trying to set the clipboard when we're not the current client..."); return; } //if our application has received a clipboard push from the server, this event still fires, so bail out if we are currently syncing the clipboard. //don't process a hook event within 2 seconds #if BailClient if (ShouldHookBailKeyboard()) { return; } ClientState.LastHookEvent_Keyboard = DateTime.UtcNow; #endif //Console.WriteLine("Sending clipboard to server"); #if QUEUE_CLIENT _dispatcher.Process(new ClipboardMessage(e.Value)); #else _dispatcher.Send(ClipboardMessage.GetBytes(e.Value)); #endif }
private void CbdNotifier_ClipboardChanged(object sender, EventArgs e) { if (Transfer != null && Clipboard.ContainsText()) { var text = Clipboard.GetText(); var msg = new ClipboardMessage(text); Transfer.Send(msg); } }
public async Task <IActionResult> SendMessage(ClipboardMessage msg, IFormFile ImageData) { if (ImageData != null) { using (var bytes = new MemoryStream()) { using (var buffer = ImageData.OpenReadStream()) { buffer.CopyTo(bytes); msg.ImageData = bytes.ToArray(); msg.ImageHeaders = "data:" + ImageData.ContentType + ";base64,"; } } } await _hubContext.Clients.All.SendAsync(msg.Group, msg); return(new OkResult()); }
private void OnClipboardFromServer(ClipboardMessage message) { //Console.WriteLine("Received clipboard from server"); //i received a hook event for a copy from another client within 2 seconds of pressing my own //clipboard. //historically this has been happening by a global hook reading my event taps and replaying back over the network //in a feedback loop. This should be solved, but i'm leaving this code here as an extra check. #if BailServer if (ShouldBailKeyboard()) { return; } state.LastServerEvent_Keyboard = DateTime.UtcNow; #endif _hook.SetClipboard(message.Data); }
private void HandleClipboardMessage(ClipboardMessage msg) { switch (msg.MessageCase) { case ClipboardMessage.MessageOneofCase.GrabClipboard: MainForm.GrabClipboard(); break; case ClipboardMessage.MessageOneofCase.RequestClipboardContents: SendClipboardData(msg.RequestClipboardContents); break; case ClipboardMessage.MessageOneofCase.ClipboardContents: MainForm.SetClipboardResponse(msg.ClipboardContents); break; case ClipboardMessage.MessageOneofCase.ContentTypes: MainForm.SetClipboardFormats(msg.ContentTypes.Types_.ToArray()); break; } }
internal void sendClipboardAsync(ClipboardMessage msg, AsyncCallback callback, Object state) { if (!(msg.username != null && msg.username.Equals(_username))) msg.sendMeAsync(_clipTcp.GetStream(), callback, state); }
internal void sendClipboard(ClipboardMessage msg) { if (!(msg.username != null && msg.username.Equals(_username))) msg.sendMe(_clipTcp.GetStream()); }
public async Task SendClipboard(ClipboardMessage message) { await Clients.All.SendAsync(message.Group, message); }
public void DispatchClipboard(ClipboardMessage msg) { clipQueue.Add(msg); }
private void receivedClipboard(ClipboardMessage msg) { if (this.InvokeRequired) { this.Invoke(new receivedClipboardDelegate(this.receivedClipboard), new object[] { msg }); } else { System.Collections.Specialized.StringCollection paths = new System.Collections.Specialized.StringCollection(); switch (msg.clipboardType) { case ClipBoardType.TEXT: string s = msg.text; IDataObject ido = new DataObject(); ido.SetData(s); Clipboard.SetDataObject(ido, true); break; case ClipBoardType.FILE: BinaryWriter bWrite; try { bWrite = new BinaryWriter(File.Open(Path.GetFullPath(@".\File ricevuti server\") + msg.filename, FileMode.Create)); } catch(DirectoryNotFoundException) { Directory.CreateDirectory(Path.GetFullPath(@".\File ricevuti server\")); bWrite = new BinaryWriter(File.Open(Path.GetFullPath(@".\File ricevuti server\") + msg.filename, FileMode.Create)); } bWrite.Write(msg.filedata); bWrite.Close(); paths.Add(Path.GetFullPath(@".\File ricevuti server\") + msg.filename); Clipboard.SetFileDropList(paths); break; case ClipBoardType.BITMAP: Bitmap bitm = msg.bitmap; Clipboard.SetImage(bitm); break; } } }
private void bntClipboard_Click(object sender, EventArgs e) { string strclip; IDataObject d = Clipboard.GetDataObject(); if (d.GetDataPresent(DataFormats.Text)) //invio testo { strclip = (string)d.GetData(DataFormats.Text); ClipboardMessage cm = new ClipboardMessage(user); cm.text = strclip; cm.clipboardType = ClipBoardType.TEXT; DispatchClipboard(cm); } else if (d.GetDataPresent(DataFormats.FileDrop, true)) //invio file { object fromClipboard = d.GetData(DataFormats.FileDrop); foreach (string sourceFileName in (Array)fromClipboard) { ClipboardMessage cm = new ClipboardMessage(user); cm.clipboardType = ClipBoardType.FILE; cm.filename = Path.GetFileName(sourceFileName); cm.filedata = File.ReadAllBytes(sourceFileName); DispatchClipboard(cm); } } else if (Clipboard.ContainsImage()) //invio immagine { Bitmap img = (Bitmap)Clipboard.GetImage(); ClipboardMessage cm = new ClipboardMessage(user); cm.bitmap = img; cm.clipboardType = ClipBoardType.BITMAP; DispatchClipboard(cm); } }