Code quality fixes (NullReference checks, unused variables etc)

This commit is contained in:
RKrom 2014-04-26 00:34:06 +02:00
commit ac08533727
99 changed files with 1252 additions and 1312 deletions

View file

@ -37,7 +37,7 @@ namespace Greenshot.Controls {
}
public BindableToolStripButton() :base() {
this.CheckedChanged += new EventHandler(BindableToolStripButton_CheckedChanged);
CheckedChanged += BindableToolStripButton_CheckedChanged;
}
void BindableToolStripButton_CheckedChanged(object sender, EventArgs e) {

View file

@ -37,7 +37,7 @@ namespace Greenshot.Controls {
}
public BindableToolStripComboBox() :base() {
this.SelectedIndexChanged += new EventHandler(BindableToolStripComboBox_SelectedIndexChanged);
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
}
void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) {

View file

@ -40,7 +40,7 @@ namespace Greenshot.Controls {
}
public ColorButton() {
Click += new EventHandler(ColorButtonClick);
Click += ColorButtonClick;
}
public Color SelectedColor {
@ -71,7 +71,7 @@ namespace Greenshot.Controls {
ColorDialog colorDialog = ColorDialog.GetInstance();
colorDialog.Color = SelectedColor;
// Using the parent to make sure the dialog doesn't show on another window
colorDialog.ShowDialog(this.Parent.Parent);
colorDialog.ShowDialog(Parent.Parent);
if (colorDialog.DialogResult != DialogResult.Cancel) {
if (!colorDialog.Color.Equals(SelectedColor)) {
SelectedColor = colorDialog.Color;

View file

@ -44,7 +44,7 @@ namespace Greenshot.Controls {
{
ComboBox.DataSource = FontFamily.Families;
ComboBox.DisplayMember = "Name";
this.SelectedIndexChanged += new EventHandler(BindableToolStripComboBox_SelectedIndexChanged);
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
}
void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)

View file

@ -45,17 +45,17 @@ namespace Greenshot.Controls {
/// </remarks>
public bool ClickThrough {
get {
return this.clickThrough;
return clickThrough;
}
set {
this.clickThrough = value;
clickThrough = value;
}
}
protected override void WndProc(ref Message m) {
base.WndProc(ref m);
if (this.clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) {
if (clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) {
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
}
}

View file

@ -22,12 +22,16 @@
/// <summary>
/// See: http://nickstips.wordpress.com/2010/03/03/c-panel-resets-scroll-position-after-focus-is-lost-and-regained/
/// </summary>
using System.Drawing;
using System.Windows.Forms;
namespace GreenshotPlugin.Controls {
public class NonJumpingPanel : System.Windows.Forms.Panel {
protected override System.Drawing.Point ScrollToControl(System.Windows.Forms.Control activeControl) {
public class NonJumpingPanel : Panel {
protected override Point ScrollToControl(Control activeControl) {
// Returning the current location prevents the panel from
// scrolling to the active control when the panel loses and regains focus
return this.DisplayRectangle.Location;
return DisplayRectangle.Location;
}
}
}

View file

@ -19,6 +19,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Forms;
@ -41,7 +42,7 @@ namespace Greenshot.Controls {
public Pipette() {
BorderStyle = BorderStyle.FixedSingle;
dragging = false;
_image = (Bitmap)new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog)).GetObject("pipette.Image");
_image = (Bitmap)new ComponentResourceManager(typeof(ColorDialog)).GetObject("pipette.Image");
Image = _image;
_cursor = CreateCursor((Bitmap)_image, 1, 14);
movableShowColorForm = new MovableShowColorForm();
@ -99,7 +100,7 @@ namespace Greenshot.Controls {
/// <param name="e">MouseEventArgs</param>
protected override void OnMouseDown(MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
User32.SetCapture(this.Handle);
User32.SetCapture(Handle);
movableShowColorForm.MoveTo(PointToScreen(new Point(e.X, e.Y)));
}
base.OnMouseDown(e);
@ -136,7 +137,7 @@ namespace Greenshot.Controls {
/// </summary>
/// <param name="e"></param>
protected override void OnMouseCaptureChanged(EventArgs e) {
if (this.Capture) {
if (Capture) {
dragging = true;
Image = null;
Cursor c = _cursor;

View file

@ -38,7 +38,7 @@ namespace Greenshot.Controls {
private Color selectedColor = Color.Transparent;
public ToolStripColorButton() {
Click+= new EventHandler(ColorButtonClick);
Click+= ColorButtonClick;
}
public Color SelectedColor {
@ -69,7 +69,7 @@ namespace Greenshot.Controls {
ColorDialog colorDialog = ColorDialog.GetInstance();
colorDialog.Color = SelectedColor;
// Using the parent to make sure the dialog doesn't show on another window
colorDialog.ShowDialog(this.Parent.Parent);
colorDialog.ShowDialog(Parent.Parent);
if (colorDialog.DialogResult != DialogResult.Cancel) {
if (!colorDialog.Color.Equals(SelectedColor)) {
SelectedColor = colorDialog.Color;

View file

@ -46,17 +46,17 @@ namespace Greenshot.Controls {
public bool ClickThrough {
get {
return this.clickThrough;
return clickThrough;
}
set {
this.clickThrough = value;
clickThrough = value;
}
}
protected override void WndProc(ref Message m) {
base.WndProc(ref m);
if (this.clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) {
if (clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) {
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
}
}