Remove duplicated CtrImageViewer

This commit is contained in:
2022-04-09 02:53:12 +02:00
parent ef30383abb
commit 44d6531bda
3 changed files with 2 additions and 126 deletions

View File

@@ -1,121 +0,0 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace VAR.ScreenAutomation.Controls
{
public class CtrImageViewer : PictureBox
{
#region Declarations
private Image _imageShow;
#endregion
#region Properties
public Image ImageShow
{
// ReSharper disable once InconsistentlySynchronizedField
get => _imageShow;
set
{
lock (this)
{
_imageShow = value;
Invalidate();
}
}
}
#endregion
#region Control life cycle
public CtrImageViewer()
{
InitializeComponent();
}
private void InitializeComponent()
{
BackColor = Color.Black;
}
protected override void OnPaint(PaintEventArgs pe)
{
base.OnPaint(pe);
Redraw(pe.Graphics);
}
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
//Redraw(null);
this.Invalidate();
}
#endregion
#region Private methods
private void Redraw(Graphics graph)
{
if (_imageShow == null)
{
return;
}
lock (_imageShow)
{
if (graph == null)
{
graph = this.CreateGraphics();
}
// Calcular dimensiones a dibujar y centrar
int imgDrawWidth;
int imgDrawHeight;
float imgDrawX = 0;
float imgDrawY = 0;
float relation = _imageShow.Width / (float)_imageShow.Height;
if (relation > 0)
{
// Imagen mas ancha que alta
imgDrawHeight = (int)(Width / relation);
if (imgDrawHeight > Height)
{
imgDrawHeight = Height;
imgDrawWidth = (int)(Height * relation);
imgDrawX = ((Width - imgDrawWidth) / 2.0f);
}
else
{
imgDrawWidth = Width;
imgDrawY = ((Height - imgDrawHeight) / 2.0f);
}
}
else
{
// Imagen mas alta que ancha
imgDrawWidth = (int)(Width * relation);
if (imgDrawWidth > Width)
{
imgDrawWidth = Width;
imgDrawHeight = (int)(Height / relation);
imgDrawY = ((Height - imgDrawHeight) / 2.0f);
}
else
{
imgDrawHeight = Height;
imgDrawX = ((Width - imgDrawWidth) / 2.0f);
}
}
graph.DrawImage(_imageShow, imgDrawX, imgDrawY, imgDrawWidth, imgDrawHeight);
}
}
#endregion
}
}

View File

@@ -36,7 +36,7 @@
this.ddlAutomationBot = new System.Windows.Forms.ComboBox();
this.btnStartEnd = new System.Windows.Forms.Button();
this.chkKeepToplevel = new System.Windows.Forms.CheckBox();
this.picPreview = new VAR.ScreenAutomation.Controls.CtrImageViewer();
this.picPreview = new VAR.Toolbox.Controls.CtrImageViewer();
this.ctrOutput = new VAR.Toolbox.Controls.CtrOutput();
this.chkClick = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.picCapturer)).BeginInit();
@@ -251,7 +251,7 @@
#endregion
private System.Windows.Forms.PictureBox picCapturer;
private Controls.CtrImageViewer picPreview;
private VAR.Toolbox.Controls.CtrImageViewer picPreview;
private VAR.Toolbox.Controls.CtrOutput ctrOutput;
private System.Windows.Forms.SplitContainer splitMain;
private System.Windows.Forms.SplitContainer splitOutput;

View File

@@ -254,9 +254,6 @@
<DependentUpon>FrmWebcam.cs</DependentUpon>
</Compile>
<Compile Include="UI\IToolForm.cs" />
<Compile Include="UI\Tools\ScreenAutomation\CtrImageViewer.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UI\Tools\ScreenAutomation\FrmAutomationBotParams.cs">
<SubType>Form</SubType>
</Compile>