More warning fixes
This commit is contained in:
@@ -4,7 +4,13 @@
|
||||
{
|
||||
public string Name { get { return "Dummy"; } }
|
||||
|
||||
public ProxyCmdExecutorDummy(string config) { }
|
||||
public ProxyCmdExecutorDummy(string config)
|
||||
{
|
||||
if (config == null)
|
||||
{
|
||||
throw new System.ArgumentNullException(nameof(config));
|
||||
}
|
||||
}
|
||||
|
||||
public bool ExecuteCmd(string cmdString, IOutputHandler outputHandler)
|
||||
{
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace VAR.Toolbox.Code.ProxyCmdExecutors
|
||||
{
|
||||
public string Name { get { return "WMIC"; } }
|
||||
|
||||
private string _configWMIC;
|
||||
private readonly string _configWMIC;
|
||||
|
||||
public ProxyCmdExecutorWMIC(string configWMIC)
|
||||
{
|
||||
|
||||
@@ -52,8 +52,8 @@ namespace VAR.Toolbox.Code
|
||||
User32.GetWindowRect(handle, ref windowRect);
|
||||
int left = windowRect.left;
|
||||
int top = windowRect.top;
|
||||
int width = windowRect.right - windowRect.left;
|
||||
int height = windowRect.bottom - windowRect.top;
|
||||
int width = windowRect.right - left;
|
||||
int height = windowRect.bottom - top;
|
||||
// create a device context we can copy to
|
||||
IntPtr hdcDest = GDI32.CreateCompatibleDC(hdcSrc);
|
||||
// create a bitmap we can copy it to,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#pragma warning disable IDE0018
|
||||
#pragma warning disable IDE0059
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -15,17 +16,17 @@ namespace VAR.Toolbox.Code
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private IFilterGraph2 graph;
|
||||
private ICaptureGraphBuilder2 capture;
|
||||
private IMediaControl control;
|
||||
private IBaseFilter sourceFilter;
|
||||
private IBaseFilter samplegrabberfilter;
|
||||
private IBaseFilter nullrenderer;
|
||||
private readonly IFilterGraph2 graph;
|
||||
private readonly ICaptureGraphBuilder2 capture;
|
||||
private readonly IMediaControl control;
|
||||
private readonly IBaseFilter sourceFilter;
|
||||
private readonly IBaseFilter samplegrabberfilter;
|
||||
private readonly IBaseFilter nullrenderer;
|
||||
|
||||
private readonly Grabber grabber;
|
||||
|
||||
private int width = 0;
|
||||
private int height = 0;
|
||||
private readonly int width = 0;
|
||||
private readonly int height = 0;
|
||||
private readonly int bpp = 0;
|
||||
|
||||
private bool active = false;
|
||||
@@ -264,7 +265,7 @@ namespace VAR.Toolbox.Code
|
||||
|
||||
private class Grabber : ISampleGrabberCB
|
||||
{
|
||||
private Webcam _parent;
|
||||
private readonly Webcam _parent;
|
||||
|
||||
private readonly Bitmap[] _frames = null;
|
||||
private readonly int _numFrames = 10;
|
||||
|
||||
@@ -10,12 +10,6 @@ namespace VAR.Toolbox.Controls
|
||||
|
||||
private Image _imageShow = null;
|
||||
|
||||
// Image projection
|
||||
private double offsetX = 0;
|
||||
private double offsetY = 0;
|
||||
private double scaleX = 1.0f;
|
||||
private double scaleY = 1.0f;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
@@ -28,7 +22,7 @@ namespace VAR.Toolbox.Controls
|
||||
lock (this)
|
||||
{
|
||||
_imageShow = value;
|
||||
this.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -81,41 +75,37 @@ namespace VAR.Toolbox.Controls
|
||||
if (relation > 0)
|
||||
{
|
||||
// Imagen mas ancha que alta
|
||||
imgDrawHeight = (int)(this.Width / relation);
|
||||
if (imgDrawHeight > this.Height)
|
||||
imgDrawHeight = (int)(Width / relation);
|
||||
if (imgDrawHeight > Height)
|
||||
{
|
||||
imgDrawHeight = this.Height;
|
||||
imgDrawWidth = (int)(this.Height * relation);
|
||||
imgDrawX = ((this.Width - imgDrawWidth) / 2.0f);
|
||||
imgDrawHeight = Height;
|
||||
imgDrawWidth = (int)(Height * relation);
|
||||
imgDrawX = ((Width - imgDrawWidth) / 2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
imgDrawWidth = this.Width;
|
||||
imgDrawY = ((this.Height - imgDrawHeight) / 2.0f);
|
||||
imgDrawWidth = Width;
|
||||
imgDrawY = ((Height - imgDrawHeight) / 2.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Imagen mas alta que ancha
|
||||
imgDrawWidth = (int)(this.Width * relation);
|
||||
if (imgDrawWidth > this.Width)
|
||||
imgDrawWidth = (int)(Width * relation);
|
||||
if (imgDrawWidth > Width)
|
||||
{
|
||||
imgDrawWidth = this.Width;
|
||||
imgDrawHeight = (int)(this.Height / relation);
|
||||
imgDrawY = ((this.Height - imgDrawHeight) / 2.0f);
|
||||
imgDrawWidth = Width;
|
||||
imgDrawHeight = (int)(Height / relation);
|
||||
imgDrawY = ((Height - imgDrawHeight) / 2.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
imgDrawHeight = this.Height;
|
||||
imgDrawX = ((this.Width - imgDrawWidth) / 2.0f);
|
||||
imgDrawHeight = Height;
|
||||
imgDrawX = ((Width - imgDrawWidth) / 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
graph.DrawImage(_imageShow, imgDrawX, imgDrawY, imgDrawWidth, imgDrawHeight);
|
||||
offsetX = imgDrawX;
|
||||
offsetY = imgDrawY;
|
||||
scaleX = (double)imgDrawWidth / (double)_imageShow.Width;
|
||||
scaleY = (double)imgDrawHeight / (double)_imageShow.Height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,8 +41,8 @@ namespace VAR.Toolbox.Controls
|
||||
ForeColor = Color.Gray,
|
||||
SelectionMode = SelectionMode.MultiExtended,
|
||||
};
|
||||
_listBox.MouseDoubleClick += _listBox_MouseDoubleClick;
|
||||
_listBox.KeyDown += _listBox_KeyDown;
|
||||
_listBox.MouseDoubleClick += ListBox_MouseDoubleClick;
|
||||
_listBox.KeyDown += ListBox_KeyDown;
|
||||
Controls.Add(_listBox);
|
||||
|
||||
_timer = new Timer
|
||||
@@ -50,7 +50,7 @@ namespace VAR.Toolbox.Controls
|
||||
Interval = 100,
|
||||
Enabled = true
|
||||
};
|
||||
_timer.Tick += _timer_Tick;
|
||||
_timer.Tick += Timer_Tick;
|
||||
|
||||
Disposed += CtrOutput_Disposed;
|
||||
}
|
||||
@@ -71,7 +71,7 @@ namespace VAR.Toolbox.Controls
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
|
||||
private void _listBox_KeyDown(object sender, KeyEventArgs e)
|
||||
private void ListBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Control && e.KeyCode == Keys.C)
|
||||
{
|
||||
@@ -92,12 +92,12 @@ namespace VAR.Toolbox.Controls
|
||||
}
|
||||
}
|
||||
|
||||
private void _listBox_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
private void ListBox_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
DoubleClick?.Invoke(sender, e);
|
||||
}
|
||||
|
||||
private void _timer_Tick(object sender, EventArgs e)
|
||||
private void Timer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (_updated)
|
||||
{
|
||||
@@ -106,7 +106,7 @@ namespace VAR.Toolbox.Controls
|
||||
}
|
||||
|
||||
private bool _updated = false;
|
||||
private List<OutputItem> _pendingOutput = new List<OutputItem>();
|
||||
private readonly List<OutputItem> _pendingOutput = new List<OutputItem>();
|
||||
|
||||
private void UpdatePosition()
|
||||
{
|
||||
|
||||
@@ -33,10 +33,6 @@ namespace VAR.Toolbox.UI
|
||||
_currentInstance = this;
|
||||
}
|
||||
|
||||
private void InitializeCustomControls()
|
||||
{
|
||||
}
|
||||
|
||||
private void FrmToolbox_Load(object sender, EventArgs e)
|
||||
{
|
||||
Icon ico = Icon.ExtractAssociatedIcon(Application.ExecutablePath);
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace VAR.Toolbox.UI
|
||||
{
|
||||
#region Declarations
|
||||
|
||||
private Random rnd = new Random();
|
||||
private Timer _timer = new Timer();
|
||||
private readonly Random _rnd = new Random();
|
||||
private readonly Timer _timer = new Timer();
|
||||
|
||||
private readonly uint _mouseX = 0;
|
||||
private readonly uint _mouseY = 0;
|
||||
@@ -85,8 +85,8 @@ namespace VAR.Toolbox.UI
|
||||
try
|
||||
{
|
||||
Mouse.Move(
|
||||
(rnd.Next() % 11) - 5,
|
||||
(rnd.Next() % 11) - 5);
|
||||
(_rnd.Next() % 11) - 5,
|
||||
(_rnd.Next() % 11) - 5);
|
||||
}
|
||||
catch (Exception) { } // ignore exceptions moving mouse
|
||||
_timer.Stop();
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace VAR.Toolbox.UI
|
||||
public static string[] GetConfigurationLines()
|
||||
{
|
||||
string configFile = GetConfigFileName();
|
||||
string[] config = null;
|
||||
string[] config;
|
||||
if (File.Exists(configFile) == false)
|
||||
{
|
||||
config = new string[] { "Dummy|Dummy:" };
|
||||
|
||||
@@ -209,7 +209,7 @@ namespace VAR.Toolbox.UI
|
||||
}
|
||||
|
||||
|
||||
private static CookieContainer _cookieJar = new CookieContainer();
|
||||
private static readonly CookieContainer _cookieJar = new CookieContainer();
|
||||
|
||||
public static string CallApi(string urlService, string urlApiMethod, Dictionary<string, string> prms, string content)
|
||||
{
|
||||
|
||||
@@ -15,22 +15,16 @@ namespace VAR.Toolbox.UI
|
||||
{
|
||||
if (DesignMode) { return; }
|
||||
timTicker.Stop();
|
||||
bool userInactive = false;
|
||||
uint inactiveTime = Win32.GetLastInputTime();
|
||||
|
||||
lblInactive.Text = string.Format("Inactive by {0} seconds", inactiveTime);
|
||||
|
||||
if (chkAutoCover.Checked)
|
||||
{
|
||||
if (!userInactive && inactiveTime > numInactive.Value)
|
||||
if (inactiveTime > numInactive.Value)
|
||||
{
|
||||
userInactive = true;
|
||||
CoverScreen();
|
||||
}
|
||||
if (inactiveTime < 1)
|
||||
{
|
||||
userInactive = false;
|
||||
}
|
||||
}
|
||||
timTicker.Start();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace VAR.Toolbox.UI
|
||||
{
|
||||
public partial class PnlSuspension : UserControl, IToolPanel
|
||||
{
|
||||
private Random rnd = new Random();
|
||||
private readonly Random _rnd = new Random();
|
||||
|
||||
public PnlSuspension()
|
||||
{
|
||||
@@ -48,31 +48,13 @@ namespace VAR.Toolbox.UI
|
||||
0)
|
||||
.AddSeconds(Convert.ToInt32(numOffset.Value));
|
||||
|
||||
if (DateTime.Compare(now, dtSuspendAtCustom) > 0)
|
||||
{
|
||||
if (chkSuspendAtCustom.Checked)
|
||||
{
|
||||
chkSuspendAtCustom.Checked = false;
|
||||
RandomizeOffset();
|
||||
SuspendSystem();
|
||||
}
|
||||
else
|
||||
{
|
||||
chkSuspendAtCustom.Enabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetCountdown(dtSuspendAtCustom, now);
|
||||
chkSuspendAtCustom.Enabled = true;
|
||||
}
|
||||
CheckTime(chkSuspendAtCustom, dtSuspendAtCustom, now);
|
||||
}
|
||||
|
||||
timTicker.Stop();
|
||||
timTicker.Start();
|
||||
}
|
||||
|
||||
|
||||
private void DdlCustomHour_Load()
|
||||
{
|
||||
for (int i = 0; i < 24; i++)
|
||||
@@ -98,7 +80,7 @@ namespace VAR.Toolbox.UI
|
||||
|
||||
private void RandomizeOffset()
|
||||
{
|
||||
numOffset.Value = (rnd.Next() % 599) + 1;
|
||||
numOffset.Value = (_rnd.Next() % 599) + 1;
|
||||
}
|
||||
|
||||
private void ResetCountdown()
|
||||
@@ -112,11 +94,11 @@ namespace VAR.Toolbox.UI
|
||||
lblCountdown.Text = string.Format("{0:00}:{1:00}:{2:00}:{3:00}", timeSpan.Days, timeSpan.Hours, timeSpan.Minutes, timeSpan.Seconds);
|
||||
}
|
||||
|
||||
private void CheckTime(CheckBox checkBox, DateTime dtSuspension, DateTime now)
|
||||
private void CheckTime(CheckBox chkSuspendAtCustom, DateTime dtSuspendAtCustom, DateTime now)
|
||||
{
|
||||
if (DateTime.Compare(now, dtSuspension) > 0)
|
||||
if (DateTime.Compare(now, dtSuspendAtCustom) > 0)
|
||||
{
|
||||
if (checkBox.Checked)
|
||||
if (chkSuspendAtCustom.Checked)
|
||||
{
|
||||
chkSuspendAtCustom.Checked = false;
|
||||
RandomizeOffset();
|
||||
@@ -124,16 +106,13 @@ namespace VAR.Toolbox.UI
|
||||
}
|
||||
else
|
||||
{
|
||||
checkBox.Enabled = false;
|
||||
chkSuspendAtCustom.Enabled = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
checkBox.Enabled = true;
|
||||
}
|
||||
if (dtSuspension > now)
|
||||
{
|
||||
SetCountdown(dtSuspension, now);
|
||||
SetCountdown(dtSuspendAtCustom, now);
|
||||
chkSuspendAtCustom.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,6 +120,5 @@ namespace VAR.Toolbox.UI
|
||||
{
|
||||
Win32.SetSuspendState(false, true, false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user