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

📄 captureform.cs

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

    public class CaptureForm : Form
    {
        private byte alpha = 100;
        private Bitmap blendedImage;
        private byte blueColor = 50;
        private IContainer components;
        private byte greenColor = 50;
        private Bitmap originalImage;
        private byte redColor = 50;
        public RectTracker RT;

        public CaptureForm()
        {
            this.InitializeComponent();
            this.InitializeCapture();
            this.CaptureFullScreenImage();
            this.SetFullScreen();
        }

        private void AlphaBlendImage(Bitmap toBlendImage)
        {
            using (Graphics graphics = Graphics.FromImage(toBlendImage))
            {
                using (SolidBrush brush = new SolidBrush(Color.FromArgb(this.alpha, this.redColor, this.greenColor, this.blueColor)))
                {
                    graphics.FillRectangle(brush, new Rectangle(0, 0, toBlendImage.Width, toBlendImage.Height));
                }
            }
        }

        private void CaptureForm_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == '\x001b')
            {
                if (this.RT.SelectStatus == SelectStatus.Selected)
                {
                    using (Graphics graphics = Graphics.FromHwnd(base.Handle))
                    {
                        graphics.DrawImage(this.blendedImage, this.RT.InvalidatedRect, this.RT.InvalidatedRect, GraphicsUnit.Pixel);
                    }
                    this.RT.InitilizeTracker();
                }
                else if (this.RT.SelectStatus == SelectStatus.Empty)
                {
                    base.DialogResult = DialogResult.Cancel;
                }
            }
            if ((e.KeyChar == '\r') && !this.RT.TrueRect.IsEmpty)
            {
                this.CaptureRectangledImage();
                base.DialogResult = DialogResult.OK;
            }
        }

        private void CaptureForm_Load(object sender, EventArgs e)
        {
            base.Activate();
        }

        private void CaptureForm_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                if (this.RT.SelectStatus == SelectStatus.Selected)
                {
                    using (Graphics graphics = Graphics.FromHwnd(base.Handle))
                    {
                        graphics.DrawImage(this.blendedImage, this.RT.InvalidatedRect, this.RT.InvalidatedRect, GraphicsUnit.Pixel);
                    }
                    this.RT.InitilizeTracker();
                }
                else if (this.RT.SelectStatus == SelectStatus.Empty)
                {
                    base.DialogResult = DialogResult.Cancel;
                }
            }
        }

        private void CaptureForm_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if ((e.Button == MouseButtons.Left) && !this.RT.SelectionIsEmpty())
            {
                this.CaptureRectangledImage();
                base.DialogResult = DialogResult.OK;
            }
        }

        private void CaptureForm_Paint(object sender, PaintEventArgs e)
        {
            e.Graphics.DrawImage(this.blendedImage, 0, 0);
        }

        private void CaptureFullScreenImage()
        {
            using (Graphics graphics = Graphics.FromImage(this.originalImage))
            {
                graphics.CopyFromScreen(new Point(0, 0), new Point(0, 0), Screen.PrimaryScreen.Bounds.Size);
                this.blendedImage = (Bitmap) this.originalImage.Clone();
                this.AlphaBlendImage(this.blendedImage);
            }
        }

        public void CaptureRectangledImage()
        {
            Rectangle rect = new Rectangle(this.RT.TrueRect.Location, this.RT.TrueRect.Size);
            CaptureHelper.AbsNormalizeRect(ref rect);
            CaptureHelper.CapturedImage = new Bitmap(rect.Width, rect.Height);
            using (Graphics graphics = Graphics.FromImage(CaptureHelper.CapturedImage))
            {
                graphics.DrawImage(this.originalImage, new Rectangle(0, 0, CaptureHelper.CapturedImage.Width, CaptureHelper.CapturedImage.Height), rect, GraphicsUnit.Pixel);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void DrawBlendedBufferImage(Rectangle bufferImageRect, Graphics g)
        {
            g.DrawImage(this.blendedImage, new Rectangle(0, 0, bufferImageRect.Width, bufferImageRect.Height), bufferImageRect, GraphicsUnit.Pixel);
        }

        private void DrawBlendedIedmage(Rectangle blendedRect, Graphics g)
        {
            g.DrawImage(this.blendedImage, blendedRect, blendedRect, GraphicsUnit.Pixel);
        }

        private void DrawImageToForm(Rectangle originalRect, Image bufferImage)
        {
            using (Graphics graphics = Graphics.FromHwnd(base.Handle))
            {
                graphics.DrawImage(bufferImage, originalRect, new Rectangle(0, 0, originalRect.Width, originalRect.Height), GraphicsUnit.Pixel);
            }
        }

        private void DrawOriginalBufferImage(Rectangle bufferImageRect, Point offsetPoint, Graphics g)
        {
            Rectangle destRect = new Rectangle(offsetPoint, bufferImageRect.Size);
            g.DrawImage(this.originalImage, destRect, bufferImageRect, GraphicsUnit.Pixel);
        }

        private void DrawOriginalImage(Rectangle originalRect, Graphics g)
        {
            if (g != null)
            {
                g.DrawImage(this.originalImage, originalRect, originalRect, GraphicsUnit.Pixel);
            }
            else
            {
                using (Graphics graphics = Graphics.FromHwnd(base.Handle))
                {
                    graphics.DrawImage(this.originalImage, originalRect, originalRect, GraphicsUnit.Pixel);
                }
            }
        }

        private void InitializeCapture()
        {
            base.SetStyle(0x22010, true);
            this.originalImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            this.RT = new RectTracker(this);
            this.RT.dlgtDrawOriginalImage = new RectTracker.DlgtDrawOriginalImage(this.DrawOriginalImage);
            this.RT.dlgtDrawBlendedBufferImage = new RectTracker.DlgtDrawBlendedBufferImage(this.DrawBlendedBufferImage);
            this.RT.dlgtDrawOriginalBufferImage = new RectTracker.DlgtDrawOriginalBufferImage(this.DrawOriginalBufferImage);
            this.RT.dlgtDrawImageToForm = new RectTracker.DlgtDrawImageToForm(this.DrawImageToForm);
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.set_AutoScaleDimensions(new SizeF(6f, 12f));
            base.set_AutoScaleMode(1);
            this.set_BackgroundImageLayout(0);
            base.ClientSize = new Size(0xf2, 0xdb);
            base.ControlBox = false;
            base.FormBorderStyle = FormBorderStyle.None;
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "CaptureForm";
            base.set_ShowIcon(false);
            base.ShowInTaskbar = false;
            base.StartPosition = FormStartPosition.Manual;
            this.Text = "CaptureForm";
            base.TopMost = true;
            base.add_MouseDoubleClick(new MouseEventHandler(this.CaptureForm_MouseDoubleClick));
            base.Paint += new PaintEventHandler(this.CaptureForm_Paint);
            base.add_MouseClick(new MouseEventHandler(this.CaptureForm_MouseClick));
            base.KeyPress += new KeyPressEventHandler(this.CaptureForm_KeyPress);
            base.Load += new EventHandler(this.CaptureForm_Load);
            base.ResumeLayout(false);
        }

        protected override void OnPaintBackground(PaintEventArgs e)
        {
        }

        private void SetFullScreen()
        {
            base.SetBounds(0, 0, Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
        }
    }
}

⌨️ 快捷键说明

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