private void WriteCompleteCheck_Tick(object sender, EventArgs e) { using (FileStream fs = new FileStream(CurrentScreenshot.InternalFileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)) { Trace.WriteLine("Checking written file size...", string.Format("PeekPreview.WriteCompleteCheck_Tick [{0}]", System.Threading.Thread.CurrentThread.Name)); if (fs.Length > 0 && CurrentStreamLength == fs.Length) { Trace.WriteLine("Write completed, loading file...", string.Format("PeekPreview.WriteCompleteCheck_Tick [{0}]", System.Threading.Thread.CurrentThread.Name)); WriteCompleteCheck.Enabled = false; using (var LatestScreenshotImageData = new MemoryStream()) { fs.CopyTo(LatestScreenshotImageData); CurrentScreenshot.SetOverrideImageData(new Bitmap(LatestScreenshotImageData)); } ReloadPreviewImage(); Opacity = 1; FadeCloseCountdown.Enabled = true; } else { //Yes, this will never complete on the first tick. This is by design. We want two consecutive same-sized ticks before reloading the image. We want to make sure we have the whole thing, and even if Length > 0 that's no guarantee. CurrentStreamLength = fs.Length; } } }
public void CopyCurrentImageToClipboard() { if (CurrentScreenshot.Image.IsAnimatedGif()) { string[] files = new string[1]; files[0] = CurrentScreenshot.Path; this.DoDragDrop(new DataObject(DataFormats.FileDrop, files), DragDropEffects.Copy); } CurrentScreenshot.PutInClipboard(); }
public void DeleteCurrentImage() { if (images.Count > 1) { CurrentScreenshot.DisposeImageCache(); CurrentScreenshot.Delete(); images.RemoveAt(imagesIndex); if (imagesIndex > images.Count - 1) { imagesIndex = images.Count - 1; } UpdateUI(); } }
public override NSImage GetScreenshot() { NSAutoreleasePool pool = new NSAutoreleasePool(); try { if (CurrentScreenshot != null) { CurrentScreenshot.Release(); CurrentScreenshot = null; } NSImage img = null; if (m_sessionViewController != null) { img = m_sessionViewController.GetScreenshot(); } if (img != null) { CurrentScreenshot = img.Retain <NSImage>(); } } catch (Exception ex) { ApiUtils.Log.Add(new RoyalLogEntry() { Severity = RoyalLogEntry.Severities.Debug, Action = RoyalLogEntry.ACTION_PLUGIN, PluginName = PLUGIN_NAME, PluginID = PLUGIN_ID, Message = "Error while getting screenshot", Details = ex.ToString() }); } finally { if (pool != null) { pool.Drain(); pool = null; } } return(CurrentScreenshot); }
public override void Dealloc() { this.LogDealloc(true); if (m_sessionViewController != null) { SessionView = null; m_sessionViewController.Release(); m_sessionViewController = null; } if (CurrentScreenshot != null) { CurrentScreenshot.Release(); CurrentScreenshot = null; } this.SendMessageSuper(DummyConnectionClass, "dealloc"); }
private void ReloadPreviewImage() { Trace.WriteLine("Reloading image...", string.Format("PeekPreview.ReloadPreviewImage [{0}]", System.Threading.Thread.CurrentThread.Name)); this.SuspendLayout(); pbPreview.SizeMode = PictureBoxSizeMode.Zoom; //using (MemoryStream stream = LatestScreenshot.GetEditedScreenshotPNGImageThumbnailStream()) using (MemoryStream stream = CurrentScreenshot.EditedScreenshotPNGImageStream()) pbPreview.Image = Bitmap.FromStream(stream); ImageAspectRatio = (float)pbPreview.Image.Width / (float)pbPreview.Image.Height; this.Width = Screen.PrimaryScreen.WorkingArea.Width / 4; float TargetPictureBoxHeight = Math.Min(Math.Min((float)this.Width / ImageAspectRatio, (float)pbPreview.Image.Height), Screen.PrimaryScreen.WorkingArea.Height - 20); this.Height = (int)Math.Min(TargetPictureBoxHeight + pnButtons.Height + (this.Height - this.ClientRectangle.Height), Screen.PrimaryScreen.WorkingArea.Height / 2); this.Width = (int)Math.Min((float)this.Height * ImageAspectRatio, this.Width); pbPreview.Width = this.ClientRectangle.Width; pbPreview.Height = this.ClientRectangle.Height - pnButtons.Height; pbPreview.Top = 0; pbPreview.Left = 0; int AdjustedWidth = (int)(this.Height * ImageAspectRatio); if (pbPreview.Height > pbPreview.Image.Height && AdjustedWidth < this.Width) { this.Height = pbPreview.Image.Height; this.Width = AdjustedWidth; } SetWindowPosition(); this.ResumeLayout(true); Trace.WriteLine("Done.", string.Format("PeekPreview.ReloadPreviewImage [{0}]", System.Threading.Thread.CurrentThread.Name)); }
/// <summary> /// Gets the color from the screenshot at the specified coordinates /// </summary> private Color GetScreenshotColorAt(int x, int y) { // get the color at the current cursor position from the screenshot return(CurrentScreenshot.GetPixelSafe(x, y)); }