コード例 #1
0
ファイル: PeekPreview.cs プロジェクト: jzabroski/ProSnap
        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;
                }
            }
        }
コード例 #2
0
 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();
 }
コード例 #3
0
 public void DeleteCurrentImage()
 {
     if (images.Count > 1)
     {
         CurrentScreenshot.DisposeImageCache();
         CurrentScreenshot.Delete();
         images.RemoveAt(imagesIndex);
         if (imagesIndex > images.Count - 1)
         {
             imagesIndex = images.Count - 1;
         }
         UpdateUI();
     }
 }
コード例 #4
0
        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);
        }
コード例 #5
0
        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");
        }
コード例 #6
0
ファイル: PeekPreview.cs プロジェクト: jzabroski/ProSnap
        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));
        }
コード例 #7
0
ファイル: Main.cs プロジェクト: kenneth423/Clarified
 /// <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));
 }