private void SendScreenshot_Click(object sender, EventArgs e) { System.Drawing.Bitmap screenshot = Screenshot.CreateScreenshot(); byte[] imageMessage = MessageBuilder.BuildImageMessage(screenshot); /** For debugging: save message to file ** FileStream outFile = new FileStream(@"C:\Message.rs", FileMode.Create); outFile.Write(imageMessage, 0, imageMessage.Length); outFile.Close(); **/ string host = Settings.GetIPAddress(); int port = Settings.GetPort(); Sender messageSender = new Sender(host, port); try { messageSender.SendMessage(imageMessage); } catch (Exception ex) { // TODO: Add more elegant error handling System.Windows.MessageBox.Show("Sorry, your message could not be sent."); } screenshot.Dispose(); }
private void SendClipboard_Click(object sender, EventArgs e) { string clipboardText = ""; if (System.Windows.Clipboard.ContainsData(System.Windows.DataFormats.Text)) { clipboardText = System.Windows.Clipboard.GetData(System.Windows.DataFormats.Text) as string; } else { clipboardText = "<BLANK>"; } byte[] textMessage = MessageBuilder.BuildTextMessage(clipboardText); string host = Settings.GetIPAddress(); int port = Settings.GetPort(); Sender messageSender = new Sender(host, port); try { messageSender.SendMessage(textMessage); } catch (Exception ex) { // TODO: Add more elegant error handling System.Windows.MessageBox.Show("Sorry, your message could not be sent."); } }