Exemple #1
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (SpecificWindowMode)
            {
                this.Size = BackgroundImage.Size;
                mhook     = new MouseListener();

                mhook.Click += (sender, loc) => {
                    if (loc.X > Location.X && loc.X < Location.X + Size.Width && loc.Y > Location.Y && loc.Y < Location.Y + Size.Height)
                    {
                        return;
                    }
                    DialogResult = DialogResult.Abort;
                    SystemSounds.Beep.Play();

                    this.Close();
                    mhook.Stop();
                };
                mhook.Start();



                return;
            }
            //full screen mode:
            MultiScreenSize m_MultiScreenSize = FindMultiScreenSize();

            this.Size = new Size(m_MultiScreenSize.maxRight - m_MultiScreenSize.minX, m_MultiScreenSize.maxBottom - m_MultiScreenSize.minY);

            Graph.CopyFromScreen(m_MultiScreenSize.minX, m_MultiScreenSize.minY, 0, 0, BitmapSize);
        }
Exemple #2
0
        /// <summary>
        /// Takes screenshot of the screen (supports multiple monitors) and then lets user to select the wanted area and returns that area.
        /// Also returns the rectangle of the selected part inside of the window.
        /// </summary>
        public static Image Snip(out Rectangle rect, PixelFormat format = PixelFormat.Format24bppRgb)
        {
            MultiScreenSize m_MultiScreenSize = FindMultiScreenSize();
            var             bmp = new Bitmap(m_MultiScreenSize.maxRight - m_MultiScreenSize.minX, m_MultiScreenSize.maxBottom - m_MultiScreenSize.minY, format);

            Graph = Graphics.FromImage(bmp);
            Graph.SmoothingMode = SmoothingMode.None;
            BitmapSize          = bmp.Size;
            using (var snipper = new SnippingTool(bmp)) {
                snipper.Location = new Point(m_MultiScreenSize.minX, m_MultiScreenSize.minY);

                if (snipper.ShowDialog() == DialogResult.OK)
                {
                    rect = snipper.rcSelect;
                    return(snipper.Image);
                }
            }

            rect = Rectangle.Empty;
            return(null);
        }
Exemple #3
0
        public static MultiScreenSize FindMultiScreenSize()
        {
            // Setup the start values based off initial monitor
            int minX = Screen.AllScreens[0].Bounds.X;
            int minY = Screen.AllScreens[0].Bounds.Y;

            int maxRight = Screen.AllScreens[0].Bounds.Right;
            int maxBottom = Screen.AllScreens[0].Bounds.Bottom;

            // Loop through all monitors to find true max-min
            foreach (Screen s in Screen.AllScreens)
            {

                // Find lower X
                if (s.Bounds.X < minX)
                {
                    minX = s.Bounds.X;
                }

                // Find lower Y
                if (s.Bounds.Y < minY)
                {
                    minY = s.Bounds.Y;
                }

                // Find higher Right
                if (s.Bounds.Right > maxRight)
                {
                    maxRight = s.Bounds.Right;
                }

                // Find higher Bottom
                if (s.Bounds.Bottom > maxBottom)
                {
                    maxBottom = s.Bounds.Bottom;
                }

            }

            MultiScreenSize totalScreens = new MultiScreenSize();
            totalScreens.minX = minX;
            totalScreens.minY = minY;
            totalScreens.maxRight = maxRight;
            totalScreens.maxBottom = maxBottom;

            return totalScreens;
        }