⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 capturehelper.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Pc.Controls
{
    using System;
    using System.Drawing;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;

    public class CaptureHelper
    {
        public static Image CapturedImage;

        public static void AbsNormalizeRect(ref Rectangle rect)
        {
            NormalizeRect(ref rect);
            if (rect.X < 0)
            {
                rect.Width -= Math.Abs(rect.X);
                rect.X = 0;
            }
            if (rect.Y < 0)
            {
                rect.Height -= Math.Abs(rect.Y);
                rect.Y = 0;
            }
            if (rect.Right > Screen.PrimaryScreen.Bounds.Right)
            {
                rect.Width = Screen.PrimaryScreen.Bounds.Right - rect.Left;
            }
            if (rect.Bottom > Screen.PrimaryScreen.Bounds.Bottom)
            {
                rect.Height = Screen.PrimaryScreen.Bounds.Bottom - rect.Top;
            }
        }

        public static void AbsNormalizeRect(ref int x, ref int y, ref int width, ref int height)
        {
            NormalizeRect(ref x, ref y, ref width, ref height);
            if (x < 0)
            {
                width -= Math.Abs(x);
                x = 0;
            }
            if (y < 0)
            {
                height -= Math.Abs(y);
                y = 0;
            }
            if ((x + width) > Screen.PrimaryScreen.Bounds.Right)
            {
                width = Screen.PrimaryScreen.Bounds.Right - x;
            }
            if ((y + height) > Screen.PrimaryScreen.Bounds.Bottom)
            {
                height = Screen.PrimaryScreen.Bounds.Bottom - y;
            }
        }

        public static bool CaptureImage()
        {
            InitializeVariable();
            using (CaptureForm form = new CaptureForm())
            {
                return (form.ShowDialog() == DialogResult.OK);
            }
        }

        private static void InitializeVariable()
        {
            CapturedImage = null;
        }

        public static void NormalizeRect(ref Rectangle rect)
        {
            Rectangle rectangle = rect;
            if (rect.Width < 0)
            {
                rect.X = rectangle.Right;
                rect.Width = -rectangle.Width;
            }
            if (rect.Height < 0)
            {
                rect.Y = rectangle.Bottom;
                rect.Height = -rectangle.Height;
            }
        }

        public static void NormalizeRect(ref int x, ref int y, ref int width, ref int height)
        {
            Rectangle rect = new Rectangle(x, y, width, height);
            NormalizeRect(ref rect);
            x = rect.X;
            y = rect.Y;
            width = rect.Width;
            height = rect.Height;
        }

        [DllImport("user32.dll")]
        public static extern bool UpdateWindow(IntPtr hwnd);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -