mirror of
https://github.com/farcasclaudiu/SmartThreadPool.git
synced 2026-06-22 09:01:19 +03:00
Added refactorings suggested by Simon Cropp
This commit is contained in:
@@ -1,11 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
//
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
//
|
||||
[assembly: AssemblyTitle("")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
@@ -14,45 +8,7 @@ using System.Runtime.CompilerServices;
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
//
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Revision and Build Numbers
|
||||
// by using the '*' as shown below:
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
//
|
||||
// In order to sign your assembly you must specify a key to use. Refer to the
|
||||
// Microsoft .NET Framework documentation for more information on assembly signing.
|
||||
//
|
||||
// Use the attributes below to control which key is used for signing.
|
||||
//
|
||||
// Notes:
|
||||
// (*) If no key is specified, the assembly is not signed.
|
||||
// (*) KeyName refers to a key that has been installed in the Crypto Service
|
||||
// Provider (CSP) on your machine. KeyFile refers to a file which contains
|
||||
// a key.
|
||||
// (*) If the KeyFile and the KeyName values are both specified, the
|
||||
// following processing occurs:
|
||||
// (1) If the KeyName can be found in the CSP, that key is used.
|
||||
// (2) If the KeyName does not exist and the KeyFile does exist, the key
|
||||
// in the KeyFile is installed into the CSP and used.
|
||||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
|
||||
// When specifying the KeyFile, the location of the KeyFile should be
|
||||
// relative to the project output directory which is
|
||||
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
|
||||
// located in the project directory, you would specify the AssemblyKeyFile
|
||||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
|
||||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
|
||||
// documentation for more information on this.
|
||||
//
|
||||
[assembly: AssemblyDelaySign(false)]
|
||||
[assembly: AssemblyKeyFile("")]
|
||||
[assembly: AssemblyKeyName("")]
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
using System.Drawing.Imaging;
|
||||
|
||||
|
||||
namespace UsageControl
|
||||
@@ -40,9 +34,8 @@ namespace UsageControl
|
||||
{
|
||||
//Debug.WriteLine("GenerateItemImage");
|
||||
|
||||
Bitmap itemImage = null;
|
||||
Rectangle rc = new Rectangle(0, 0, width, height);
|
||||
itemImage = new Bitmap(rc.Width, rc.Height);
|
||||
Bitmap itemImage = new Bitmap(rc.Width, rc.Height);
|
||||
|
||||
/// Create button
|
||||
rc.Inflate(-3, -3);
|
||||
@@ -90,11 +83,11 @@ namespace UsageControl
|
||||
{
|
||||
//Debug.WriteLine("GetItemsImage");
|
||||
|
||||
Bitmap itemImage = null;
|
||||
Bitmap itemImage;
|
||||
|
||||
if (!_imagesCache.ContainsKey(color))
|
||||
{
|
||||
Rectangle rc = new Rectangle(0, 0, this.Width, _itemHeight);
|
||||
Rectangle rc = new Rectangle(0, 0, Width, _itemHeight);
|
||||
itemImage = new Bitmap(rc.Width, rc.Height);
|
||||
|
||||
/// Create button
|
||||
@@ -120,7 +113,7 @@ namespace UsageControl
|
||||
GraphicsPath path3 = GetPath(rc3, rc3.Height);
|
||||
LinearGradientBrush br3 = new LinearGradientBrush(rc3, Color.FromArgb(255, Color.White), Color.FromArgb(0, Color.White), LinearGradientMode.Vertical);
|
||||
|
||||
itemImage = new Bitmap(this.Width - 2, _itemHeight);
|
||||
itemImage = new Bitmap(Width - 2, _itemHeight);
|
||||
Graphics g = Graphics.FromImage(itemImage);
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
g.FillPath(br2, path2);
|
||||
@@ -140,12 +133,12 @@ namespace UsageControl
|
||||
//Debug.WriteLine("EnableDoubleBuffering");
|
||||
|
||||
// Set the value of the double-buffering style bits to true.
|
||||
this.SetStyle(ControlStyles.DoubleBuffer |
|
||||
SetStyle(ControlStyles.DoubleBuffer |
|
||||
ControlStyles.UserPaint |
|
||||
ControlStyles.AllPaintingInWmPaint |
|
||||
ControlStyles.SupportsTransparentBackColor,
|
||||
true);
|
||||
this.UpdateStyles();
|
||||
UpdateStyles();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
@@ -245,7 +238,7 @@ namespace UsageControl
|
||||
text = "(" + (_queuedItems.Count - _maxItemsVisible) + ")...";
|
||||
}
|
||||
|
||||
SizeF size = g.MeasureString(entry.Text, this.Font);
|
||||
SizeF size = g.MeasureString(entry.Text, Font);
|
||||
//Debug.WriteLine(size.Width);
|
||||
|
||||
Bitmap itemImage = GetItemsImage(entry.Color);
|
||||
@@ -256,7 +249,7 @@ namespace UsageControl
|
||||
g.DrawImage(itemImage, -1, slot.Top-2);
|
||||
|
||||
//g.DrawString(text, this.Font, Brushes.Black, new RectangleF((this.Width - size.Width) / 2, top + 2, this.Width, bottom));
|
||||
g.DrawString(text, this.Font, Brushes.Black, slot);
|
||||
g.DrawString(text, Font, Brushes.Black, slot);
|
||||
++i;
|
||||
}
|
||||
|
||||
@@ -282,15 +275,15 @@ namespace UsageControl
|
||||
private void ControlRezised()
|
||||
{
|
||||
//Debug.WriteLine("ControlRezised");
|
||||
Graphics g = Graphics.FromHwnd(this.Handle);
|
||||
SizeF size = g.MeasureString("X", this.Font);
|
||||
Graphics g = Graphics.FromHwnd(Handle);
|
||||
SizeF size = g.MeasureString("X", Font);
|
||||
g.Dispose();
|
||||
_itemHeight = (int)size.Height + 5;
|
||||
_maxItemsVisible = this.Height / _itemHeight - 1;
|
||||
_maxItemsVisible = Height / _itemHeight - 1;
|
||||
_lastVisibleItemIndex = _maxItemsVisible;
|
||||
_imagesCache = new Dictionary<Color, Bitmap>();
|
||||
|
||||
Rectangle border = new Rectangle(0, 0, this.ClientRectangle.Width - 1, this.ClientRectangle.Height - 1);
|
||||
Rectangle border = new Rectangle(0, 0, ClientRectangle.Width - 1, ClientRectangle.Height - 1);
|
||||
_pathBorder = GetPath(border, 20);
|
||||
|
||||
PrepareSlots();
|
||||
@@ -303,8 +296,8 @@ namespace UsageControl
|
||||
_slots = new RectangleF[_maxItemsVisible+5];
|
||||
for (int i = 0; i < _slots.Length; i++)
|
||||
{
|
||||
int top = 0;
|
||||
int bottom = 0;
|
||||
int top;
|
||||
int bottom;
|
||||
if (topdown)
|
||||
{
|
||||
bottom = 1;
|
||||
@@ -314,13 +307,13 @@ namespace UsageControl
|
||||
}
|
||||
else
|
||||
{
|
||||
bottom = this.Height - 1;
|
||||
bottom = Height - 1;
|
||||
top = bottom;
|
||||
bottom -= i * _itemHeight;
|
||||
top -= (i + 1) * _itemHeight;
|
||||
}
|
||||
|
||||
_slots[i] = new RectangleF((this.Width - 55) / 2, top + 2, this.Width, bottom);
|
||||
_slots[i] = new RectangleF((Width - 55) / 2, top + 2, Width, bottom);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Drawing;
|
||||
|
||||
namespace UsageControl
|
||||
@@ -9,10 +6,6 @@ namespace UsageControl
|
||||
{
|
||||
public class QueueUsageEntry
|
||||
{
|
||||
private string _text;
|
||||
private Color _color;
|
||||
private bool _isExecuting;
|
||||
|
||||
public QueueUsageEntry(
|
||||
string text,
|
||||
Color color) : this (text, color, false)
|
||||
@@ -24,26 +17,16 @@ namespace UsageControl
|
||||
Color color,
|
||||
bool blink)
|
||||
{
|
||||
_text = text;
|
||||
_color = color;
|
||||
_isExecuting = blink;
|
||||
Text = text;
|
||||
Color = color;
|
||||
IsExecuting = blink;
|
||||
}
|
||||
|
||||
public Color Color
|
||||
{
|
||||
get { return _color; }
|
||||
}
|
||||
public Color Color { get; private set; }
|
||||
|
||||
public string Text
|
||||
{
|
||||
get { return _text; }
|
||||
}
|
||||
public string Text { get; private set; }
|
||||
|
||||
public bool IsExecuting
|
||||
{
|
||||
get { return _isExecuting; }
|
||||
set { _isExecuting = value; }
|
||||
}
|
||||
public bool IsExecuting { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace UsageControl
|
||||
@@ -10,12 +8,12 @@ namespace UsageControl
|
||||
/// <summary>
|
||||
/// Summary description for UsageHistoryControl.
|
||||
/// </summary>
|
||||
public class UsageHistoryControl : System.Windows.Forms.UserControl
|
||||
public class UsageHistoryControl : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.Container components = null;
|
||||
private Container components = null;
|
||||
|
||||
private const int squareWidth = 12;
|
||||
private const int maxLastValuesCount = 2000;
|
||||
@@ -83,17 +81,17 @@ namespace UsageControl
|
||||
private void EnableDoubleBuffering()
|
||||
{
|
||||
// Set the value of the double-buffering style bits to true.
|
||||
this.SetStyle(ControlStyles.DoubleBuffer |
|
||||
SetStyle(ControlStyles.DoubleBuffer |
|
||||
ControlStyles.UserPaint |
|
||||
ControlStyles.AllPaintingInWmPaint,
|
||||
true);
|
||||
this.UpdateStyles();
|
||||
UpdateStyles();
|
||||
}
|
||||
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
// Invalidate the control to get a repaint.
|
||||
this.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
@@ -183,7 +181,7 @@ namespace UsageControl
|
||||
max = value;
|
||||
|
||||
// Invalidate the control to get a repaint.
|
||||
this.Invalidate();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user