Esempio n. 1
0
        private void button_Click(object sender, RoutedEventArgs e)
        {
            SetWindowStyle(true);
            selectionRectangle.MouseUp   -= image1_MouseLeftButtonUp;
            selectionRectangle.MouseMove -= image1_MouseMove;
            BackPanel.MouseUp            -= image1_MouseLeftButtonUp;
            BackPanel.MouseMove          -= image1_MouseMove;
            image.MouseUp           -= image1_MouseLeftButtonUp;
            image.MouseMove         -= image1_MouseMove;
            selectionRectangle.Width = 0; //workaround

            if (OwnShotHelpers.GetConfig("DeleteMode") == "Yes")
            {
                File.Delete(ScreenPath);
            }
        }
Esempio n. 2
0
        public void WindowCapture()
        {
            ScreenPath = OwnShotHelpers.RandomName(ssnamelength) + ".png";

            SetWindowStyle(true);
            System.Threading.Thread.Sleep(25);

            OwnShotHelpers.WindowCapture(ScreenPath);

            ShowBalloon(OwnShotHelpers.UploadImage(ScreenPath));

            if (OwnShotHelpers.GetConfig("DeleteMode") == "Yes")
            {
                File.Delete(ScreenPath);
            }
        }
Esempio n. 3
0
        private void image1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            selectionRectangle.MouseUp   -= image1_MouseLeftButtonUp;
            selectionRectangle.MouseMove -= image1_MouseMove;
            BackPanel.MouseUp            -= image1_MouseLeftButtonUp;
            BackPanel.MouseMove          -= image1_MouseMove;
            image.MouseUp   -= image1_MouseLeftButtonUp;
            image.MouseMove -= image1_MouseMove;

            if (selectionRectangle.Width > 0)
            {
                this.Hide();
                Rect      rect1  = new Rect(Canvas.GetLeft(selectionRectangle), Canvas.GetTop(selectionRectangle), selectionRectangle.Width, selectionRectangle.Height);
                Int32Rect rcFrom = new Int32Rect();
                rcFrom.X      = (int)((rect1.X) * (image.Source.Width) / (image.Width));
                rcFrom.Y      = (int)((rect1.Y) * (image.Source.Height) / (image.Height));
                rcFrom.Width  = (int)((rect1.Width) * (image.Source.Width) / (image.Width));
                rcFrom.Height = (int)((rect1.Height) * (image.Source.Height) / (image.Height));
                BitmapSource bs            = new CroppedBitmap(image.Source as BitmapSource, rcFrom);
                var          PreScreenPath = "";
                using (MemoryStream outStream = new MemoryStream())
                {
                    BitmapEncoder enc = new BmpBitmapEncoder();
                    enc.Frames.Add(BitmapFrame.Create(bs));
                    enc.Save(outStream);
                    PreScreenPath = ScreenPath;
                    ScreenPath    = ScreenPath.Replace("_pre", "");
                    new Bitmap(outStream).Save(ScreenPath, System.Drawing.Imaging.ImageFormat.Png);
                }

                ShowBalloon(OwnShotHelpers.UploadImage(ScreenPath));
                SetWindowStyle(true);
                selectionRectangle.Width = 0; //workaround

                if (OwnShotHelpers.GetConfig("DeleteMode") == "Yes")
                {
                    File.Delete(ScreenPath);
                    File.Delete(PreScreenPath);
                }
            }
            selectionRectangle.Visibility = Visibility.Visible;
        }
Esempio n. 4
0
        public void screenCapture(bool showCursor, bool Partial = false)
        {
            ScreenPath = OwnShotHelpers.RandomName(ssnamelength) + (Partial ? "_pre" : "") + ".png";

            SetWindowStyle(true);
            System.Threading.Thread.Sleep(25);

            OwnShotHelpers.CaptureImage(showCursor, ScreenPath);

            if (!Partial)
            {
                ShowBalloon(OwnShotHelpers.UploadImage(ScreenPath));
            }

            SetWindowStyle(!Partial);

            if (!Partial && OwnShotHelpers.GetConfig("DeleteMode") == "Yes")
            {
                File.Delete(ScreenPath);
            }
        }
Esempio n. 5
0
        public static void CaptureImage(bool showCursor, string FilePath)
        {
            int screenWidth  = Convert.ToInt32(System.Windows.SystemParameters.VirtualScreenWidth);
            int screenHeight = Convert.ToInt32(System.Windows.SystemParameters.VirtualScreenHeight);
            int screenLeft   = Convert.ToInt32(System.Windows.SystemParameters.VirtualScreenLeft);
            int screenTop    = Convert.ToInt32(System.Windows.SystemParameters.VirtualScreenTop);

            using (Bitmap bitmap = new Bitmap(screenWidth, screenHeight, PixelFormat.Format32bppArgb))
            {
                using (Graphics gr = Graphics.FromImage(bitmap))
                {
                    gr.CopyFromScreen(screenLeft, screenTop, 0, 0, bitmap.Size);
                    if (showCursor)
                    {
                        var cursorBounds = new Rectangle(Cursor.Position, Cursor.Current.Size);
                        Cursors.Default.Draw(gr, cursorBounds);
                    }
                    bitmap.Save(FilePath);
                }
            }

            if (OwnShotHelpers.GetConfig("OptimizeImage", "Yes") == "Yes" && File.Exists("optipng.exe"))
            {
                var proc = new System.Diagnostics.Process
                {
                    StartInfo = new System.Diagnostics.ProcessStartInfo
                    {
                        FileName               = "optipng.exe",
                        Arguments              = FilePath,
                        UseShellExecute        = false,
                        RedirectStandardOutput = false,
                        CreateNoWindow         = true
                    }
                };
                proc.Start();
                proc.WaitForExit();
            }
        }