mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Code quality changes
This commit is contained in:
parent
f07ed83722
commit
610f45d082
189 changed files with 4609 additions and 5203 deletions
|
@ -41,8 +41,9 @@ namespace Greenshot.Controls {
|
|||
CheckedChanged += BindableToolStripButton_CheckedChanged;
|
||||
}
|
||||
|
||||
private void BindableToolStripButton_CheckedChanged(object sender, EventArgs e) {
|
||||
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Checked"));
|
||||
private void BindableToolStripButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Checked"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,11 +41,9 @@ namespace Greenshot.Controls {
|
|||
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
if(PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem"));
|
||||
|
||||
}
|
||||
private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedItem"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace Greenshot.Controls {
|
|||
if(Tag == null || !Tag.Equals(clickedItem.Tag)) {
|
||||
Tag = clickedItem.Tag;
|
||||
Image = clickedItem.Image;
|
||||
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SelectedTag"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedTag"));
|
||||
}
|
||||
base.OnDropDownItemClicked(e);
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
Tag = tag;
|
||||
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SelectedTag"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedTag"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,14 +72,16 @@ namespace Greenshot.Controls {
|
|||
colorDialog.Color = SelectedColor;
|
||||
// Using the parent to make sure the dialog doesn't show on another window
|
||||
colorDialog.ShowDialog(Parent.Parent);
|
||||
if (colorDialog.DialogResult != DialogResult.Cancel) {
|
||||
if (!colorDialog.Color.Equals(SelectedColor)) {
|
||||
SelectedColor = colorDialog.Color;
|
||||
if(PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
}
|
||||
}
|
||||
if (colorDialog.DialogResult == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (colorDialog.Color.Equals(SelectedColor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectedColor = colorDialog.Color;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,18 +29,16 @@ namespace Greenshot.Controls {
|
|||
/// ToolStripProfessionalRenderer which draws the Check correctly when the icons are larger
|
||||
/// </summary>
|
||||
public class ContextMenuToolStripProfessionalRenderer : ToolStripProfessionalRenderer {
|
||||
private static readonly CoreConfiguration coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static Image scaledCheckbox;
|
||||
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static Image _scaledCheckbox;
|
||||
|
||||
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) {
|
||||
if (scaledCheckbox == null || scaledCheckbox.Size != coreConfiguration.IconSize) {
|
||||
if (scaledCheckbox != null) {
|
||||
scaledCheckbox.Dispose();
|
||||
}
|
||||
scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, coreConfiguration.IconSize.Width, coreConfiguration.IconSize.Height, null);
|
||||
if (_scaledCheckbox == null || _scaledCheckbox.Size != CoreConfig.IconSize) {
|
||||
_scaledCheckbox?.Dispose();
|
||||
_scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, CoreConfig.IconSize.Width, CoreConfig.IconSize.Height, null);
|
||||
}
|
||||
Rectangle old = e.ImageRectangle;
|
||||
ToolStripItemImageRenderEventArgs clone = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, scaledCheckbox, new Rectangle(old.X, 0, old.Width, old.Height));
|
||||
ToolStripItemImageRenderEventArgs clone = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, _scaledCheckbox, new Rectangle(old.X, 0, old.Width, old.Height));
|
||||
base.OnRenderItemCheck(clone);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,9 +84,7 @@ namespace Greenshot.Controls {
|
|||
if (_cursor != null) {
|
||||
_cursor.Dispose();
|
||||
}
|
||||
if (_movableShowColorForm != null) {
|
||||
_movableShowColorForm.Dispose();
|
||||
}
|
||||
_movableShowColorForm?.Dispose();
|
||||
}
|
||||
_movableShowColorForm = null;
|
||||
_cursor = null;
|
||||
|
@ -114,10 +112,7 @@ namespace Greenshot.Controls {
|
|||
{
|
||||
//Release Capture should consume MouseUp when canceled with the escape key
|
||||
User32.ReleaseCapture();
|
||||
if (PipetteUsed != null)
|
||||
{
|
||||
PipetteUsed(this, new PipetteUsedArgs(_movableShowColorForm.color));
|
||||
}
|
||||
PipetteUsed?.Invoke(this, new PipetteUsedArgs(_movableShowColorForm.color));
|
||||
}
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
|
|
@ -70,14 +70,16 @@ namespace Greenshot.Controls {
|
|||
colorDialog.Color = SelectedColor;
|
||||
// Using the parent to make sure the dialog doesn't show on another window
|
||||
colorDialog.ShowDialog(Parent.Parent);
|
||||
if (colorDialog.DialogResult != DialogResult.Cancel) {
|
||||
if (!colorDialog.Color.Equals(SelectedColor)) {
|
||||
SelectedColor = colorDialog.Color;
|
||||
if (PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
}
|
||||
}
|
||||
if (colorDialog.DialogResult == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (colorDialog.Color.Equals(SelectedColor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectedColor = colorDialog.Color;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,16 +34,13 @@ namespace Greenshot.Controls {
|
|||
{
|
||||
}
|
||||
|
||||
public NumericUpDown NumericUpDown
|
||||
{
|
||||
get {return Control as NumericUpDown;}
|
||||
}
|
||||
|
||||
public NumericUpDown NumericUpDown => Control as NumericUpDown;
|
||||
|
||||
public decimal Value
|
||||
{
|
||||
get { return NumericUpDown.Value; }
|
||||
set { NumericUpDown.Value = value;}
|
||||
}
|
||||
{
|
||||
get { return NumericUpDown.Value; }
|
||||
set { NumericUpDown.Value = value;}
|
||||
}
|
||||
public decimal Minimum {
|
||||
get { return NumericUpDown.Minimum; }
|
||||
set { NumericUpDown.Minimum = value; }
|
||||
|
@ -74,8 +71,9 @@ namespace Greenshot.Controls {
|
|||
NumericUpDown.ValueChanged -= _valueChanged;
|
||||
}
|
||||
|
||||
private void _valueChanged(object sender, EventArgs e) {
|
||||
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Value"));
|
||||
private void _valueChanged(object sender, EventArgs e)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue