public static void TakeAndSend() { Rectangle bounds = Screen.GetBounds(Point.Empty); using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size); } using (MemoryStream stream = new MemoryStream()) { bitmap.Save(stream, ImageFormat.Jpeg); byte[] bytes = stream.ToArray(); using (xmds.xmds screenShotXmds = new xmds.xmds()) { screenShotXmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds; screenShotXmds.SubmitScreenShotCompleted += screenShotXmds_SubmitScreenShotCompleted; screenShotXmds.SubmitScreenShotAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, bytes); } } } }
private static void send(Bitmap bitmap) { using (MemoryStream stream = new MemoryStream()) { bitmap.Save(stream, ImageFormat.Jpeg); byte[] bytes = stream.ToArray(); using (xmds.xmds screenShotXmds = new xmds.xmds()) { screenShotXmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=submitScreenshot"; screenShotXmds.SubmitScreenShotCompleted += screenShotXmds_SubmitScreenShotCompleted; screenShotXmds.SubmitScreenShotAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, bytes); } } }
public static void TakeAndSend() { Rectangle bounds; // Override the default size if necessary if (ApplicationSettings.Default.SizeX != 0) { bounds = new Rectangle((int)ApplicationSettings.Default.OffsetX, (int)ApplicationSettings.Default.OffsetY, (int)ApplicationSettings.Default.SizeX, (int)ApplicationSettings.Default.SizeY); } else { bounds = new Rectangle(0, 0, SystemInformation.PrimaryMonitorSize.Width, SystemInformation.PrimaryMonitorSize.Height); } using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height)) { using (Graphics g = Graphics.FromImage(bitmap)) { Point p = new Point(bounds.X, bounds.Y); g.CopyFromScreen(bounds.X, bounds.Y, 0, 0, bounds.Size, CopyPixelOperation.SourceCopy); } using (MemoryStream stream = new MemoryStream()) { bitmap.Save(stream, ImageFormat.Jpeg); byte[] bytes = stream.ToArray(); using (xmds.xmds screenShotXmds = new xmds.xmds()) { screenShotXmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds; screenShotXmds.SubmitScreenShotCompleted += screenShotXmds_SubmitScreenShotCompleted; screenShotXmds.SubmitScreenShotAsync(ApplicationSettings.Default.ServerKey, ApplicationSettings.Default.HardwareKey, bytes); } } } }