Files
SuperVPN/output_3234/VideoReader/UCPictureBox.cs
2025-10-09 09:57:24 +09:00

343 lines
8.0 KiB
C#

using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace VideoReader;
public class UCPictureBox : UserControl
{
private Size size = new Size(1280, 720);
private Image image;
private float scale = 1f;
private Point PointImage = new Point(0, 0);
public RotateFlipType RotateFlip;
private int rotate;
private int flip;
private object block = new object();
private Point mousestart;
private bool Mousestart;
private IContainer components;
public int Rotate
{
get
{
return rotate;
}
set
{
rotate = value;
RoutFlip();
}
}
public int Flip
{
get
{
return flip;
}
set
{
flip = value;
RoutFlip();
}
}
public Image Image
{
get
{
return image;
}
set
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
Image val = image;
if (value != null)
{
image = (Image)new Bitmap(value);
}
if (val != null && value == null)
{
val.Dispose();
}
else if (val != null && value != null && ((object)image).GetHashCode() != ((object)value).GetHashCode())
{
val.Dispose();
}
}
}
public Size SizeImage
{
get
{
return size;
}
set
{
size = value;
}
}
public UCPictureBox()
{
InitializeComponent();
((Control)this).DoubleBuffered = true;
}
private void RoutFlip()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
RotateFlipType rotateFlip = (RotateFlipType)0;
if (rotate == 0 && flip == 1)
{
rotateFlip = (RotateFlipType)4;
}
else if (rotate == 0 && flip == 2)
{
rotateFlip = (RotateFlipType)6;
}
else if (rotate == 0 && flip == 3)
{
rotateFlip = (RotateFlipType)2;
}
else if (rotate == 90 && flip == 0)
{
rotateFlip = (RotateFlipType)1;
}
else if (rotate == 90 && flip == 1)
{
rotateFlip = (RotateFlipType)5;
}
else if (rotate == 90 && flip == 2)
{
rotateFlip = (RotateFlipType)7;
}
else if (rotate == 90 && flip == 3)
{
rotateFlip = (RotateFlipType)3;
}
else if (rotate == 180 && flip == 0)
{
rotateFlip = (RotateFlipType)2;
}
else if (rotate == 180 && flip == 1)
{
rotateFlip = (RotateFlipType)6;
}
else if (rotate == 180 && flip == 2)
{
rotateFlip = (RotateFlipType)4;
}
else if (rotate == 180 && flip == 3)
{
rotateFlip = (RotateFlipType)0;
}
else if (rotate == 270 && flip == 0)
{
rotateFlip = (RotateFlipType)3;
}
else if (rotate == 270 && flip == 1)
{
rotateFlip = (RotateFlipType)7;
}
else if (rotate == 270 && flip == 2)
{
rotateFlip = (RotateFlipType)5;
}
else if (rotate == 270 && flip == 3)
{
rotateFlip = (RotateFlipType)1;
}
RotateFlip = rotateFlip;
((Control)this).Refresh();
}
public Point rePoint(Point point)
{
Point result = default(Point);
if (Rotate == 0)
{
result.X = (int)((float)point.X * scale) + PointImage.X;
result.Y = (int)((float)point.Y * scale) + PointImage.Y;
}
else if (Rotate == 90)
{
result.X = (int)((float)point.Y * scale) + PointImage.Y;
result.Y = size.Height - ((int)((float)point.X * scale) + PointImage.X);
}
else if (Rotate == 180)
{
result.X = size.Width - ((int)((float)point.X * scale) + PointImage.X);
result.Y = size.Height - ((int)((float)point.Y * scale) + PointImage.Y);
}
else if (Rotate == 270)
{
result.X = size.Width - ((int)((float)point.Y * scale) + PointImage.Y);
result.Y = (int)((float)point.X * scale) + PointImage.X;
}
if (Flip == 1 || Flip == 3)
{
result.X = size.Width - result.X;
}
if (Flip == 2 || Flip == 3)
{
result.Y = size.Height - result.Y;
}
return result;
}
public void Zoom(bool zoom)
{
if (zoom)
{
scale += scale / 25f;
}
else
{
scale -= scale / 25f;
}
if (scale > 3f)
{
scale = 3f;
}
if ((double)scale < 0.1)
{
scale = 0.1f;
}
((Control)this).Refresh();
}
protected override void OnPaintBackground(PaintEventArgs e)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Invalid comparison between Unknown and I4
Rectangle rectangle = new Rectangle(PointImage.X, PointImage.Y, Convert.ToInt32((float)((Control)this).Width * scale), Convert.ToInt32((float)((Control)this).Height * scale));
lock (block)
{
if (image != null && (int)image.PixelFormat != 0)
{
Bitmap val = new Bitmap(image);
((Image)val).RotateFlip(RotateFlip);
e.Graphics.Clear(((Control)this).BackColor);
if ((int)RotateFlip == 0 || (int)RotateFlip == 2)
{
e.Graphics.DrawImage((Image)(object)val, new Rectangle(0, 0, ((Control)this).Width, ((Control)this).Height), rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, (GraphicsUnit)2);
}
else
{
e.Graphics.DrawImage((Image)(object)val, new Rectangle(0, 0, ((Control)this).Width, ((Control)this).Height), rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, (GraphicsUnit)2);
}
}
else
{
((ScrollableControl)this).OnPaintBackground(e);
}
}
}
protected override void OnMouseWheel(MouseEventArgs e)
{
if (e.Delta < 0)
{
Zoom(zoom: true);
}
else
{
Zoom(zoom: false);
}
}
protected override void OnMouseDown(MouseEventArgs e)
{
((UserControl)this).OnMouseDown(e);
Mousestart = true;
mousestart = e.Location;
}
protected override void OnMouseUp(MouseEventArgs e)
{
((Control)this).OnMouseUp(e);
Mousestart = false;
}
protected override void OnMouseMove(MouseEventArgs e)
{
((Control)this).OnMouseMove(e);
if (Mousestart)
{
PointImage.X += mousestart.X - e.X;
PointImage.Y += mousestart.Y - e.Y;
mousestart = e.Location;
if (PointImage.X < 0)
{
PointImage.X = 0;
}
if (PointImage.Y < 0)
{
PointImage.Y = 0;
}
((Control)this).Refresh();
}
}
protected override void OnMouseLeave(EventArgs e)
{
((Control)this).OnMouseLeave(e);
Mousestart = false;
}
protected override void Dispose(bool disposing)
{
if (disposing && components != null)
{
components.Dispose();
}
((ContainerControl)this).Dispose(disposing);
}
private void InitializeComponent()
{
((Control)this).SuspendLayout();
((ContainerControl)this).AutoScaleMode = (AutoScaleMode)0;
((Control)this).Name = "UCPictureBox";
((Control)this).ResumeLayout(false);
}
}