diff --git a/Greenshot/Controls/BindableToolStripButton.cs b/Greenshot/Controls/BindableToolStripButton.cs index 29387610c..52dfcd3e8 100644 --- a/Greenshot/Controls/BindableToolStripButton.cs +++ b/Greenshot/Controls/BindableToolStripButton.cs @@ -41,7 +41,7 @@ namespace Greenshot.Controls { CheckedChanged += BindableToolStripButton_CheckedChanged; } - void BindableToolStripButton_CheckedChanged(object sender, EventArgs e) { + private void BindableToolStripButton_CheckedChanged(object sender, EventArgs e) { if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Checked")); } } diff --git a/Greenshot/Controls/BindableToolStripComboBox.cs b/Greenshot/Controls/BindableToolStripComboBox.cs index 639bb9637..14560ca12 100644 --- a/Greenshot/Controls/BindableToolStripComboBox.cs +++ b/Greenshot/Controls/BindableToolStripComboBox.cs @@ -41,7 +41,7 @@ namespace Greenshot.Controls { SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged; } - void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { + private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { if(PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem")); diff --git a/Greenshot/Controls/ColorButton.cs b/Greenshot/Controls/ColorButton.cs index 92f4c7d8b..50546a3d8 100644 --- a/Greenshot/Controls/ColorButton.cs +++ b/Greenshot/Controls/ColorButton.cs @@ -67,7 +67,7 @@ namespace Greenshot.Controls { } } - void ColorButtonClick(object sender, EventArgs e) { + private void ColorButtonClick(object sender, EventArgs e) { ColorDialog colorDialog = ColorDialog.GetInstance(); colorDialog.Color = SelectedColor; // Using the parent to make sure the dialog doesn't show on another window diff --git a/Greenshot/Controls/FontFamilyComboBox.cs b/Greenshot/Controls/FontFamilyComboBox.cs index 7b1e4183b..53a89111a 100644 --- a/Greenshot/Controls/FontFamilyComboBox.cs +++ b/Greenshot/Controls/FontFamilyComboBox.cs @@ -53,7 +53,7 @@ namespace Greenshot.Controls { } } - void ComboBox_DrawItem(object sender, DrawItemEventArgs e) { + private void ComboBox_DrawItem(object sender, DrawItemEventArgs e) { // DrawBackground handles drawing the background (i.e,. hot-tracked v. not) // It uses the system colors (Bluish, and and white, by default) // same as calling e.Graphics.FillRectangle ( SystemBrushes.Highlight, e.Bounds ); @@ -108,7 +108,7 @@ namespace Greenshot.Controls { } } - void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { + private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("Text")); PropertyChanged(this, new PropertyChangedEventArgs("FontFamily")); diff --git a/Greenshot/Controls/MenuStripEx.cs b/Greenshot/Controls/MenuStripEx.cs index b2b1d0fc1..b8f1ab264 100644 --- a/Greenshot/Controls/MenuStripEx.cs +++ b/Greenshot/Controls/MenuStripEx.cs @@ -29,7 +29,7 @@ namespace Greenshot.Controls { public class MenuStripEx : MenuStrip { private const int WM_MOUSEACTIVATE = 0x21; - enum NativeConstants : uint { + private enum NativeConstants : uint { MA_ACTIVATE = 1, MA_ACTIVATEANDEAT = 2, } diff --git a/Greenshot/Controls/ToolStripColorButton.cs b/Greenshot/Controls/ToolStripColorButton.cs index c4d5d3808..05391bfd7 100644 --- a/Greenshot/Controls/ToolStripColorButton.cs +++ b/Greenshot/Controls/ToolStripColorButton.cs @@ -65,7 +65,7 @@ namespace Greenshot.Controls { } } - void ColorButtonClick(object sender, EventArgs e) { + private void ColorButtonClick(object sender, EventArgs e) { ColorDialog colorDialog = ColorDialog.GetInstance(); colorDialog.Color = SelectedColor; // Using the parent to make sure the dialog doesn't show on another window diff --git a/Greenshot/Controls/ToolStripEx.cs b/Greenshot/Controls/ToolStripEx.cs index c93e51653..1298db21f 100644 --- a/Greenshot/Controls/ToolStripEx.cs +++ b/Greenshot/Controls/ToolStripEx.cs @@ -26,10 +26,10 @@ namespace Greenshot.Controls { /// This is an extension of the default ToolStrip and allows us to click it even when the form doesn't have focus. /// See: http://blogs.msdn.com/b/rickbrew/archive/2006/01/09/511003.aspx /// - class ToolStripEx : ToolStrip { + internal class ToolStripEx : ToolStrip { private const int WM_MOUSEACTIVATE = 0x21; - enum NativeConstants : uint { + private enum NativeConstants : uint { MA_ACTIVATE = 1, MA_ACTIVATEANDEAT = 2, } diff --git a/Greenshot/Drawing/Fields/AbstractFieldHolderWithChildren.cs b/Greenshot/Drawing/Fields/AbstractFieldHolderWithChildren.cs index 21922cc1b..55c810d27 100644 --- a/Greenshot/Drawing/Fields/AbstractFieldHolderWithChildren.cs +++ b/Greenshot/Drawing/Fields/AbstractFieldHolderWithChildren.cs @@ -34,8 +34,7 @@ namespace Greenshot.Drawing.Fields [Serializable()] public abstract class AbstractFieldHolderWithChildren : AbstractFieldHolder { - - FieldChangedEventHandler fieldChangedEventHandler; + private FieldChangedEventHandler fieldChangedEventHandler; [NonSerialized] private EventHandler childrenChanged; diff --git a/Greenshot/Drawing/Fields/FieldAggregator.cs b/Greenshot/Drawing/Fields/FieldAggregator.cs index 0bbd395d3..efeab79bd 100644 --- a/Greenshot/Drawing/Fields/FieldAggregator.cs +++ b/Greenshot/Drawing/Fields/FieldAggregator.cs @@ -47,7 +47,7 @@ namespace Greenshot.Drawing.Fields private IDrawableContainerList boundContainers; private bool internalUpdateRunning = false; - enum Status { IDLE, BINDING, UPDATING }; + private enum Status { IDLE, BINDING, UPDATING }; private static readonly ILog LOG = LogManager.GetLogger(typeof(FieldAggregator)); private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection(); diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index cc727eb7b..3edf59364 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -1169,7 +1169,7 @@ namespace Greenshot.Drawing /// /// /// - void SurfaceMouseDown(object sender, MouseEventArgs e) + private void SurfaceMouseDown(object sender, MouseEventArgs e) { // Handle Adorners @@ -1261,7 +1261,7 @@ namespace Greenshot.Drawing /// /// /// - void SurfaceMouseUp(object sender, MouseEventArgs e) + private void SurfaceMouseUp(object sender, MouseEventArgs e) { // Handle Adorners @@ -1350,7 +1350,7 @@ namespace Greenshot.Drawing /// /// /// - void SurfaceMouseMove(object sender, MouseEventArgs e) + private void SurfaceMouseMove(object sender, MouseEventArgs e) { // Handle Adorners var adorner = FindActiveAdorner(e); @@ -1417,7 +1417,7 @@ namespace Greenshot.Drawing /// /// /// - void SurfaceDoubleClick(object sender, MouseEventArgs e) + private void SurfaceDoubleClick(object sender, MouseEventArgs e) { selectedElements.OnDoubleClick(); selectedElements.Invalidate(); @@ -1459,7 +1459,7 @@ namespace Greenshot.Drawing /// /// /// PaintEventArgs - void SurfacePaint(object sender, PaintEventArgs paintEventArgs) + private void SurfacePaint(object sender, PaintEventArgs paintEventArgs) { Graphics targetGraphics = paintEventArgs.Graphics; Rectangle clipRectangle = paintEventArgs.ClipRectangle; diff --git a/Greenshot/Forms/AboutForm.cs b/Greenshot/Forms/AboutForm.cs index 8bca7f2eb..e35d281e7 100644 --- a/Greenshot/Forms/AboutForm.cs +++ b/Greenshot/Forms/AboutForm.cs @@ -116,7 +116,7 @@ namespace Greenshot { // 18 19 20 21 22 23 // The order in which we draw the dots & flow the collors. - readonly List flowOrder = new List() { 4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 14, 15, 18, 19, 20, 21, 22, 23, 16, 17, 13, 12, 11 }; + private readonly List flowOrder = new List() { 4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 14, 15, 18, 19, 20, 21, 22, 23, 16, 17, 13, 12, 11 }; /// /// Cleanup all the allocated resources @@ -211,7 +211,7 @@ namespace Greenshot { /// /// /// - void LinkLabelClicked(object sender, LinkLabelLinkClickedEventArgs e) { + private void LinkLabelClicked(object sender, LinkLabelLinkClickedEventArgs e) { LinkLabel linkLabel = sender as LinkLabel; if (linkLabel != null) { try { diff --git a/Greenshot/Forms/BugReportForm.cs b/Greenshot/Forms/BugReportForm.cs index 08c28c5ef..9cf72b968 100644 --- a/Greenshot/Forms/BugReportForm.cs +++ b/Greenshot/Forms/BugReportForm.cs @@ -37,8 +37,8 @@ namespace Greenshot.Forms { public BugReportForm(string bugText) : this() { textBoxDescription.Text = bugText; } - - void LinkLblBugsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { + + private void LinkLblBugsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { openLink((LinkLabel)sender); } diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index d4a9f0512..0f34ca0ab 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -185,7 +185,7 @@ namespace Greenshot.Forms { /// /// Create an animation for the zoomer, depending on if it's active or not. /// - void InitializeZoomer(bool isOn) { + private void InitializeZoomer(bool isOn) { if (isOn) { // Initialize the zoom with a invalid position _zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), FramesForMillis(1000), EasingType.Quintic, EasingMode.EaseOut); @@ -196,7 +196,8 @@ namespace Greenshot.Forms { } #region key handling - void CaptureFormKeyUp(object sender, KeyEventArgs e) { + + private void CaptureFormKeyUp(object sender, KeyEventArgs e) { switch(e.KeyCode) { case Keys.ShiftKey: _fixMode = FixMode.None; @@ -212,7 +213,7 @@ namespace Greenshot.Forms { /// /// /// - void CaptureFormKeyDown(object sender, KeyEventArgs e) { + private void CaptureFormKeyDown(object sender, KeyEventArgs e) { int step = _isCtrlPressed ? 10 : 1; switch (e.KeyCode) { @@ -319,7 +320,7 @@ namespace Greenshot.Forms { /// /// /// - void OnMouseDown(object sender, MouseEventArgs e) { + private void OnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { HandleMouseDown(); } @@ -360,7 +361,7 @@ namespace Greenshot.Forms { /// /// /// - void OnMouseUp(object sender, MouseEventArgs e) { + private void OnMouseUp(object sender, MouseEventArgs e) { if (_mouseDown) { HandleMouseUp(); } @@ -392,7 +393,7 @@ namespace Greenshot.Forms { /// /// /// - void OnMouseMove(object sender, MouseEventArgs e) { + private void OnMouseMove(object sender, MouseEventArgs e) { // Make sure the mouse coordinates are fixed, when pressing shift _mouseMovePos = FixMouseCoordinates(User32.GetCursorLocation()); _mouseMovePos = WindowCapture.GetLocationRelativeToScreenBounds(_mouseMovePos); @@ -704,7 +705,7 @@ namespace Greenshot.Forms { /// /// /// - void OnPaint(object sender, PaintEventArgs e) { + private void OnPaint(object sender, PaintEventArgs e) { Graphics graphics = e.Graphics; Rectangle clipRectangle = e.ClipRectangle; //graphics.BitBlt((Bitmap)buffer, Point.Empty); diff --git a/Greenshot/Forms/ColorDialog.cs b/Greenshot/Forms/ColorDialog.cs index 4c2bcbe9f..d4428b407 100644 --- a/Greenshot/Forms/ColorDialog.cs +++ b/Greenshot/Forms/ColorDialog.cs @@ -165,7 +165,8 @@ namespace Greenshot { #endregion #region textbox event handlers - void TextBoxHexadecimalTextChanged(object sender, EventArgs e) { + + private void TextBoxHexadecimalTextChanged(object sender, EventArgs e) { if (_updateInProgress) { return; } @@ -188,7 +189,7 @@ namespace Greenshot { PreviewColor(opaqueColor, textBox); } - void TextBoxRGBTextChanged(object sender, EventArgs e) { + private void TextBoxRGBTextChanged(object sender, EventArgs e) { if (_updateInProgress) { return; } @@ -196,11 +197,11 @@ namespace Greenshot { PreviewColor(Color.FromArgb(GetColorPartIntFromString(textBoxAlpha.Text), GetColorPartIntFromString(textBoxRed.Text), GetColorPartIntFromString(textBoxGreen.Text), GetColorPartIntFromString(textBoxBlue.Text)), textBox); } - void TextBoxGotFocus(object sender, EventArgs e) { + private void TextBoxGotFocus(object sender, EventArgs e) { textBoxHtmlColor.SelectAll(); } - void TextBoxKeyDown(object sender, KeyEventArgs e) { + private void TextBoxKeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) { AddToRecentColors(colorPanel.BackColor); } @@ -208,15 +209,17 @@ namespace Greenshot { #endregion #region button event handlers - void ColorButtonClick(object sender, EventArgs e) { + + private void ColorButtonClick(object sender, EventArgs e) { Button b = (Button)sender; PreviewColor(b.BackColor, b); } - void BtnTransparentClick(object sender, EventArgs e) { + private void BtnTransparentClick(object sender, EventArgs e) { ColorButtonClick(sender, e); } - void BtnApplyClick(object sender, EventArgs e) { + + private void BtnApplyClick(object sender, EventArgs e) { DialogResult = DialogResult.OK; Hide(); AddToRecentColors(colorPanel.BackColor); diff --git a/Greenshot/Forms/LanguageDialog.cs b/Greenshot/Forms/LanguageDialog.cs index ed77a1c8a..c043017da 100644 --- a/Greenshot/Forms/LanguageDialog.cs +++ b/Greenshot/Forms/LanguageDialog.cs @@ -78,8 +78,8 @@ namespace Greenshot.Forms { Close(); } } - - void BtnOKClick(object sender, EventArgs e) { + + private void BtnOKClick(object sender, EventArgs e) { properOkPressed = true; // Fix for Bug #3431100 Language.CurrentLanguage = SelectedLanguage; diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 7beee15f5..5c4a9d0a8 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -648,24 +648,26 @@ namespace Greenshot { #region mainform events - void MainFormFormClosing(object sender, FormClosingEventArgs e) { + + private void MainFormFormClosing(object sender, FormClosingEventArgs e) { LOG.DebugFormat("Mainform closing, reason: {0}", e.CloseReason); _instance = null; Exit(); } - void MainFormActivated(object sender, EventArgs e) { + private void MainFormActivated(object sender, EventArgs e) { Hide(); ShowInTaskbar = false; } #endregion #region key handlers - void CaptureRegion() { + + private void CaptureRegion() { CaptureHelper.CaptureRegion(true); } - void CaptureFile() { + private void CaptureFile() { var openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Image files (*.greenshot, *.png, *.jpg, *.gif, *.bmp, *.ico, *.tiff, *.wmf)|*.greenshot; *.png; *.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.tiff; *.tif; *.wmf"; if (openFileDialog.ShowDialog() == DialogResult.OK) { @@ -675,21 +677,21 @@ namespace Greenshot { } } - void CaptureFullScreen() { + private void CaptureFullScreen() { CaptureHelper.CaptureFullscreen(true, _conf.ScreenCaptureMode); } - void CaptureLastRegion() { + private void CaptureLastRegion() { CaptureHelper.CaptureLastRegion(true); } - void CaptureIE() { + private void CaptureIE() { if (_conf.IECapture) { CaptureHelper.CaptureIE(true, null); } } - void CaptureWindow() { + private void CaptureWindow() { if (_conf.CaptureWindowsInteractive) { CaptureHelper.CaptureWindowInteractive(true); } else { @@ -700,7 +702,8 @@ namespace Greenshot { #region contextmenu - void ContextMenuOpening(object sender, CancelEventArgs e) { + + private void ContextMenuOpening(object sender, CancelEventArgs e) { contextmenu_captureclipboard.Enabled = ClipboardHelper.ContainsImage(); contextmenu_capturelastregion.Enabled = coreConfiguration.LastCapturedRegion != Rectangle.Empty; @@ -735,8 +738,8 @@ namespace Greenshot { contextmenu_donate.Image = (Image)resources.GetObject("contextmenu_present.Image"); } } - - void ContextMenuClosing(object sender, EventArgs e) { + + private void ContextMenuClosing(object sender, EventArgs e) { contextmenu_captureiefromlist.DropDownItems.Clear(); contextmenu_capturewindowfromlist.DropDownItems.Clear(); CleanupThumbnail(); @@ -745,7 +748,7 @@ namespace Greenshot { /// /// Build a selectable list of IE tabs when we enter the menu item /// - void CaptureIEMenuDropDownOpening(object sender, EventArgs e) { + private void CaptureIEMenuDropDownOpening(object sender, EventArgs e) { if (!_conf.IECapture) { return; } @@ -903,43 +906,43 @@ namespace Greenshot { } } - void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e) { + private void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e) { BeginInvoke((MethodInvoker)delegate { CaptureHelper.CaptureRegion(false); }); } - void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e) { + private void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e) { BeginInvoke((MethodInvoker)delegate { CaptureHelper.CaptureClipboard(); }); } - - void OpenFileToolStripMenuItemClick(object sender, EventArgs e) { + + private void OpenFileToolStripMenuItemClick(object sender, EventArgs e) { BeginInvoke((MethodInvoker)delegate { CaptureFile(); }); } - void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e) { + private void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e) { BeginInvoke((MethodInvoker)delegate { CaptureHelper.CaptureFullscreen(false, _conf.ScreenCaptureMode); }); } - - void Contextmenu_capturelastregionClick(object sender, EventArgs e) { + + private void Contextmenu_capturelastregionClick(object sender, EventArgs e) { BeginInvoke((MethodInvoker)delegate { CaptureHelper.CaptureLastRegion(false); }); } - - void Contextmenu_capturewindow_Click(object sender,EventArgs e) { + + private void Contextmenu_capturewindow_Click(object sender,EventArgs e) { BeginInvoke((MethodInvoker)delegate { CaptureHelper.CaptureWindowInteractive(false); }); } - void Contextmenu_capturewindowfromlist_Click(object sender,EventArgs e) { + private void Contextmenu_capturewindowfromlist_Click(object sender,EventArgs e) { ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender; BeginInvoke((MethodInvoker)delegate { try { @@ -950,12 +953,12 @@ namespace Greenshot { } }); } - - void Contextmenu_captureie_Click(object sender, EventArgs e) { + + private void Contextmenu_captureie_Click(object sender, EventArgs e) { CaptureIE(); } - void Contextmenu_captureiefromlist_Click(object sender, EventArgs e) { + private void Contextmenu_captureiefromlist_Click(object sender, EventArgs e) { if (!_conf.IECapture) { LOG.InfoFormat("IE Capture is disabled."); return; @@ -985,7 +988,7 @@ namespace Greenshot { /// /// /// - void Contextmenu_donateClick(object sender, EventArgs e) { + private void Contextmenu_donateClick(object sender, EventArgs e) { BeginInvoke((MethodInvoker)delegate { Process.Start("http://getgreenshot.org/support/"); }); @@ -996,7 +999,7 @@ namespace Greenshot { /// /// /// - void Contextmenu_settingsClick(object sender, EventArgs e) { + private void Contextmenu_settingsClick(object sender, EventArgs e) { BeginInvoke((MethodInvoker)delegate { ShowSetting(); }); @@ -1026,7 +1029,7 @@ namespace Greenshot { /// /// /// - void Contextmenu_aboutClick(object sender, EventArgs e) { + private void Contextmenu_aboutClick(object sender, EventArgs e) { ShowAbout(); } @@ -1049,7 +1052,7 @@ namespace Greenshot { /// /// /// - void Contextmenu_helpClick(object sender, EventArgs e) { + private void Contextmenu_helpClick(object sender, EventArgs e) { HelpFileLoader.LoadHelp(); } @@ -1058,7 +1061,7 @@ namespace Greenshot { /// /// /// - void Contextmenu_exitClick(object sender, EventArgs e) { + private void Contextmenu_exitClick(object sender, EventArgs e) { Exit(); } @@ -1150,8 +1153,8 @@ namespace Greenshot { contextmenu_quicksettings.DropDownItems.Add(selectList); } } - - void QuickSettingCaptureModeChanged(object sender, EventArgs e) { + + private void QuickSettingCaptureModeChanged(object sender, EventArgs e) { ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item; WindowCaptureMode windowsCaptureMode = (WindowCaptureMode)item.Data; if (item.Checked) { @@ -1159,7 +1162,7 @@ namespace Greenshot { } } - void QuickSettingBoolItemChanged(object sender, EventArgs e) { + private void QuickSettingBoolItemChanged(object sender, EventArgs e) { ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item; IniValue iniValue = item.Data as IniValue; if (iniValue != null) { @@ -1168,7 +1171,7 @@ namespace Greenshot { } } - void QuickSettingDestinationChanged(object sender, EventArgs e) { + private void QuickSettingDestinationChanged(object sender, EventArgs e) { ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item; IDestination selectedDestination = (IDestination)item.Data; if (item.Checked) { diff --git a/Greenshot/Forms/PrintOptionsDialog.cs b/Greenshot/Forms/PrintOptionsDialog.cs index 18313498e..34884d402 100644 --- a/Greenshot/Forms/PrintOptionsDialog.cs +++ b/Greenshot/Forms/PrintOptionsDialog.cs @@ -34,9 +34,9 @@ namespace Greenshot.Forms { InitializeComponent(); checkbox_dontaskagain.Checked = false; } - - - void Button_okClick(object sender, EventArgs e) { + + + private void Button_okClick(object sender, EventArgs e) { // update config coreConfiguration.OutputPrintPromptOptions = !checkbox_dontaskagain.Checked; IniConfig.Save(); diff --git a/Greenshot/Forms/SettingsForm.cs b/Greenshot/Forms/SettingsForm.cs index 00588bdee..21a584fe2 100644 --- a/Greenshot/Forms/SettingsForm.cs +++ b/Greenshot/Forms/SettingsForm.cs @@ -467,12 +467,12 @@ namespace Greenshot { LOG.Warn("Problem checking registry, ignoring for now: ", e); } } - - void Settings_cancelClick(object sender, EventArgs e) { + + private void Settings_cancelClick(object sender, EventArgs e) { DialogResult = DialogResult.Cancel; } - - void Settings_okayClick(object sender, EventArgs e) { + + private void Settings_okayClick(object sender, EventArgs e) { if (CheckSettings()) { HotkeyControl.UnregisterHotkeys(); SaveSettings(); @@ -486,8 +486,8 @@ namespace Greenshot { tabcontrol.SelectTab(tab_output); } } - - void BrowseClick(object sender, EventArgs e) { + + private void BrowseClick(object sender, EventArgs e) { // Get the storage location and replace the environment variables folderBrowserDialog1.SelectedPath = FilenameHelper.FillVariables(textbox_storagelocation.Text, false); if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { @@ -497,28 +497,28 @@ namespace Greenshot { } } } - - void TrackBarJpegQualityScroll(object sender, EventArgs e) { + + private void TrackBarJpegQualityScroll(object sender, EventArgs e) { textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString(CultureInfo.InvariantCulture); } - - void BtnPatternHelpClick(object sender, EventArgs e) { + + private void BtnPatternHelpClick(object sender, EventArgs e) { string filenamepatternText = Language.GetString(LangKey.settings_message_filenamepattern); // Convert %NUM% to ${NUM} for old language files! filenamepatternText = Regex.Replace(filenamepatternText, "%([a-zA-Z_0-9]+)%", @"${$1}"); MessageBox.Show(filenamepatternText, Language.GetString(LangKey.settings_filenamepattern)); } - - void Listview_pluginsSelectedIndexChanged(object sender, EventArgs e) { + + private void Listview_pluginsSelectedIndexChanged(object sender, EventArgs e) { button_pluginconfigure.Enabled = PluginHelper.Instance.isSelectedItemConfigurable(listview_plugins); } - - void Button_pluginconfigureClick(object sender, EventArgs e) { + + private void Button_pluginconfigureClick(object sender, EventArgs e) { PluginHelper.Instance.ConfigureSelectedItem(listview_plugins); } - void Combobox_languageSelectedIndexChanged(object sender, EventArgs e) { + private void Combobox_languageSelectedIndexChanged(object sender, EventArgs e) { // Get the combobox values BEFORE changing the language //EmailFormat selectedEmailFormat = GetSelected(combobox_emailformat); WindowCaptureMode selectedWindowCaptureMode = GetSelected(combobox_window_capture_mode); @@ -536,8 +536,8 @@ namespace Greenshot { //SetEmailFormat(selectedEmailFormat); SetWindowCaptureMode(selectedWindowCaptureMode); } - - void Combobox_window_capture_modeSelectedIndexChanged(object sender, EventArgs e) { + + private void Combobox_window_capture_modeSelectedIndexChanged(object sender, EventArgs e) { int windowsVersion = Environment.OSVersion.Version.Major; WindowCaptureMode mode = GetSelected(combobox_window_capture_mode); if (windowsVersion >= 6) { @@ -553,7 +553,7 @@ namespace Greenshot { /// /// Check the destination settings /// - void CheckDestinationSettings() { + private void CheckDestinationSettings() { bool clipboardDestinationChecked = false; bool pickerSelected = checkbox_picker.Checked; bool destinationsEnabled = true; @@ -588,7 +588,7 @@ namespace Greenshot { } } - void DestinationsCheckStateChanged(object sender, EventArgs e) { + private void DestinationsCheckStateChanged(object sender, EventArgs e) { CheckDestinationSettings(); } diff --git a/Greenshot/GreenshotMain.cs b/Greenshot/GreenshotMain.cs index 849b01b1a..150e2aecb 100644 --- a/Greenshot/GreenshotMain.cs +++ b/Greenshot/GreenshotMain.cs @@ -32,7 +32,7 @@ namespace Greenshot { AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; } - static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { + private static Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) { Assembly ayResult = null; string sShortAssemblyName = args.Name.Split(',')[0]; Assembly[] ayAssemblies = AppDomain.CurrentDomain.GetAssemblies(); diff --git a/Greenshot/Helpers/PrintHelper.cs b/Greenshot/Helpers/PrintHelper.cs index 65c32e939..95b01552c 100644 --- a/Greenshot/Helpers/PrintHelper.cs +++ b/Greenshot/Helpers/PrintHelper.cs @@ -155,7 +155,7 @@ namespace Greenshot.Helpers { return ret; } - void DrawImageForPrint(object sender, PrintPageEventArgs e) { + private void DrawImageForPrint(object sender, PrintPageEventArgs e) { // Create the output settins diff --git a/Greenshot/Helpers/ToolStripItemEndisabler.cs b/Greenshot/Helpers/ToolStripItemEndisabler.cs index f074f5e44..dc62f4cc7 100644 --- a/Greenshot/Helpers/ToolStripItemEndisabler.cs +++ b/Greenshot/Helpers/ToolStripItemEndisabler.cs @@ -29,7 +29,7 @@ namespace Greenshot.Helpers { /// public static class ToolStripItemEndisabler { [Flags] - enum PropagationMode {NONE=0, CHILDREN=1, ANCESTORS=2}; + private enum PropagationMode {NONE=0, CHILDREN=1, ANCESTORS=2}; /// /// Enables all of a ToolStrip's children (recursively), diff --git a/Greenshot/Memento/DrawableContainerBoundsChangeMemento.cs b/Greenshot/Memento/DrawableContainerBoundsChangeMemento.cs index 37564b694..01f372b10 100644 --- a/Greenshot/Memento/DrawableContainerBoundsChangeMemento.cs +++ b/Greenshot/Memento/DrawableContainerBoundsChangeMemento.cs @@ -31,9 +31,9 @@ namespace Greenshot.Memento /// public class DrawableContainerBoundsChangeMemento : IMemento { - List points = new List(); - List sizes = new List(); - IDrawableContainerList listOfdrawableContainer; + private List points = new List(); + private List sizes = new List(); + private IDrawableContainerList listOfdrawableContainer; private void StoreBounds() { diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceConfigurationForm.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceConfigurationForm.xaml.cs index deee806a0..d194fddcb 100644 --- a/GreenshotConfluencePlugin/Forms/ConfluenceConfigurationForm.xaml.cs +++ b/GreenshotConfluencePlugin/Forms/ConfluenceConfigurationForm.xaml.cs @@ -38,8 +38,8 @@ namespace GreenshotConfluencePlugin { this.config = config; InitializeComponent(); } - - void Button_OK_Click(object sender, RoutedEventArgs e) { + + private void Button_OK_Click(object sender, RoutedEventArgs e) { DialogResult = true; } } diff --git a/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs index cbaa66438..cc237ccbe 100644 --- a/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs +++ b/GreenshotConfluencePlugin/Forms/ConfluencePagePicker.xaml.cs @@ -35,12 +35,12 @@ namespace GreenshotConfluencePlugin { DataContext = pagesToPick; InitializeComponent(); } - - void PageListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { + + private void PageListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { SelectionChanged(); } - - void SelectionChanged() { + + private void SelectionChanged() { if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) { confluenceUpload.SelectedPage = (Page)PageListView.SelectedItem; // Make sure the uploader knows we selected an already opened page @@ -49,8 +49,8 @@ namespace GreenshotConfluencePlugin { confluenceUpload.SelectedPage = null; } } - - void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) { + + private void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) { SelectionChanged(); } } diff --git a/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs b/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs index a9326887a..82424d5c7 100644 --- a/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs +++ b/GreenshotConfluencePlugin/Forms/ConfluenceUpload.xaml.cs @@ -110,8 +110,8 @@ namespace GreenshotConfluencePlugin { SearchTab.IsSelected = true; } } - - void UpdateSpaces() { + + private void UpdateSpaces() { if (_spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(_lastLoad) > 0) { // Reset _spaces = null; @@ -125,7 +125,7 @@ namespace GreenshotConfluencePlugin { } } - void Upload_Click(object sender, RoutedEventArgs e) { + private void Upload_Click(object sender, RoutedEventArgs e) { DialogResult = true; } } diff --git a/GreenshotDropboxPlugin/DropboxDestination.cs b/GreenshotDropboxPlugin/DropboxDestination.cs index 004b20334..4faf9f9a1 100644 --- a/GreenshotDropboxPlugin/DropboxDestination.cs +++ b/GreenshotDropboxPlugin/DropboxDestination.cs @@ -24,7 +24,7 @@ using Greenshot.IniFile; using Greenshot.Plugin; using GreenshotPlugin.Core; namespace GreenshotDropboxPlugin { - class DropboxDestination : AbstractDestination { + internal class DropboxDestination : AbstractDestination { private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxDestination)); private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection(); diff --git a/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs b/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs index ea845fb6e..d6aae0d1f 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandConfiguration.cs @@ -52,28 +52,85 @@ namespace ExternalCommand { public bool UriToClipboard { get; set; } [IniProperty("Commandline", Description="The commandline for the output command.")] - public Dictionary commandlines { get; set; } + public Dictionary Commandline { get; set; } [IniProperty("Argument", Description="The arguments for the output command.")] - public Dictionary arguments { get; set; } + public Dictionary Argument { get; set; } [IniProperty("RunInbackground", Description = "Should the command be started in the background.")] - public Dictionary runInbackground { get; set; } + public Dictionary RunInbackground { get; set; } - private const string MSPAINT = "MS Paint"; - private static readonly string paintPath; - private static readonly bool hasPaint = false; + [IniProperty("DeletedBuildInCommands", Description = "If a build in command was deleted manually, it should not be recreated.")] + public List DeletedBuildInCommands { get; set; } - private const string PAINTDOTNET = "Paint.NET"; - private static readonly string paintDotNetPath; - private static readonly bool hasPaintDotNet = false; + private const string MsPaint = "MS Paint"; + private static readonly string PaintPath; + private static readonly bool HasPaint; + + private const string PaintDotNet = "Paint.NET"; + private static readonly string PaintDotNetPath; + private static readonly bool HasPaintDotNet; static ExternalCommandConfiguration() { try { - paintPath = PluginUtils.GetExePath("pbrush.exe"); - hasPaint = !string.IsNullOrEmpty(paintPath) && File.Exists(paintPath); - paintDotNetPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Paint.NET\PaintDotNet.exe"); - hasPaintDotNet = !string.IsNullOrEmpty(paintDotNetPath) && File.Exists(paintDotNetPath); + PaintPath = PluginUtils.GetExePath("pbrush.exe"); + HasPaint = !string.IsNullOrEmpty(PaintPath) && File.Exists(PaintPath); } catch { + // Ignore + } + try + { + PaintDotNetPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Paint.NET\PaintDotNet.exe"); + HasPaintDotNet = !string.IsNullOrEmpty(PaintDotNetPath) && File.Exists(PaintDotNetPath); + } + catch + { + // Ignore + } + } + + /// + /// Delete the configuration for the specified command + /// + /// string with command + public void Delete(string command) + { + if (string.IsNullOrEmpty(command)) + { + return; + } + Commands.Remove(command); + Commandline.Remove(command); + Argument.Remove(command); + RunInbackground.Remove(command); + if (MsPaint.Equals(command) || PaintDotNet.Equals(command)) + { + if (!DeletedBuildInCommands.Contains(command)) + { + DeletedBuildInCommands.Add(command); + } + } + } + + public override void AfterLoad() + { + base.AfterLoad(); + + // Check if we need to add MsPaint + if (HasPaint && !Commands.Contains(MsPaint) && !DeletedBuildInCommands.Contains(MsPaint)) + { + Commands.Add(MsPaint); + Commandline.Add(MsPaint, PaintPath); + Argument.Add(MsPaint, "\"{0}\""); + RunInbackground.Add(MsPaint, true); + } + + // Check if we need to add Paint.NET + if (HasPaintDotNet && !Commands.Contains(PaintDotNet) && !DeletedBuildInCommands.Contains(PaintDotNet)) + { + Commands.Add(PaintDotNet); + Commandline.Add(PaintDotNet, PaintDotNetPath); + Argument.Add(PaintDotNet, "\"{0}\""); + RunInbackground.Add(PaintDotNet, true); } } @@ -84,42 +141,16 @@ namespace ExternalCommand { /// object with the default value for the supplied property public override object GetDefault(string property) { switch(property) { - case "Commands": - List commandDefaults = new List(); - if (hasPaintDotNet) { - commandDefaults.Add(PAINTDOTNET); - } - if (hasPaint) { - commandDefaults.Add(MSPAINT); - } - return commandDefaults; - case "Commandline": - Dictionary commandlineDefaults = new Dictionary(); - if (hasPaintDotNet) { - commandlineDefaults.Add(PAINTDOTNET, paintDotNetPath); - } - if (hasPaint) { - commandlineDefaults.Add(MSPAINT, paintPath); - } - return commandlineDefaults; - case "Argument": - Dictionary argumentDefaults = new Dictionary(); - if (hasPaintDotNet) { - argumentDefaults.Add(PAINTDOTNET, "\"{0}\""); - } - if (hasPaint) { - argumentDefaults.Add(MSPAINT, "\"{0}\""); - } - return argumentDefaults; - case "RunInbackground": - Dictionary runInBackground = new Dictionary(); - if (hasPaintDotNet) { - runInBackground.Add(PAINTDOTNET, true); - } - if (hasPaint) { - runInBackground.Add(MSPAINT, true); - } - return runInBackground; + case nameof(DeletedBuildInCommands): + return new List(); + case nameof(Commands): + return new List(); + case nameof(Commandline): + return new Dictionary(); + case nameof(Argument): + return new Dictionary(); + case nameof(RunInbackground): + return new Dictionary(); } return null; } diff --git a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs index a115815ca..654c2051a 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandDestination.cs @@ -71,10 +71,10 @@ namespace ExternalCommand { if (_presetCommand != null) { - if (!config.runInbackground.ContainsKey(_presetCommand)) { - config.runInbackground.Add(_presetCommand, true); + if (!config.RunInbackground.ContainsKey(_presetCommand)) { + config.RunInbackground.Add(_presetCommand, true); } - bool runInBackground = config.runInbackground[_presetCommand]; + bool runInBackground = config.RunInbackground[_presetCommand]; string fullPath = captureDetails.Filename; if (fullPath == null) { fullPath = ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings); @@ -139,7 +139,7 @@ namespace ExternalCommand { } catch (Exception ex) { exportInformation.ExportMade = false; exportInformation.ErrorMessage = ex.Message; - LOG.WarnFormat("Error calling external command: {0} ", exportInformation.ErrorMessage); + LOG.WarnFormat("Error calling external command: {0} ", exportInformation.ErrorMessage); } } @@ -158,13 +158,13 @@ namespace ExternalCommand { try { return CallExternalCommand(commando, fullPath, "runas", out output, out error); } catch { - w32ex.Data.Add("commandline", config.commandlines[_presetCommand]); - w32ex.Data.Add("arguments", config.arguments[_presetCommand]); + w32ex.Data.Add("commandline", config.Commandline[_presetCommand]); + w32ex.Data.Add("arguments", config.Argument[_presetCommand]); throw; } } catch (Exception ex) { - ex.Data.Add("commandline", config.commandlines[_presetCommand]); - ex.Data.Add("arguments", config.arguments[_presetCommand]); + ex.Data.Add("commandline", config.Commandline[_presetCommand]); + ex.Data.Add("arguments", config.Argument[_presetCommand]); throw; } } @@ -179,8 +179,8 @@ namespace ExternalCommand { /// /// private int CallExternalCommand(string commando, string fullPath, string verb, out string output, out string error) { - string commandline = config.commandlines[commando]; - string arguments = config.arguments[commando]; + string commandline = config.Commandline[commando]; + string arguments = config.Argument[commando]; output = null; error = null; if (!string.IsNullOrEmpty(commandline)) { @@ -227,9 +227,9 @@ namespace ExternalCommand { return -1; } - public static string FormatArguments(string arguments, string fullpath) - { - return string.Format(arguments, fullpath); - } - } + public static string FormatArguments(string arguments, string fullpath) + { + return string.Format(arguments, fullpath); + } + } } diff --git a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs index 51d637a12..670b17106 100644 --- a/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs +++ b/GreenshotExternalCommandPlugin/ExternalCommandPlugin.cs @@ -33,9 +33,9 @@ namespace ExternalCommand { /// An Plugin to run commands after an image was written /// public class ExternalCommandPlugin : IGreenshotPlugin { - private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin)); - private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection(); - private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection(); + private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin)); + private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection(); + private static readonly ExternalCommandConfiguration ExternalCommandConfig = IniConfig.GetIniSection(); private IGreenshotHost _host; private PluginAttribute _myAttributes; private ToolStripMenuItem _itemPlugInRoot; @@ -55,7 +55,7 @@ namespace ExternalCommand { } public IEnumerable Destinations() { - foreach(string command in config.Commands) { + foreach(string command in ExternalCommandConfig.Commands) { yield return new ExternalCommandDestination(command); } } @@ -69,26 +69,26 @@ namespace ExternalCommand { /// /// /// false if the command is not correctly configured - private bool isCommandValid(string command) { - if (!config.runInbackground.ContainsKey(command)) { - LOG.WarnFormat("Found missing runInbackground for {0}", command); + private bool IsCommandValid(string command) { + if (!ExternalCommandConfig.RunInbackground.ContainsKey(command)) { + Log.WarnFormat("Found missing runInbackground for {0}", command); // Fix it - config.runInbackground.Add(command, true); + ExternalCommandConfig.RunInbackground.Add(command, true); } - if (!config.arguments.ContainsKey(command)) { - LOG.WarnFormat("Found missing argument for {0}", command); + if (!ExternalCommandConfig.Argument.ContainsKey(command)) { + Log.WarnFormat("Found missing argument for {0}", command); // Fix it - config.arguments.Add(command, "{0}"); + ExternalCommandConfig.Argument.Add(command, "{0}"); } - if (!config.commandlines.ContainsKey(command)) { - LOG.WarnFormat("Found missing commandline for {0}", command); + if (!ExternalCommandConfig.Commandline.ContainsKey(command)) { + Log.WarnFormat("Found missing commandline for {0}", command); return false; } - string commandline = FilenameHelper.FillVariables(config.commandlines[command], true); + string commandline = FilenameHelper.FillVariables(ExternalCommandConfig.Commandline[command], true); commandline = FilenameHelper.FillCmdVariables(commandline, true); if (!File.Exists(commandline)) { - LOG.WarnFormat("Found 'invalid' commandline {0} for command {1}", config.commandlines[command], command); + Log.WarnFormat("Found 'invalid' commandline {0} for command {1}", ExternalCommandConfig.Commandline[command], command); return false; } return true; @@ -99,22 +99,19 @@ namespace ExternalCommand { /// Use the IGreenshotPluginHost interface to register events /// My own attributes public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { - LOG.DebugFormat("Initialize called of {0}", myAttributes.Name); + Log.DebugFormat("Initialize called of {0}", myAttributes.Name); List commandsToDelete = new List(); // Check configuration - foreach(string command in config.Commands) { - if (!isCommandValid(command)) { + foreach(string command in ExternalCommandConfig.Commands) { + if (!IsCommandValid(command)) { commandsToDelete.Add(command); } } // cleanup foreach (string command in commandsToDelete) { - config.runInbackground.Remove(command); - config.commandlines.Remove(command); - config.arguments.Remove(command); - config.Commands.Remove(command); + ExternalCommandConfig.Delete(command); } _host = pluginHost; @@ -128,7 +125,7 @@ namespace ExternalCommand { PluginUtils.AddToContextMenu(_host, _itemPlugInRoot); Language.LanguageChanged += OnLanguageChanged; - coreConfig.PropertyChanged += OnIconSizeChanged; + CoreConfig.PropertyChanged += OnIconSizeChanged; return true; } @@ -145,7 +142,7 @@ namespace ExternalCommand { _itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0); } } catch (Exception ex) { - LOG.Warn("Couldn't get the cmd.exe image", ex); + Log.Warn("Couldn't get the cmd.exe image", ex); } } } @@ -157,7 +154,7 @@ namespace ExternalCommand { } public virtual void Shutdown() { - LOG.Debug("Shutdown of " + _myAttributes.Name); + Log.Debug("Shutdown of " + _myAttributes.Name); } private void ConfigMenuClick(object sender, EventArgs eventArgs) { @@ -168,7 +165,7 @@ namespace ExternalCommand { /// Implementation of the IPlugin.Configure /// public virtual void Configure() { - LOG.Debug("Configure called"); + Log.Debug("Configure called"); new SettingsForm().ShowDialog(); } } diff --git a/GreenshotExternalCommandPlugin/IconCache.cs b/GreenshotExternalCommandPlugin/IconCache.cs index 1e931634d..fdff5815e 100644 --- a/GreenshotExternalCommandPlugin/IconCache.cs +++ b/GreenshotExternalCommandPlugin/IconCache.cs @@ -33,11 +33,11 @@ namespace ExternalCommand { public static Image IconForCommand(string commandName) { Image icon = null; if (commandName != null) { - if (config.commandlines.ContainsKey(commandName) && File.Exists(config.commandlines[commandName])) { + if (config.Commandline.ContainsKey(commandName) && File.Exists(config.Commandline[commandName])) { try { - icon = PluginUtils.GetCachedExeIcon(config.commandlines[commandName], 0); + icon = PluginUtils.GetCachedExeIcon(config.Commandline[commandName], 0); } catch (Exception ex) { - LOG.Warn("Problem loading icon for " + config.commandlines[commandName], ex); + LOG.Warn("Problem loading icon for " + config.Commandline[commandName], ex); } } } diff --git a/GreenshotExternalCommandPlugin/SettingsForm.cs b/GreenshotExternalCommandPlugin/SettingsForm.cs index 2bb6a9331..e5721749b 100644 --- a/GreenshotExternalCommandPlugin/SettingsForm.cs +++ b/GreenshotExternalCommandPlugin/SettingsForm.cs @@ -29,8 +29,7 @@ namespace ExternalCommand { /// Description of SettingsForm. /// public partial class SettingsForm : ExternalCommandForm { - private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm)); - private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection(); + private static readonly ExternalCommandConfiguration ExternalCommandConfig = IniConfig.GetIniSection(); public SettingsForm() { // @@ -42,35 +41,34 @@ namespace ExternalCommand { UpdateView(); } - void ButtonOkClick(object sender, EventArgs e) { + private void ButtonOkClick(object sender, EventArgs e) { IniConfig.Save(); } - void ButtonAddClick(object sender, EventArgs e) { - SettingsFormDetail form = new SettingsFormDetail(null); + private void ButtonAddClick(object sender, EventArgs e) { + var form = new SettingsFormDetail(null); form.ShowDialog(); UpdateView(); } - void ButtonDeleteClick(object sender, EventArgs e) { + private void ButtonDeleteClick(object sender, EventArgs e) { foreach(ListViewItem item in listView1.SelectedItems) { string commando = item.Tag as string; - config.Commands.Remove(commando); - config.commandlines.Remove(commando); - config.arguments.Remove(commando); + + ExternalCommandConfig.Delete(commando); } UpdateView(); } - void UpdateView() { + private void UpdateView() { listView1.Items.Clear(); - if(config.Commands != null) { + if(ExternalCommandConfig.Commands != null) { listView1.ListViewItemSorter = new ListviewComparer(); ImageList imageList = new ImageList(); listView1.SmallImageList = imageList; int imageNr = 0; - foreach(string commando in config.Commands) { + foreach(string commando in ExternalCommandConfig.Commands) { ListViewItem item; Image iconForExe = IconCache.IconForCommand(commando); if(iconForExe != null) { @@ -87,15 +85,15 @@ namespace ExternalCommand { button_edit.Enabled = listView1.SelectedItems.Count > 0; } - void ListView1ItemSelectionChanged(object sender, EventArgs e) { + private void ListView1ItemSelectionChanged(object sender, EventArgs e) { button_edit.Enabled = listView1.SelectedItems.Count > 0; } - void ButtonEditClick(object sender, EventArgs e) { + private void ButtonEditClick(object sender, EventArgs e) { ListView1DoubleClick(sender, e); } - void ListView1DoubleClick(object sender, EventArgs e) { + private void ListView1DoubleClick(object sender, EventArgs e) { // Safety check for bug #1484 bool selectionActive = listView1.SelectedItems.Count > 0; if(!selectionActive) { @@ -104,7 +102,7 @@ namespace ExternalCommand { } string commando = listView1.SelectedItems[0].Tag as string; - SettingsFormDetail form = new SettingsFormDetail(commando); + var form = new SettingsFormDetail(commando); form.ShowDialog(); UpdateView(); @@ -120,12 +118,9 @@ namespace ExternalCommand { return (0); } - ListViewItem l1 = (ListViewItem)x; - ListViewItem l2 = (ListViewItem)y; - if(l2 == null) { - return 1; - } - return l1.Text.CompareTo(l2.Text); + var l1 = (ListViewItem)x; + var l2 = (ListViewItem)y; + return string.Compare(l1.Text, l2.Text, StringComparison.Ordinal); } } } diff --git a/GreenshotExternalCommandPlugin/SettingsFormDetail.cs b/GreenshotExternalCommandPlugin/SettingsFormDetail.cs index a5e794524..dbe2aaf20 100644 --- a/GreenshotExternalCommandPlugin/SettingsFormDetail.cs +++ b/GreenshotExternalCommandPlugin/SettingsFormDetail.cs @@ -45,8 +45,8 @@ namespace ExternalCommand { if(commando != null) { textBox_name.Text = commando; - textBox_commandline.Text = config.commandlines[commando]; - textBox_arguments.Text = config.arguments[commando]; + textBox_commandline.Text = config.Commandline[commando]; + textBox_arguments.Text = config.Argument[commando]; _commandIndex = config.Commands.FindIndex(delegate(string s) { return s == commando; }); } else { textBox_arguments.Text = "\"{0}\""; @@ -54,25 +54,25 @@ namespace ExternalCommand { OkButtonState(); } - void ButtonOkClick(object sender, EventArgs e) { + private void ButtonOkClick(object sender, EventArgs e) { string commandName = textBox_name.Text; string commandLine = textBox_commandline.Text; string arguments = textBox_arguments.Text; if(_commando != null) { config.Commands[_commandIndex] = commandName; - config.commandlines.Remove(_commando); - config.commandlines.Add(commandName, commandLine); - config.arguments.Remove(_commando); - config.arguments.Add(commandName, arguments); + config.Commandline.Remove(_commando); + config.Commandline.Add(commandName, commandLine); + config.Argument.Remove(_commando); + config.Argument.Add(commandName, arguments); } else { config.Commands.Add(commandName); - config.commandlines.Add(commandName, commandLine); - config.arguments.Add(commandName, arguments); + config.Commandline.Add(commandName, commandLine); + config.Argument.Add(commandName, arguments); } } - void Button3Click(object sender, EventArgs e) { - OpenFileDialog openFileDialog = new OpenFileDialog + private void Button3Click(object sender, EventArgs e) { + var openFileDialog = new OpenFileDialog { Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*", FilterIndex = 1, @@ -106,7 +106,7 @@ namespace ExternalCommand { buttonOk.Enabled = true; textBox_name.BackColor = Color.White; textBox_commandline.BackColor = Color.White; - textBox_arguments.BackColor = Color.White; + textBox_arguments.BackColor = Color.White; // Is there a text in the name field if(string.IsNullOrEmpty(textBox_name.Text)) { buttonOk.Enabled = false; @@ -136,17 +136,17 @@ namespace ExternalCommand { } // Are the arguments in a valid format? try - { + { string arguments = FilenameHelper.FillVariables(textBox_arguments.Text, false); arguments = FilenameHelper.FillCmdVariables(arguments, false); ExternalCommandDestination.FormatArguments(arguments, string.Empty); - } - catch - { - buttonOk.Enabled = false; - textBox_arguments.BackColor = Color.Red; - } + } + catch + { + buttonOk.Enabled = false; + textBox_arguments.BackColor = Color.Red; + } } private void textBox_name_TextChanged(object sender, EventArgs e) { @@ -157,10 +157,10 @@ namespace ExternalCommand { OkButtonState(); } - private void textBox_arguments_TextChanged(object sender, EventArgs e) - { - OkButtonState(); - } + private void textBox_arguments_TextChanged(object sender, EventArgs e) + { + OkButtonState(); + } } } diff --git a/GreenshotImgurPlugin/Forms/ImgurHistory.cs b/GreenshotImgurPlugin/Forms/ImgurHistory.cs index 18a732fc0..e8a8d4cba 100644 --- a/GreenshotImgurPlugin/Forms/ImgurHistory.cs +++ b/GreenshotImgurPlugin/Forms/ImgurHistory.cs @@ -200,8 +200,8 @@ namespace GreenshotImgurPlugin { listview_imgur_uploads.Sort(); } - - void ImgurHistoryFormClosing(object sender, FormClosingEventArgs e) + + private void ImgurHistoryFormClosing(object sender, FormClosingEventArgs e) { _instance = null; } diff --git a/GreenshotImgurPlugin/Forms/SettingsForm.cs b/GreenshotImgurPlugin/Forms/SettingsForm.cs index b2d678478..dcf17fbf5 100644 --- a/GreenshotImgurPlugin/Forms/SettingsForm.cs +++ b/GreenshotImgurPlugin/Forms/SettingsForm.cs @@ -41,8 +41,8 @@ namespace GreenshotImgurPlugin { historyButton.Enabled = false; } } - - void ButtonHistoryClick(object sender, EventArgs e) { + + private void ButtonHistoryClick(object sender, EventArgs e) { ImgurHistory.ShowHistory(); } } diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj index cc52a7b68..bb3f82676 100644 --- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj +++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj @@ -34,12 +34,12 @@ - - ..\packages\Dapplo.HttpExtensions.0.5.33\lib\net45\Dapplo.HttpExtensions.dll + + ..\packages\Dapplo.HttpExtensions.0.5.36\lib\net45\Dapplo.HttpExtensions.dll True - - ..\packages\Dapplo.Jira.0.1.59\lib\net45\Dapplo.Jira.dll + + ..\packages\Dapplo.Jira.0.1.61\lib\net45\Dapplo.Jira.dll True diff --git a/GreenshotJiraPlugin/packages.config b/GreenshotJiraPlugin/packages.config index 58ee11d6b..bd1287f70 100644 --- a/GreenshotJiraPlugin/packages.config +++ b/GreenshotJiraPlugin/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/GreenshotOCRPlugin/SettingsForm.cs b/GreenshotOCRPlugin/SettingsForm.cs index a9782d256..871da209e 100644 --- a/GreenshotOCRPlugin/SettingsForm.cs +++ b/GreenshotOCRPlugin/SettingsForm.cs @@ -53,8 +53,8 @@ namespace GreenshotOCR { index++; } } - - void ButtonOKClick(object sender, EventArgs e) { + + private void ButtonOKClick(object sender, EventArgs e) { string selectedString = (string) comboBox_languages.SelectedItem; if (selectedString != null) { config.Language = selectedString.ToUpper(); diff --git a/GreenshotOfficePlugin/OfficeInterop/OutlookUtils.cs b/GreenshotOfficePlugin/OfficeInterop/OutlookUtils.cs index 4a5f64b71..c0a85b341 100644 --- a/GreenshotOfficePlugin/OfficeInterop/OutlookUtils.cs +++ b/GreenshotOfficePlugin/OfficeInterop/OutlookUtils.cs @@ -22,7 +22,7 @@ using System; using System.Runtime.InteropServices; namespace Greenshot.Interop.Office { - enum PT : uint { + internal enum PT : uint { PT_UNSPECIFIED = 0, /* (Reserved for interface use) type doesn't matter to caller */ PT_NULL = 1, /* NULL property value */ PT_I2 = 2, /* Signed 16-bit value */ @@ -470,7 +470,7 @@ namespace Greenshot.Interop.Office { [ComImport()] [Guid(IID_IMAPIProp)] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - interface IMessage : IMAPIProp { + private interface IMessage : IMAPIProp { [return: MarshalAs(UnmanagedType.I4)] [PreserveSig] int GetAttachmentTable(); @@ -558,7 +558,7 @@ namespace Greenshot.Interop.Office { [ComImport()] [Guid(IID_IMAPIProp)] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] - interface IMAPIProp { + private interface IMAPIProp { [return: MarshalAs(UnmanagedType.I4)] [PreserveSig] int GetLastError(); diff --git a/GreenshotPlugin/Controls/AnimatingForm.cs b/GreenshotPlugin/Controls/AnimatingForm.cs index f3765e9c9..c1e6bedc3 100644 --- a/GreenshotPlugin/Controls/AnimatingForm.cs +++ b/GreenshotPlugin/Controls/AnimatingForm.cs @@ -110,7 +110,7 @@ namespace GreenshotPlugin.Controls { /// /// /// - void timer_Tick(object sender, EventArgs e) { + private void timer_Tick(object sender, EventArgs e) { try { Animate(); } catch (Exception ex) { diff --git a/GreenshotPlugin/Controls/BackgroundForm.cs b/GreenshotPlugin/Controls/BackgroundForm.cs index 5994f4f2d..59fe024e3 100644 --- a/GreenshotPlugin/Controls/BackgroundForm.cs +++ b/GreenshotPlugin/Controls/BackgroundForm.cs @@ -92,8 +92,8 @@ namespace GreenshotPlugin.Controls { _shouldClose = true; Application.DoEvents(); } - - void BackgroundFormFormClosing(object sender, FormClosingEventArgs e) { + + private void BackgroundFormFormClosing(object sender, FormClosingEventArgs e) { timer_checkforclose.Stop(); } } diff --git a/GreenshotPlugin/Controls/ExtendedWebBrowser.cs b/GreenshotPlugin/Controls/ExtendedWebBrowser.cs index 8b8b886ad..5fae94edd 100644 --- a/GreenshotPlugin/Controls/ExtendedWebBrowser.cs +++ b/GreenshotPlugin/Controls/ExtendedWebBrowser.cs @@ -25,14 +25,14 @@ using GreenshotInterop.Interop; namespace GreenshotPlugin.Controls { public class ExtendedWebBrowser : WebBrowser { protected class ExtendedWebBrowserSite : WebBrowserSite, IOleCommandTarget { - const int OLECMDID_SHOWSCRIPTERROR = 40; - const int OLECMDID_SHOWMESSAGE = 41; + private const int OLECMDID_SHOWSCRIPTERROR = 40; + private const int OLECMDID_SHOWMESSAGE = 41; - static readonly Guid CGID_DocHostCommandHandler = new Guid("F38BC242-B950-11D1-8918-00C04FC2C836"); + private static readonly Guid CGID_DocHostCommandHandler = new Guid("F38BC242-B950-11D1-8918-00C04FC2C836"); - const int S_OK = 0; - const int OLECMDERR_E_NOTSUPPORTED = (-2147221248); - const int OLECMDERR_E_UNKNOWNGROUP = (-2147221244); + private const int S_OK = 0; + private const int OLECMDERR_E_NOTSUPPORTED = (-2147221248); + private const int OLECMDERR_E_UNKNOWNGROUP = (-2147221244); public ExtendedWebBrowserSite(WebBrowser wb) : base(wb) { } diff --git a/GreenshotPlugin/Controls/HotkeyControl.cs b/GreenshotPlugin/Controls/HotkeyControl.cs index ac9becaab..fb9674ec8 100644 --- a/GreenshotPlugin/Controls/HotkeyControl.cs +++ b/GreenshotPlugin/Controls/HotkeyControl.cs @@ -201,7 +201,7 @@ namespace GreenshotPlugin.Controls { /// Fires when a key is pushed down. Here, we'll want to update the text in the box /// to notify the user what combination is currently pressed. /// - void HotkeyControl_KeyDown(object sender, KeyEventArgs e) { + private void HotkeyControl_KeyDown(object sender, KeyEventArgs e) { // Clear the current hotkey if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete) { ResetHotkey(); @@ -217,7 +217,7 @@ namespace GreenshotPlugin.Controls { /// Fires when all keys are released. If the current hotkey isn't valid, reset it. /// Otherwise, do nothing and keep the text and hotkey as it was. /// - void HotkeyControl_KeyUp(object sender, KeyEventArgs e) { + private void HotkeyControl_KeyUp(object sender, KeyEventArgs e) { // Somehow the PrintScreen only comes as a keyup, therefore we handle it here. if (e.KeyCode == Keys.PrintScreen) { _modifiers = e.Modifiers; @@ -235,7 +235,7 @@ namespace GreenshotPlugin.Controls { /// Prevents the letter/whatever entered to show up in the TextBox /// Without this, a "A" key press would appear as "aControl, Alt + A" /// - void HotkeyControl_KeyPress(object sender, KeyPressEventArgs e) { + private void HotkeyControl_KeyPress(object sender, KeyPressEventArgs e) { e.Handled = true; } diff --git a/GreenshotPlugin/Controls/PleaseWaitForm.cs b/GreenshotPlugin/Controls/PleaseWaitForm.cs index 2146a6247..3556af50b 100644 --- a/GreenshotPlugin/Controls/PleaseWaitForm.cs +++ b/GreenshotPlugin/Controls/PleaseWaitForm.cs @@ -115,7 +115,7 @@ namespace GreenshotPlugin.Controls { /// /// /// - void CancelButtonClick(object sender, EventArgs e) { + private void CancelButtonClick(object sender, EventArgs e) { LOG.DebugFormat("Cancel clicked on {0}", _title); cancelButton.Enabled = false; _waitFor.Abort(); diff --git a/GreenshotPlugin/Controls/QualityDialog.cs b/GreenshotPlugin/Controls/QualityDialog.cs index dc8a75f99..43029ed62 100644 --- a/GreenshotPlugin/Controls/QualityDialog.cs +++ b/GreenshotPlugin/Controls/QualityDialog.cs @@ -48,8 +48,8 @@ namespace GreenshotPlugin.Controls { textBoxJpegQuality.Text = Settings.JPGQuality.ToString(); ToFront = true; } - - void Button_okClick(object sender, EventArgs e) { + + private void Button_okClick(object sender, EventArgs e) { Settings.JPGQuality = trackBarJpegQuality.Value; Settings.ReduceColors = checkBox_reduceColors.Checked; if (checkbox_dontaskagain.Checked) { @@ -59,8 +59,8 @@ namespace GreenshotPlugin.Controls { IniConfig.Save(); } } - - void TrackBarJpegQualityScroll(object sender, EventArgs e) { + + private void TrackBarJpegQualityScroll(object sender, EventArgs e) { textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString(); } } diff --git a/GreenshotPlugin/Core/AnimationHelpers.cs b/GreenshotPlugin/Core/AnimationHelpers.cs index b63412632..f34fb04ab 100644 --- a/GreenshotPlugin/Core/AnimationHelpers.cs +++ b/GreenshotPlugin/Core/AnimationHelpers.cs @@ -519,7 +519,7 @@ namespace GreenshotPlugin.Core { throw new NotImplementedException(); } - static class Sine { + private static class Sine { public static double EaseIn(double s) { return Math.Sin(s * (Math.PI / 2) - (Math.PI / 2)) + 1; } @@ -531,7 +531,7 @@ namespace GreenshotPlugin.Core { } } - static class Power { + private static class Power { public static double EaseIn(double s, int power) { return Math.Pow(s, power); } diff --git a/GreenshotPlugin/Core/ImageHelper.cs b/GreenshotPlugin/Core/ImageHelper.cs index e0193a71b..44e0fd7b6 100644 --- a/GreenshotPlugin/Core/ImageHelper.cs +++ b/GreenshotPlugin/Core/ImageHelper.cs @@ -490,7 +490,7 @@ namespace GreenshotPlugin.Core { /// Bitmap public static Image ApplyEffect(Image sourceImage, IEffect effect, Matrix matrix) { - List effects = new List { effect }; + var effects = new List { effect }; return ApplyEffects(sourceImage, effects, matrix); } @@ -501,13 +501,13 @@ namespace GreenshotPlugin.Core { /// List of IEffect /// /// Bitmap - public static Image ApplyEffects(Image sourceImage, List effects, Matrix matrix) + public static Image ApplyEffects(Image sourceImage, IEnumerable effects, Matrix matrix) { - Image currentImage = sourceImage; + var currentImage = sourceImage; bool disposeImage = false; - foreach (IEffect effect in effects) + foreach (var effect in effects) { - Image tmpImage = effect.Apply(currentImage, matrix); + var tmpImage = effect.Apply(currentImage, matrix); if (tmpImage != null) { if (disposeImage) @@ -515,7 +515,6 @@ namespace GreenshotPlugin.Core { currentImage.Dispose(); } currentImage = tmpImage; - tmpImage = null; // Make sure the "new" image is disposed disposeImage = true; } @@ -549,7 +548,7 @@ namespace GreenshotPlugin.Core { public static Image CreateTornEdge(Image sourceImage, int toothHeight, int horizontalToothRange, int verticalToothRange, bool[] edges) { Image returnImage = CreateEmpty(sourceImage.Width, sourceImage.Height, PixelFormat.Format32bppArgb, Color.Empty, sourceImage.HorizontalResolution, sourceImage.VerticalResolution); - using (GraphicsPath path = new GraphicsPath()) + using (var path = new GraphicsPath()) { Random random = new Random(); int horizontalRegions = (int)Math.Round((float)sourceImage.Width / horizontalToothRange); diff --git a/GreenshotPlugin/Core/WindowsHelper.cs b/GreenshotPlugin/Core/WindowsHelper.cs index 71db3675f..fb7624bbf 100644 --- a/GreenshotPlugin/Core/WindowsHelper.cs +++ b/GreenshotPlugin/Core/WindowsHelper.cs @@ -780,7 +780,7 @@ namespace GreenshotPlugin.Core { } if (windowRect.IsEmpty) { - if (GetWindowRect(out windowRect)) + if (!GetWindowRect(out windowRect)) { Win32Error error = Win32.GetLastErrorCode(); Log.WarnFormat("Couldn't retrieve the windows rectangle: {0}", Win32.GetMessage(error)); diff --git a/GreenshotPlugin/Interop/COMWrapper.cs b/GreenshotPlugin/Interop/COMWrapper.cs index ff9693a8e..243180939 100644 --- a/GreenshotPlugin/Interop/COMWrapper.cs +++ b/GreenshotPlugin/Interop/COMWrapper.cs @@ -64,10 +64,10 @@ namespace Greenshot.Interop { #endregion [DllImport("ole32.dll")] - static extern int ProgIDFromCLSID([In] ref Guid clsid, [MarshalAs(UnmanagedType.LPWStr)] out string lplpszProgId); + private static extern int ProgIDFromCLSID([In] ref Guid clsid, [MarshalAs(UnmanagedType.LPWStr)] out string lplpszProgId); // Converts failure HRESULTs to exceptions: [DllImport("oleaut32", PreserveSig=false)] - static extern void GetActiveObject(ref Guid rclsid, IntPtr pvReserved, [MarshalAs(UnmanagedType.IUnknown)] out object ppunk); + private static extern void GetActiveObject(ref Guid rclsid, IntPtr pvReserved, [MarshalAs(UnmanagedType.IUnknown)] out object ppunk); #region Construction diff --git a/GreenshotPlugin/UnmanagedHelpers/Win32Errors.cs b/GreenshotPlugin/UnmanagedHelpers/Win32Errors.cs index 25480d7eb..01e435daa 100644 --- a/GreenshotPlugin/UnmanagedHelpers/Win32Errors.cs +++ b/GreenshotPlugin/UnmanagedHelpers/Win32Errors.cs @@ -90,7 +90,7 @@ namespace GreenshotPlugin.UnmanagedHelpers { public static class Win32 { [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] - static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, [Out] StringBuilder lpBuffer, int nSize, IntPtr Arguments); + private static extern uint FormatMessage(uint dwFlags, IntPtr lpSource, uint dwMessageId, uint dwLanguageId, [Out] StringBuilder lpBuffer, int nSize, IntPtr Arguments); [DllImport("kernel32.dll")] public static extern void SetLastError(uint dwErrCode);