BUG-1908: Made Greenshot recheck & add the external commands like Ms-Paint and Paint.NET if they are not deleted manually and not yet available. Also cleaned up some code.

This commit is contained in:
Robin 2016-09-16 21:48:57 +02:00
parent 35ed3b8d60
commit 6efc7796b8
49 changed files with 322 additions and 294 deletions

View file

@ -41,7 +41,7 @@ namespace Greenshot.Controls {
CheckedChanged += BindableToolStripButton_CheckedChanged; 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")); if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Checked"));
} }
} }

View file

@ -41,7 +41,7 @@ namespace Greenshot.Controls {
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged; SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
} }
void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) {
if(PropertyChanged != null) { if(PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem")); PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem"));

View file

@ -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 colorDialog = ColorDialog.GetInstance();
colorDialog.Color = SelectedColor; colorDialog.Color = SelectedColor;
// Using the parent to make sure the dialog doesn't show on another window // Using the parent to make sure the dialog doesn't show on another window

View file

@ -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) // DrawBackground handles drawing the background (i.e,. hot-tracked v. not)
// It uses the system colors (Bluish, and and white, by default) // It uses the system colors (Bluish, and and white, by default)
// same as calling e.Graphics.FillRectangle ( SystemBrushes.Highlight, e.Bounds ); // 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) { if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs("Text")); PropertyChanged(this, new PropertyChangedEventArgs("Text"));
PropertyChanged(this, new PropertyChangedEventArgs("FontFamily")); PropertyChanged(this, new PropertyChangedEventArgs("FontFamily"));

View file

@ -29,7 +29,7 @@ namespace Greenshot.Controls {
public class MenuStripEx : MenuStrip { public class MenuStripEx : MenuStrip {
private const int WM_MOUSEACTIVATE = 0x21; private const int WM_MOUSEACTIVATE = 0x21;
enum NativeConstants : uint { private enum NativeConstants : uint {
MA_ACTIVATE = 1, MA_ACTIVATE = 1,
MA_ACTIVATEANDEAT = 2, MA_ACTIVATEANDEAT = 2,
} }

View file

@ -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 colorDialog = ColorDialog.GetInstance();
colorDialog.Color = SelectedColor; colorDialog.Color = SelectedColor;
// Using the parent to make sure the dialog doesn't show on another window // Using the parent to make sure the dialog doesn't show on another window

View file

@ -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. /// 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 /// See: http://blogs.msdn.com/b/rickbrew/archive/2006/01/09/511003.aspx
/// </summary> /// </summary>
class ToolStripEx : ToolStrip { internal class ToolStripEx : ToolStrip {
private const int WM_MOUSEACTIVATE = 0x21; private const int WM_MOUSEACTIVATE = 0x21;
enum NativeConstants : uint { private enum NativeConstants : uint {
MA_ACTIVATE = 1, MA_ACTIVATE = 1,
MA_ACTIVATEANDEAT = 2, MA_ACTIVATEANDEAT = 2,
} }

View file

@ -34,8 +34,7 @@ namespace Greenshot.Drawing.Fields
[Serializable()] [Serializable()]
public abstract class AbstractFieldHolderWithChildren : AbstractFieldHolder public abstract class AbstractFieldHolderWithChildren : AbstractFieldHolder
{ {
private FieldChangedEventHandler fieldChangedEventHandler;
FieldChangedEventHandler fieldChangedEventHandler;
[NonSerialized] [NonSerialized]
private EventHandler childrenChanged; private EventHandler childrenChanged;

View file

@ -47,7 +47,7 @@ namespace Greenshot.Drawing.Fields
private IDrawableContainerList boundContainers; private IDrawableContainerList boundContainers;
private bool internalUpdateRunning = false; 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 readonly ILog LOG = LogManager.GetLogger(typeof(FieldAggregator));
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>(); private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();

View file

@ -1169,7 +1169,7 @@ namespace Greenshot.Drawing
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void SurfaceMouseDown(object sender, MouseEventArgs e) private void SurfaceMouseDown(object sender, MouseEventArgs e)
{ {
// Handle Adorners // Handle Adorners
@ -1261,7 +1261,7 @@ namespace Greenshot.Drawing
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void SurfaceMouseUp(object sender, MouseEventArgs e) private void SurfaceMouseUp(object sender, MouseEventArgs e)
{ {
// Handle Adorners // Handle Adorners
@ -1350,7 +1350,7 @@ namespace Greenshot.Drawing
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void SurfaceMouseMove(object sender, MouseEventArgs e) private void SurfaceMouseMove(object sender, MouseEventArgs e)
{ {
// Handle Adorners // Handle Adorners
var adorner = FindActiveAdorner(e); var adorner = FindActiveAdorner(e);
@ -1417,7 +1417,7 @@ namespace Greenshot.Drawing
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void SurfaceDoubleClick(object sender, MouseEventArgs e) private void SurfaceDoubleClick(object sender, MouseEventArgs e)
{ {
selectedElements.OnDoubleClick(); selectedElements.OnDoubleClick();
selectedElements.Invalidate(); selectedElements.Invalidate();
@ -1459,7 +1459,7 @@ namespace Greenshot.Drawing
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="paintEventArgs">PaintEventArgs</param> /// <param name="paintEventArgs">PaintEventArgs</param>
void SurfacePaint(object sender, PaintEventArgs paintEventArgs) private void SurfacePaint(object sender, PaintEventArgs paintEventArgs)
{ {
Graphics targetGraphics = paintEventArgs.Graphics; Graphics targetGraphics = paintEventArgs.Graphics;
Rectangle clipRectangle = paintEventArgs.ClipRectangle; Rectangle clipRectangle = paintEventArgs.ClipRectangle;

View file

@ -116,7 +116,7 @@ namespace Greenshot {
// 18 19 20 21 22 23 // 18 19 20 21 22 23
// The order in which we draw the dots & flow the collors. // The order in which we draw the dots & flow the collors.
readonly List<int> flowOrder = new List<int>() { 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<int> flowOrder = new List<int>() { 4, 3, 2, 1, 0, 5, 6, 7, 8, 9, 10, 14, 15, 18, 19, 20, 21, 22, 23, 16, 17, 13, 12, 11 };
/// <summary> /// <summary>
/// Cleanup all the allocated resources /// Cleanup all the allocated resources
@ -211,7 +211,7 @@ namespace Greenshot {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void LinkLabelClicked(object sender, LinkLabelLinkClickedEventArgs e) { private void LinkLabelClicked(object sender, LinkLabelLinkClickedEventArgs e) {
LinkLabel linkLabel = sender as LinkLabel; LinkLabel linkLabel = sender as LinkLabel;
if (linkLabel != null) { if (linkLabel != null) {
try { try {

View file

@ -37,8 +37,8 @@ namespace Greenshot.Forms {
public BugReportForm(string bugText) : this() { public BugReportForm(string bugText) : this() {
textBoxDescription.Text = bugText; textBoxDescription.Text = bugText;
} }
void LinkLblBugsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { private void LinkLblBugsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
openLink((LinkLabel)sender); openLink((LinkLabel)sender);
} }

View file

@ -185,7 +185,7 @@ namespace Greenshot.Forms {
/// <summary> /// <summary>
/// Create an animation for the zoomer, depending on if it's active or not. /// Create an animation for the zoomer, depending on if it's active or not.
/// </summary> /// </summary>
void InitializeZoomer(bool isOn) { private void InitializeZoomer(bool isOn) {
if (isOn) { if (isOn) {
// Initialize the zoom with a invalid position // 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); _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 #region key handling
void CaptureFormKeyUp(object sender, KeyEventArgs e) {
private void CaptureFormKeyUp(object sender, KeyEventArgs e) {
switch(e.KeyCode) { switch(e.KeyCode) {
case Keys.ShiftKey: case Keys.ShiftKey:
_fixMode = FixMode.None; _fixMode = FixMode.None;
@ -212,7 +213,7 @@ namespace Greenshot.Forms {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void CaptureFormKeyDown(object sender, KeyEventArgs e) { private void CaptureFormKeyDown(object sender, KeyEventArgs e) {
int step = _isCtrlPressed ? 10 : 1; int step = _isCtrlPressed ? 10 : 1;
switch (e.KeyCode) { switch (e.KeyCode) {
@ -319,7 +320,7 @@ namespace Greenshot.Forms {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void OnMouseDown(object sender, MouseEventArgs e) { private void OnMouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) { if (e.Button == MouseButtons.Left) {
HandleMouseDown(); HandleMouseDown();
} }
@ -360,7 +361,7 @@ namespace Greenshot.Forms {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void OnMouseUp(object sender, MouseEventArgs e) { private void OnMouseUp(object sender, MouseEventArgs e) {
if (_mouseDown) { if (_mouseDown) {
HandleMouseUp(); HandleMouseUp();
} }
@ -392,7 +393,7 @@ namespace Greenshot.Forms {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void OnMouseMove(object sender, MouseEventArgs e) { private void OnMouseMove(object sender, MouseEventArgs e) {
// Make sure the mouse coordinates are fixed, when pressing shift // Make sure the mouse coordinates are fixed, when pressing shift
_mouseMovePos = FixMouseCoordinates(User32.GetCursorLocation()); _mouseMovePos = FixMouseCoordinates(User32.GetCursorLocation());
_mouseMovePos = WindowCapture.GetLocationRelativeToScreenBounds(_mouseMovePos); _mouseMovePos = WindowCapture.GetLocationRelativeToScreenBounds(_mouseMovePos);
@ -704,7 +705,7 @@ namespace Greenshot.Forms {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void OnPaint(object sender, PaintEventArgs e) { private void OnPaint(object sender, PaintEventArgs e) {
Graphics graphics = e.Graphics; Graphics graphics = e.Graphics;
Rectangle clipRectangle = e.ClipRectangle; Rectangle clipRectangle = e.ClipRectangle;
//graphics.BitBlt((Bitmap)buffer, Point.Empty); //graphics.BitBlt((Bitmap)buffer, Point.Empty);

View file

@ -165,7 +165,8 @@ namespace Greenshot {
#endregion #endregion
#region textbox event handlers #region textbox event handlers
void TextBoxHexadecimalTextChanged(object sender, EventArgs e) {
private void TextBoxHexadecimalTextChanged(object sender, EventArgs e) {
if (_updateInProgress) { if (_updateInProgress) {
return; return;
} }
@ -188,7 +189,7 @@ namespace Greenshot {
PreviewColor(opaqueColor, textBox); PreviewColor(opaqueColor, textBox);
} }
void TextBoxRGBTextChanged(object sender, EventArgs e) { private void TextBoxRGBTextChanged(object sender, EventArgs e) {
if (_updateInProgress) { if (_updateInProgress) {
return; return;
} }
@ -196,11 +197,11 @@ namespace Greenshot {
PreviewColor(Color.FromArgb(GetColorPartIntFromString(textBoxAlpha.Text), GetColorPartIntFromString(textBoxRed.Text), GetColorPartIntFromString(textBoxGreen.Text), GetColorPartIntFromString(textBoxBlue.Text)), textBox); 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(); textBoxHtmlColor.SelectAll();
} }
void TextBoxKeyDown(object sender, KeyEventArgs e) { private void TextBoxKeyDown(object sender, KeyEventArgs e) {
if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) { if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) {
AddToRecentColors(colorPanel.BackColor); AddToRecentColors(colorPanel.BackColor);
} }
@ -208,15 +209,17 @@ namespace Greenshot {
#endregion #endregion
#region button event handlers #region button event handlers
void ColorButtonClick(object sender, EventArgs e) {
private void ColorButtonClick(object sender, EventArgs e) {
Button b = (Button)sender; Button b = (Button)sender;
PreviewColor(b.BackColor, b); PreviewColor(b.BackColor, b);
} }
void BtnTransparentClick(object sender, EventArgs e) { private void BtnTransparentClick(object sender, EventArgs e) {
ColorButtonClick(sender, e); ColorButtonClick(sender, e);
} }
void BtnApplyClick(object sender, EventArgs e) {
private void BtnApplyClick(object sender, EventArgs e) {
DialogResult = DialogResult.OK; DialogResult = DialogResult.OK;
Hide(); Hide();
AddToRecentColors(colorPanel.BackColor); AddToRecentColors(colorPanel.BackColor);

View file

@ -78,8 +78,8 @@ namespace Greenshot.Forms {
Close(); Close();
} }
} }
void BtnOKClick(object sender, EventArgs e) { private void BtnOKClick(object sender, EventArgs e) {
properOkPressed = true; properOkPressed = true;
// Fix for Bug #3431100 // Fix for Bug #3431100
Language.CurrentLanguage = SelectedLanguage; Language.CurrentLanguage = SelectedLanguage;

View file

@ -648,24 +648,26 @@ namespace Greenshot {
#region mainform events #region mainform events
void MainFormFormClosing(object sender, FormClosingEventArgs e) {
private void MainFormFormClosing(object sender, FormClosingEventArgs e) {
LOG.DebugFormat("Mainform closing, reason: {0}", e.CloseReason); LOG.DebugFormat("Mainform closing, reason: {0}", e.CloseReason);
_instance = null; _instance = null;
Exit(); Exit();
} }
void MainFormActivated(object sender, EventArgs e) { private void MainFormActivated(object sender, EventArgs e) {
Hide(); Hide();
ShowInTaskbar = false; ShowInTaskbar = false;
} }
#endregion #endregion
#region key handlers #region key handlers
void CaptureRegion() {
private void CaptureRegion() {
CaptureHelper.CaptureRegion(true); CaptureHelper.CaptureRegion(true);
} }
void CaptureFile() { private void CaptureFile() {
var openFileDialog = new OpenFileDialog(); 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"; 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) { if (openFileDialog.ShowDialog() == DialogResult.OK) {
@ -675,21 +677,21 @@ namespace Greenshot {
} }
} }
void CaptureFullScreen() { private void CaptureFullScreen() {
CaptureHelper.CaptureFullscreen(true, _conf.ScreenCaptureMode); CaptureHelper.CaptureFullscreen(true, _conf.ScreenCaptureMode);
} }
void CaptureLastRegion() { private void CaptureLastRegion() {
CaptureHelper.CaptureLastRegion(true); CaptureHelper.CaptureLastRegion(true);
} }
void CaptureIE() { private void CaptureIE() {
if (_conf.IECapture) { if (_conf.IECapture) {
CaptureHelper.CaptureIE(true, null); CaptureHelper.CaptureIE(true, null);
} }
} }
void CaptureWindow() { private void CaptureWindow() {
if (_conf.CaptureWindowsInteractive) { if (_conf.CaptureWindowsInteractive) {
CaptureHelper.CaptureWindowInteractive(true); CaptureHelper.CaptureWindowInteractive(true);
} else { } else {
@ -700,7 +702,8 @@ namespace Greenshot {
#region contextmenu #region contextmenu
void ContextMenuOpening(object sender, CancelEventArgs e) {
private void ContextMenuOpening(object sender, CancelEventArgs e) {
contextmenu_captureclipboard.Enabled = ClipboardHelper.ContainsImage(); contextmenu_captureclipboard.Enabled = ClipboardHelper.ContainsImage();
contextmenu_capturelastregion.Enabled = coreConfiguration.LastCapturedRegion != Rectangle.Empty; contextmenu_capturelastregion.Enabled = coreConfiguration.LastCapturedRegion != Rectangle.Empty;
@ -735,8 +738,8 @@ namespace Greenshot {
contextmenu_donate.Image = (Image)resources.GetObject("contextmenu_present.Image"); 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_captureiefromlist.DropDownItems.Clear();
contextmenu_capturewindowfromlist.DropDownItems.Clear(); contextmenu_capturewindowfromlist.DropDownItems.Clear();
CleanupThumbnail(); CleanupThumbnail();
@ -745,7 +748,7 @@ namespace Greenshot {
/// <summary> /// <summary>
/// Build a selectable list of IE tabs when we enter the menu item /// Build a selectable list of IE tabs when we enter the menu item
/// </summary> /// </summary>
void CaptureIEMenuDropDownOpening(object sender, EventArgs e) { private void CaptureIEMenuDropDownOpening(object sender, EventArgs e) {
if (!_conf.IECapture) { if (!_conf.IECapture) {
return; return;
} }
@ -903,43 +906,43 @@ namespace Greenshot {
} }
} }
void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e) { private void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
CaptureHelper.CaptureRegion(false); CaptureHelper.CaptureRegion(false);
}); });
} }
void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e) { private void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
CaptureHelper.CaptureClipboard(); CaptureHelper.CaptureClipboard();
}); });
} }
void OpenFileToolStripMenuItemClick(object sender, EventArgs e) { private void OpenFileToolStripMenuItemClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
CaptureFile(); CaptureFile();
}); });
} }
void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e) { private void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
CaptureHelper.CaptureFullscreen(false, _conf.ScreenCaptureMode); CaptureHelper.CaptureFullscreen(false, _conf.ScreenCaptureMode);
}); });
} }
void Contextmenu_capturelastregionClick(object sender, EventArgs e) { private void Contextmenu_capturelastregionClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
CaptureHelper.CaptureLastRegion(false); CaptureHelper.CaptureLastRegion(false);
}); });
} }
void Contextmenu_capturewindow_Click(object sender,EventArgs e) { private void Contextmenu_capturewindow_Click(object sender,EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
CaptureHelper.CaptureWindowInteractive(false); CaptureHelper.CaptureWindowInteractive(false);
}); });
} }
void Contextmenu_capturewindowfromlist_Click(object sender,EventArgs e) { private void Contextmenu_capturewindowfromlist_Click(object sender,EventArgs e) {
ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender; ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
try { 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(); CaptureIE();
} }
void Contextmenu_captureiefromlist_Click(object sender, EventArgs e) { private void Contextmenu_captureiefromlist_Click(object sender, EventArgs e) {
if (!_conf.IECapture) { if (!_conf.IECapture) {
LOG.InfoFormat("IE Capture is disabled."); LOG.InfoFormat("IE Capture is disabled.");
return; return;
@ -985,7 +988,7 @@ namespace Greenshot {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void Contextmenu_donateClick(object sender, EventArgs e) { private void Contextmenu_donateClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
Process.Start("http://getgreenshot.org/support/"); Process.Start("http://getgreenshot.org/support/");
}); });
@ -996,7 +999,7 @@ namespace Greenshot {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void Contextmenu_settingsClick(object sender, EventArgs e) { private void Contextmenu_settingsClick(object sender, EventArgs e) {
BeginInvoke((MethodInvoker)delegate { BeginInvoke((MethodInvoker)delegate {
ShowSetting(); ShowSetting();
}); });
@ -1026,7 +1029,7 @@ namespace Greenshot {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void Contextmenu_aboutClick(object sender, EventArgs e) { private void Contextmenu_aboutClick(object sender, EventArgs e) {
ShowAbout(); ShowAbout();
} }
@ -1049,7 +1052,7 @@ namespace Greenshot {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void Contextmenu_helpClick(object sender, EventArgs e) { private void Contextmenu_helpClick(object sender, EventArgs e) {
HelpFileLoader.LoadHelp(); HelpFileLoader.LoadHelp();
} }
@ -1058,7 +1061,7 @@ namespace Greenshot {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void Contextmenu_exitClick(object sender, EventArgs e) { private void Contextmenu_exitClick(object sender, EventArgs e) {
Exit(); Exit();
} }
@ -1150,8 +1153,8 @@ namespace Greenshot {
contextmenu_quicksettings.DropDownItems.Add(selectList); contextmenu_quicksettings.DropDownItems.Add(selectList);
} }
} }
void QuickSettingCaptureModeChanged(object sender, EventArgs e) { private void QuickSettingCaptureModeChanged(object sender, EventArgs e) {
ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item; ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item;
WindowCaptureMode windowsCaptureMode = (WindowCaptureMode)item.Data; WindowCaptureMode windowsCaptureMode = (WindowCaptureMode)item.Data;
if (item.Checked) { 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; ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item;
IniValue iniValue = item.Data as IniValue; IniValue iniValue = item.Data as IniValue;
if (iniValue != null) { 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; ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item;
IDestination selectedDestination = (IDestination)item.Data; IDestination selectedDestination = (IDestination)item.Data;
if (item.Checked) { if (item.Checked) {

View file

@ -34,9 +34,9 @@ namespace Greenshot.Forms {
InitializeComponent(); InitializeComponent();
checkbox_dontaskagain.Checked = false; checkbox_dontaskagain.Checked = false;
} }
void Button_okClick(object sender, EventArgs e) { private void Button_okClick(object sender, EventArgs e) {
// update config // update config
coreConfiguration.OutputPrintPromptOptions = !checkbox_dontaskagain.Checked; coreConfiguration.OutputPrintPromptOptions = !checkbox_dontaskagain.Checked;
IniConfig.Save(); IniConfig.Save();

View file

@ -467,12 +467,12 @@ namespace Greenshot {
LOG.Warn("Problem checking registry, ignoring for now: ", e); 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; DialogResult = DialogResult.Cancel;
} }
void Settings_okayClick(object sender, EventArgs e) { private void Settings_okayClick(object sender, EventArgs e) {
if (CheckSettings()) { if (CheckSettings()) {
HotkeyControl.UnregisterHotkeys(); HotkeyControl.UnregisterHotkeys();
SaveSettings(); SaveSettings();
@ -486,8 +486,8 @@ namespace Greenshot {
tabcontrol.SelectTab(tab_output); 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 // Get the storage location and replace the environment variables
folderBrowserDialog1.SelectedPath = FilenameHelper.FillVariables(textbox_storagelocation.Text, false); folderBrowserDialog1.SelectedPath = FilenameHelper.FillVariables(textbox_storagelocation.Text, false);
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { 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); 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); string filenamepatternText = Language.GetString(LangKey.settings_message_filenamepattern);
// Convert %NUM% to ${NUM} for old language files! // Convert %NUM% to ${NUM} for old language files!
filenamepatternText = Regex.Replace(filenamepatternText, "%([a-zA-Z_0-9]+)%", @"${$1}"); filenamepatternText = Regex.Replace(filenamepatternText, "%([a-zA-Z_0-9]+)%", @"${$1}");
MessageBox.Show(filenamepatternText, Language.GetString(LangKey.settings_filenamepattern)); 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); 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); 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 // Get the combobox values BEFORE changing the language
//EmailFormat selectedEmailFormat = GetSelected<EmailFormat>(combobox_emailformat); //EmailFormat selectedEmailFormat = GetSelected<EmailFormat>(combobox_emailformat);
WindowCaptureMode selectedWindowCaptureMode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode); WindowCaptureMode selectedWindowCaptureMode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode);
@ -536,8 +536,8 @@ namespace Greenshot {
//SetEmailFormat(selectedEmailFormat); //SetEmailFormat(selectedEmailFormat);
SetWindowCaptureMode(selectedWindowCaptureMode); 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; int windowsVersion = Environment.OSVersion.Version.Major;
WindowCaptureMode mode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode); WindowCaptureMode mode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode);
if (windowsVersion >= 6) { if (windowsVersion >= 6) {
@ -553,7 +553,7 @@ namespace Greenshot {
/// <summary> /// <summary>
/// Check the destination settings /// Check the destination settings
/// </summary> /// </summary>
void CheckDestinationSettings() { private void CheckDestinationSettings() {
bool clipboardDestinationChecked = false; bool clipboardDestinationChecked = false;
bool pickerSelected = checkbox_picker.Checked; bool pickerSelected = checkbox_picker.Checked;
bool destinationsEnabled = true; bool destinationsEnabled = true;
@ -588,7 +588,7 @@ namespace Greenshot {
} }
} }
void DestinationsCheckStateChanged(object sender, EventArgs e) { private void DestinationsCheckStateChanged(object sender, EventArgs e) {
CheckDestinationSettings(); CheckDestinationSettings();
} }

View file

@ -32,7 +32,7 @@ namespace Greenshot {
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; 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; Assembly ayResult = null;
string sShortAssemblyName = args.Name.Split(',')[0]; string sShortAssemblyName = args.Name.Split(',')[0];
Assembly[] ayAssemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] ayAssemblies = AppDomain.CurrentDomain.GetAssemblies();

View file

@ -155,7 +155,7 @@ namespace Greenshot.Helpers {
return ret; return ret;
} }
void DrawImageForPrint(object sender, PrintPageEventArgs e) { private void DrawImageForPrint(object sender, PrintPageEventArgs e) {
// Create the output settins // Create the output settins

View file

@ -29,7 +29,7 @@ namespace Greenshot.Helpers {
/// </summary> /// </summary>
public static class ToolStripItemEndisabler { public static class ToolStripItemEndisabler {
[Flags] [Flags]
enum PropagationMode {NONE=0, CHILDREN=1, ANCESTORS=2}; private enum PropagationMode {NONE=0, CHILDREN=1, ANCESTORS=2};
/// <summary> /// <summary>
/// Enables all of a ToolStrip's children (recursively), /// Enables all of a ToolStrip's children (recursively),

View file

@ -31,9 +31,9 @@ namespace Greenshot.Memento
/// </summary> /// </summary>
public class DrawableContainerBoundsChangeMemento : IMemento public class DrawableContainerBoundsChangeMemento : IMemento
{ {
List<Point> points = new List<Point>(); private List<Point> points = new List<Point>();
List<Size> sizes = new List<Size>(); private List<Size> sizes = new List<Size>();
IDrawableContainerList listOfdrawableContainer; private IDrawableContainerList listOfdrawableContainer;
private void StoreBounds() private void StoreBounds()
{ {

View file

@ -38,8 +38,8 @@ namespace GreenshotConfluencePlugin {
this.config = config; this.config = config;
InitializeComponent(); InitializeComponent();
} }
void Button_OK_Click(object sender, RoutedEventArgs e) { private void Button_OK_Click(object sender, RoutedEventArgs e) {
DialogResult = true; DialogResult = true;
} }
} }

View file

@ -35,12 +35,12 @@ namespace GreenshotConfluencePlugin {
DataContext = pagesToPick; DataContext = pagesToPick;
InitializeComponent(); InitializeComponent();
} }
void PageListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { private void PageListView_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) {
SelectionChanged(); SelectionChanged();
} }
void SelectionChanged() { private void SelectionChanged() {
if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) { if (PageListView.HasItems && PageListView.SelectedItems.Count > 0) {
confluenceUpload.SelectedPage = (Page)PageListView.SelectedItem; confluenceUpload.SelectedPage = (Page)PageListView.SelectedItem;
// Make sure the uploader knows we selected an already opened page // Make sure the uploader knows we selected an already opened page
@ -49,8 +49,8 @@ namespace GreenshotConfluencePlugin {
confluenceUpload.SelectedPage = null; confluenceUpload.SelectedPage = null;
} }
} }
void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) { private void Page_Loaded(object sender, System.Windows.RoutedEventArgs e) {
SelectionChanged(); SelectionChanged();
} }
} }

View file

@ -110,8 +110,8 @@ namespace GreenshotConfluencePlugin {
SearchTab.IsSelected = true; SearchTab.IsSelected = true;
} }
} }
void UpdateSpaces() { private void UpdateSpaces() {
if (_spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(_lastLoad) > 0) { if (_spaces != null && DateTime.Now.AddMinutes(-60).CompareTo(_lastLoad) > 0) {
// Reset // Reset
_spaces = null; _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; DialogResult = true;
} }
} }

View file

@ -24,7 +24,7 @@ using Greenshot.IniFile;
using Greenshot.Plugin; using Greenshot.Plugin;
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
namespace GreenshotDropboxPlugin { namespace GreenshotDropboxPlugin {
class DropboxDestination : AbstractDestination { internal class DropboxDestination : AbstractDestination {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxDestination)); private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DropboxDestination));
private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>(); private static readonly DropboxPluginConfiguration config = IniConfig.GetIniSection<DropboxPluginConfiguration>();

View file

@ -52,28 +52,85 @@ namespace ExternalCommand {
public bool UriToClipboard { get; set; } public bool UriToClipboard { get; set; }
[IniProperty("Commandline", Description="The commandline for the output command.")] [IniProperty("Commandline", Description="The commandline for the output command.")]
public Dictionary<string, string> commandlines { get; set; } public Dictionary<string, string> Commandline { get; set; }
[IniProperty("Argument", Description="The arguments for the output command.")] [IniProperty("Argument", Description="The arguments for the output command.")]
public Dictionary<string, string> arguments { get; set; } public Dictionary<string, string> Argument { get; set; }
[IniProperty("RunInbackground", Description = "Should the command be started in the background.")] [IniProperty("RunInbackground", Description = "Should the command be started in the background.")]
public Dictionary<string, bool> runInbackground { get; set; } public Dictionary<string, bool> RunInbackground { get; set; }
private const string MSPAINT = "MS Paint"; [IniProperty("DeletedBuildInCommands", Description = "If a build in command was deleted manually, it should not be recreated.")]
private static readonly string paintPath; public List<string> DeletedBuildInCommands { get; set; }
private static readonly bool hasPaint = false;
private const string PAINTDOTNET = "Paint.NET"; private const string MsPaint = "MS Paint";
private static readonly string paintDotNetPath; private static readonly string PaintPath;
private static readonly bool hasPaintDotNet = false; private static readonly bool HasPaint;
private const string PaintDotNet = "Paint.NET";
private static readonly string PaintDotNetPath;
private static readonly bool HasPaintDotNet;
static ExternalCommandConfiguration() { static ExternalCommandConfiguration() {
try { try {
paintPath = PluginUtils.GetExePath("pbrush.exe"); PaintPath = PluginUtils.GetExePath("pbrush.exe");
hasPaint = !string.IsNullOrEmpty(paintPath) && File.Exists(paintPath); 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);
} catch { } catch {
// Ignore
}
try
{
PaintDotNetPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), @"Paint.NET\PaintDotNet.exe");
HasPaintDotNet = !string.IsNullOrEmpty(PaintDotNetPath) && File.Exists(PaintDotNetPath);
}
catch
{
// Ignore
}
}
/// <summary>
/// Delete the configuration for the specified command
/// </summary>
/// <param name="command">string with command</param>
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 {
/// <returns>object with the default value for the supplied property</returns> /// <returns>object with the default value for the supplied property</returns>
public override object GetDefault(string property) { public override object GetDefault(string property) {
switch(property) { switch(property) {
case "Commands": case nameof(DeletedBuildInCommands):
List<string> commandDefaults = new List<string>(); return new List<string>();
if (hasPaintDotNet) { case nameof(Commands):
commandDefaults.Add(PAINTDOTNET); return new List<string>();
} case nameof(Commandline):
if (hasPaint) { return new Dictionary<string, string>();
commandDefaults.Add(MSPAINT); case nameof(Argument):
} return new Dictionary<string, string>();
return commandDefaults; case nameof(RunInbackground):
case "Commandline": return new Dictionary<string, bool>();
Dictionary<string, string> commandlineDefaults = new Dictionary<string, string>();
if (hasPaintDotNet) {
commandlineDefaults.Add(PAINTDOTNET, paintDotNetPath);
}
if (hasPaint) {
commandlineDefaults.Add(MSPAINT, paintPath);
}
return commandlineDefaults;
case "Argument":
Dictionary<string, string> argumentDefaults = new Dictionary<string, string>();
if (hasPaintDotNet) {
argumentDefaults.Add(PAINTDOTNET, "\"{0}\"");
}
if (hasPaint) {
argumentDefaults.Add(MSPAINT, "\"{0}\"");
}
return argumentDefaults;
case "RunInbackground":
Dictionary<string, bool> runInBackground = new Dictionary<string, bool>();
if (hasPaintDotNet) {
runInBackground.Add(PAINTDOTNET, true);
}
if (hasPaint) {
runInBackground.Add(MSPAINT, true);
}
return runInBackground;
} }
return null; return null;
} }

View file

@ -71,10 +71,10 @@ namespace ExternalCommand {
if (_presetCommand != null) { if (_presetCommand != null) {
if (!config.runInbackground.ContainsKey(_presetCommand)) { if (!config.RunInbackground.ContainsKey(_presetCommand)) {
config.runInbackground.Add(_presetCommand, true); config.RunInbackground.Add(_presetCommand, true);
} }
bool runInBackground = config.runInbackground[_presetCommand]; bool runInBackground = config.RunInbackground[_presetCommand];
string fullPath = captureDetails.Filename; string fullPath = captureDetails.Filename;
if (fullPath == null) { if (fullPath == null) {
fullPath = ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings); fullPath = ImageOutput.SaveNamedTmpFile(surface, captureDetails, outputSettings);
@ -139,7 +139,7 @@ namespace ExternalCommand {
} catch (Exception ex) { } catch (Exception ex) {
exportInformation.ExportMade = false; exportInformation.ExportMade = false;
exportInformation.ErrorMessage = ex.Message; 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 { try {
return CallExternalCommand(commando, fullPath, "runas", out output, out error); return CallExternalCommand(commando, fullPath, "runas", out output, out error);
} catch { } catch {
w32ex.Data.Add("commandline", config.commandlines[_presetCommand]); w32ex.Data.Add("commandline", config.Commandline[_presetCommand]);
w32ex.Data.Add("arguments", config.arguments[_presetCommand]); w32ex.Data.Add("arguments", config.Argument[_presetCommand]);
throw; throw;
} }
} catch (Exception ex) { } catch (Exception ex) {
ex.Data.Add("commandline", config.commandlines[_presetCommand]); ex.Data.Add("commandline", config.Commandline[_presetCommand]);
ex.Data.Add("arguments", config.arguments[_presetCommand]); ex.Data.Add("arguments", config.Argument[_presetCommand]);
throw; throw;
} }
} }
@ -179,8 +179,8 @@ namespace ExternalCommand {
/// <param name="error"></param> /// <param name="error"></param>
/// <returns></returns> /// <returns></returns>
private int CallExternalCommand(string commando, string fullPath, string verb, out string output, out string error) { private int CallExternalCommand(string commando, string fullPath, string verb, out string output, out string error) {
string commandline = config.commandlines[commando]; string commandline = config.Commandline[commando];
string arguments = config.arguments[commando]; string arguments = config.Argument[commando];
output = null; output = null;
error = null; error = null;
if (!string.IsNullOrEmpty(commandline)) { if (!string.IsNullOrEmpty(commandline)) {
@ -227,9 +227,9 @@ namespace ExternalCommand {
return -1; return -1;
} }
public static string FormatArguments(string arguments, string fullpath) public static string FormatArguments(string arguments, string fullpath)
{ {
return string.Format(arguments, fullpath); return string.Format(arguments, fullpath);
} }
} }
} }

View file

@ -33,9 +33,9 @@ namespace ExternalCommand {
/// An Plugin to run commands after an image was written /// An Plugin to run commands after an image was written
/// </summary> /// </summary>
public class ExternalCommandPlugin : IGreenshotPlugin { public class ExternalCommandPlugin : IGreenshotPlugin {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin)); private static readonly log4net.ILog Log = log4net.LogManager.GetLogger(typeof(ExternalCommandPlugin));
private static readonly CoreConfiguration coreConfig = IniConfig.GetIniSection<CoreConfiguration>(); private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>(); private static readonly ExternalCommandConfiguration ExternalCommandConfig = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private IGreenshotHost _host; private IGreenshotHost _host;
private PluginAttribute _myAttributes; private PluginAttribute _myAttributes;
private ToolStripMenuItem _itemPlugInRoot; private ToolStripMenuItem _itemPlugInRoot;
@ -55,7 +55,7 @@ namespace ExternalCommand {
} }
public IEnumerable<IDestination> Destinations() { public IEnumerable<IDestination> Destinations() {
foreach(string command in config.Commands) { foreach(string command in ExternalCommandConfig.Commands) {
yield return new ExternalCommandDestination(command); yield return new ExternalCommandDestination(command);
} }
} }
@ -69,26 +69,26 @@ namespace ExternalCommand {
/// </summary> /// </summary>
/// <param name="command"></param> /// <param name="command"></param>
/// <returns>false if the command is not correctly configured</returns> /// <returns>false if the command is not correctly configured</returns>
private bool isCommandValid(string command) { private bool IsCommandValid(string command) {
if (!config.runInbackground.ContainsKey(command)) { if (!ExternalCommandConfig.RunInbackground.ContainsKey(command)) {
LOG.WarnFormat("Found missing runInbackground for {0}", command); Log.WarnFormat("Found missing runInbackground for {0}", command);
// Fix it // Fix it
config.runInbackground.Add(command, true); ExternalCommandConfig.RunInbackground.Add(command, true);
} }
if (!config.arguments.ContainsKey(command)) { if (!ExternalCommandConfig.Argument.ContainsKey(command)) {
LOG.WarnFormat("Found missing argument for {0}", command); Log.WarnFormat("Found missing argument for {0}", command);
// Fix it // Fix it
config.arguments.Add(command, "{0}"); ExternalCommandConfig.Argument.Add(command, "{0}");
} }
if (!config.commandlines.ContainsKey(command)) { if (!ExternalCommandConfig.Commandline.ContainsKey(command)) {
LOG.WarnFormat("Found missing commandline for {0}", command); Log.WarnFormat("Found missing commandline for {0}", command);
return false; return false;
} }
string commandline = FilenameHelper.FillVariables(config.commandlines[command], true); string commandline = FilenameHelper.FillVariables(ExternalCommandConfig.Commandline[command], true);
commandline = FilenameHelper.FillCmdVariables(commandline, true); commandline = FilenameHelper.FillCmdVariables(commandline, true);
if (!File.Exists(commandline)) { 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 false;
} }
return true; return true;
@ -99,22 +99,19 @@ namespace ExternalCommand {
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param> /// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
/// <param name="myAttributes">My own attributes</param> /// <param name="myAttributes">My own attributes</param>
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) { 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<string> commandsToDelete = new List<string>(); List<string> commandsToDelete = new List<string>();
// Check configuration // Check configuration
foreach(string command in config.Commands) { foreach(string command in ExternalCommandConfig.Commands) {
if (!isCommandValid(command)) { if (!IsCommandValid(command)) {
commandsToDelete.Add(command); commandsToDelete.Add(command);
} }
} }
// cleanup // cleanup
foreach (string command in commandsToDelete) { foreach (string command in commandsToDelete) {
config.runInbackground.Remove(command); ExternalCommandConfig.Delete(command);
config.commandlines.Remove(command);
config.arguments.Remove(command);
config.Commands.Remove(command);
} }
_host = pluginHost; _host = pluginHost;
@ -128,7 +125,7 @@ namespace ExternalCommand {
PluginUtils.AddToContextMenu(_host, _itemPlugInRoot); PluginUtils.AddToContextMenu(_host, _itemPlugInRoot);
Language.LanguageChanged += OnLanguageChanged; Language.LanguageChanged += OnLanguageChanged;
coreConfig.PropertyChanged += OnIconSizeChanged; CoreConfig.PropertyChanged += OnIconSizeChanged;
return true; return true;
} }
@ -145,7 +142,7 @@ namespace ExternalCommand {
_itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0); _itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
} }
} catch (Exception ex) { } 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() { public virtual void Shutdown() {
LOG.Debug("Shutdown of " + _myAttributes.Name); Log.Debug("Shutdown of " + _myAttributes.Name);
} }
private void ConfigMenuClick(object sender, EventArgs eventArgs) { private void ConfigMenuClick(object sender, EventArgs eventArgs) {
@ -168,7 +165,7 @@ namespace ExternalCommand {
/// Implementation of the IPlugin.Configure /// Implementation of the IPlugin.Configure
/// </summary> /// </summary>
public virtual void Configure() { public virtual void Configure() {
LOG.Debug("Configure called"); Log.Debug("Configure called");
new SettingsForm().ShowDialog(); new SettingsForm().ShowDialog();
} }
} }

View file

@ -33,11 +33,11 @@ namespace ExternalCommand {
public static Image IconForCommand(string commandName) { public static Image IconForCommand(string commandName) {
Image icon = null; Image icon = null;
if (commandName != 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 { try {
icon = PluginUtils.GetCachedExeIcon(config.commandlines[commandName], 0); icon = PluginUtils.GetCachedExeIcon(config.Commandline[commandName], 0);
} catch (Exception ex) { } catch (Exception ex) {
LOG.Warn("Problem loading icon for " + config.commandlines[commandName], ex); LOG.Warn("Problem loading icon for " + config.Commandline[commandName], ex);
} }
} }
} }

View file

@ -29,8 +29,7 @@ namespace ExternalCommand {
/// Description of SettingsForm. /// Description of SettingsForm.
/// </summary> /// </summary>
public partial class SettingsForm : ExternalCommandForm { public partial class SettingsForm : ExternalCommandForm {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm)); private static readonly ExternalCommandConfiguration ExternalCommandConfig = IniConfig.GetIniSection<ExternalCommandConfiguration>();
private static readonly ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
public SettingsForm() { public SettingsForm() {
// //
@ -42,35 +41,34 @@ namespace ExternalCommand {
UpdateView(); UpdateView();
} }
void ButtonOkClick(object sender, EventArgs e) { private void ButtonOkClick(object sender, EventArgs e) {
IniConfig.Save(); IniConfig.Save();
} }
void ButtonAddClick(object sender, EventArgs e) { private void ButtonAddClick(object sender, EventArgs e) {
SettingsFormDetail form = new SettingsFormDetail(null); var form = new SettingsFormDetail(null);
form.ShowDialog(); form.ShowDialog();
UpdateView(); UpdateView();
} }
void ButtonDeleteClick(object sender, EventArgs e) { private void ButtonDeleteClick(object sender, EventArgs e) {
foreach(ListViewItem item in listView1.SelectedItems) { foreach(ListViewItem item in listView1.SelectedItems) {
string commando = item.Tag as string; string commando = item.Tag as string;
config.Commands.Remove(commando);
config.commandlines.Remove(commando); ExternalCommandConfig.Delete(commando);
config.arguments.Remove(commando);
} }
UpdateView(); UpdateView();
} }
void UpdateView() { private void UpdateView() {
listView1.Items.Clear(); listView1.Items.Clear();
if(config.Commands != null) { if(ExternalCommandConfig.Commands != null) {
listView1.ListViewItemSorter = new ListviewComparer(); listView1.ListViewItemSorter = new ListviewComparer();
ImageList imageList = new ImageList(); ImageList imageList = new ImageList();
listView1.SmallImageList = imageList; listView1.SmallImageList = imageList;
int imageNr = 0; int imageNr = 0;
foreach(string commando in config.Commands) { foreach(string commando in ExternalCommandConfig.Commands) {
ListViewItem item; ListViewItem item;
Image iconForExe = IconCache.IconForCommand(commando); Image iconForExe = IconCache.IconForCommand(commando);
if(iconForExe != null) { if(iconForExe != null) {
@ -87,15 +85,15 @@ namespace ExternalCommand {
button_edit.Enabled = listView1.SelectedItems.Count > 0; 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; button_edit.Enabled = listView1.SelectedItems.Count > 0;
} }
void ButtonEditClick(object sender, EventArgs e) { private void ButtonEditClick(object sender, EventArgs e) {
ListView1DoubleClick(sender, e); ListView1DoubleClick(sender, e);
} }
void ListView1DoubleClick(object sender, EventArgs e) { private void ListView1DoubleClick(object sender, EventArgs e) {
// Safety check for bug #1484 // Safety check for bug #1484
bool selectionActive = listView1.SelectedItems.Count > 0; bool selectionActive = listView1.SelectedItems.Count > 0;
if(!selectionActive) { if(!selectionActive) {
@ -104,7 +102,7 @@ namespace ExternalCommand {
} }
string commando = listView1.SelectedItems[0].Tag as string; string commando = listView1.SelectedItems[0].Tag as string;
SettingsFormDetail form = new SettingsFormDetail(commando); var form = new SettingsFormDetail(commando);
form.ShowDialog(); form.ShowDialog();
UpdateView(); UpdateView();
@ -120,12 +118,9 @@ namespace ExternalCommand {
return (0); return (0);
} }
ListViewItem l1 = (ListViewItem)x; var l1 = (ListViewItem)x;
ListViewItem l2 = (ListViewItem)y; var l2 = (ListViewItem)y;
if(l2 == null) { return string.Compare(l1.Text, l2.Text, StringComparison.Ordinal);
return 1;
}
return l1.Text.CompareTo(l2.Text);
} }
} }
} }

View file

@ -45,8 +45,8 @@ namespace ExternalCommand {
if(commando != null) { if(commando != null) {
textBox_name.Text = commando; textBox_name.Text = commando;
textBox_commandline.Text = config.commandlines[commando]; textBox_commandline.Text = config.Commandline[commando];
textBox_arguments.Text = config.arguments[commando]; textBox_arguments.Text = config.Argument[commando];
_commandIndex = config.Commands.FindIndex(delegate(string s) { return s == commando; }); _commandIndex = config.Commands.FindIndex(delegate(string s) { return s == commando; });
} else { } else {
textBox_arguments.Text = "\"{0}\""; textBox_arguments.Text = "\"{0}\"";
@ -54,25 +54,25 @@ namespace ExternalCommand {
OkButtonState(); OkButtonState();
} }
void ButtonOkClick(object sender, EventArgs e) { private void ButtonOkClick(object sender, EventArgs e) {
string commandName = textBox_name.Text; string commandName = textBox_name.Text;
string commandLine = textBox_commandline.Text; string commandLine = textBox_commandline.Text;
string arguments = textBox_arguments.Text; string arguments = textBox_arguments.Text;
if(_commando != null) { if(_commando != null) {
config.Commands[_commandIndex] = commandName; config.Commands[_commandIndex] = commandName;
config.commandlines.Remove(_commando); config.Commandline.Remove(_commando);
config.commandlines.Add(commandName, commandLine); config.Commandline.Add(commandName, commandLine);
config.arguments.Remove(_commando); config.Argument.Remove(_commando);
config.arguments.Add(commandName, arguments); config.Argument.Add(commandName, arguments);
} else { } else {
config.Commands.Add(commandName); config.Commands.Add(commandName);
config.commandlines.Add(commandName, commandLine); config.Commandline.Add(commandName, commandLine);
config.arguments.Add(commandName, arguments); config.Argument.Add(commandName, arguments);
} }
} }
void Button3Click(object sender, EventArgs e) { private void Button3Click(object sender, EventArgs e) {
OpenFileDialog openFileDialog = new OpenFileDialog var openFileDialog = new OpenFileDialog
{ {
Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*", Filter = "Executables (*.exe, *.bat, *.com)|*.exe; *.bat; *.com|All files (*)|*",
FilterIndex = 1, FilterIndex = 1,
@ -106,7 +106,7 @@ namespace ExternalCommand {
buttonOk.Enabled = true; buttonOk.Enabled = true;
textBox_name.BackColor = Color.White; textBox_name.BackColor = Color.White;
textBox_commandline.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 // Is there a text in the name field
if(string.IsNullOrEmpty(textBox_name.Text)) { if(string.IsNullOrEmpty(textBox_name.Text)) {
buttonOk.Enabled = false; buttonOk.Enabled = false;
@ -136,17 +136,17 @@ namespace ExternalCommand {
} }
// Are the arguments in a valid format? // Are the arguments in a valid format?
try try
{ {
string arguments = FilenameHelper.FillVariables(textBox_arguments.Text, false); string arguments = FilenameHelper.FillVariables(textBox_arguments.Text, false);
arguments = FilenameHelper.FillCmdVariables(arguments, false); arguments = FilenameHelper.FillCmdVariables(arguments, false);
ExternalCommandDestination.FormatArguments(arguments, string.Empty); ExternalCommandDestination.FormatArguments(arguments, string.Empty);
} }
catch catch
{ {
buttonOk.Enabled = false; buttonOk.Enabled = false;
textBox_arguments.BackColor = Color.Red; textBox_arguments.BackColor = Color.Red;
} }
} }
private void textBox_name_TextChanged(object sender, EventArgs e) { private void textBox_name_TextChanged(object sender, EventArgs e) {
@ -157,10 +157,10 @@ namespace ExternalCommand {
OkButtonState(); OkButtonState();
} }
private void textBox_arguments_TextChanged(object sender, EventArgs e) private void textBox_arguments_TextChanged(object sender, EventArgs e)
{ {
OkButtonState(); OkButtonState();
} }
} }
} }

View file

@ -200,8 +200,8 @@ namespace GreenshotImgurPlugin {
listview_imgur_uploads.Sort(); listview_imgur_uploads.Sort();
} }
void ImgurHistoryFormClosing(object sender, FormClosingEventArgs e) private void ImgurHistoryFormClosing(object sender, FormClosingEventArgs e)
{ {
_instance = null; _instance = null;
} }

View file

@ -41,8 +41,8 @@ namespace GreenshotImgurPlugin {
historyButton.Enabled = false; historyButton.Enabled = false;
} }
} }
void ButtonHistoryClick(object sender, EventArgs e) { private void ButtonHistoryClick(object sender, EventArgs e) {
ImgurHistory.ShowHistory(); ImgurHistory.ShowHistory();
} }
} }

View file

@ -34,12 +34,12 @@
</PropertyGroup> </PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup> <ItemGroup>
<Reference Include="Dapplo.HttpExtensions, Version=0.5.33.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Dapplo.HttpExtensions, Version=0.5.36.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapplo.HttpExtensions.0.5.33\lib\net45\Dapplo.HttpExtensions.dll</HintPath> <HintPath>..\packages\Dapplo.HttpExtensions.0.5.36\lib\net45\Dapplo.HttpExtensions.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Dapplo.Jira, Version=0.1.59.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Dapplo.Jira, Version=0.1.61.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Dapplo.Jira.0.1.59\lib\net45\Dapplo.Jira.dll</HintPath> <HintPath>..\packages\Dapplo.Jira.0.1.61\lib\net45\Dapplo.Jira.dll</HintPath>
<Private>True</Private> <Private>True</Private>
</Reference> </Reference>
<Reference Include="Dapplo.Log.Facade, Version=0.5.4.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Dapplo.Log.Facade, Version=0.5.4.0, Culture=neutral, processorArchitecture=MSIL">

View file

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Dapplo.HttpExtensions" version="0.5.33" targetFramework="net45" /> <package id="Dapplo.HttpExtensions" version="0.5.36" targetFramework="net45" />
<package id="Dapplo.Jira" version="0.1.59" targetFramework="net45" /> <package id="Dapplo.Jira" version="0.1.61" targetFramework="net45" />
<package id="Dapplo.Log.Facade" version="0.5.4" targetFramework="net45" /> <package id="Dapplo.Log.Facade" version="0.5.4" targetFramework="net45" />
<package id="LibZ.Tool" version="1.2.0.0" targetFramework="net45" /> <package id="LibZ.Tool" version="1.2.0.0" targetFramework="net45" />
<package id="Svg" version="2.2.1" targetFramework="net45" /> <package id="Svg" version="2.2.1" targetFramework="net45" />

View file

@ -53,8 +53,8 @@ namespace GreenshotOCR {
index++; index++;
} }
} }
void ButtonOKClick(object sender, EventArgs e) { private void ButtonOKClick(object sender, EventArgs e) {
string selectedString = (string) comboBox_languages.SelectedItem; string selectedString = (string) comboBox_languages.SelectedItem;
if (selectedString != null) { if (selectedString != null) {
config.Language = selectedString.ToUpper(); config.Language = selectedString.ToUpper();

View file

@ -22,7 +22,7 @@ using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Greenshot.Interop.Office { 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_UNSPECIFIED = 0, /* (Reserved for interface use) type doesn't matter to caller */
PT_NULL = 1, /* NULL property value */ PT_NULL = 1, /* NULL property value */
PT_I2 = 2, /* Signed 16-bit value */ PT_I2 = 2, /* Signed 16-bit value */
@ -470,7 +470,7 @@ namespace Greenshot.Interop.Office {
[ComImport()] [ComImport()]
[Guid(IID_IMAPIProp)] [Guid(IID_IMAPIProp)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
interface IMessage : IMAPIProp { private interface IMessage : IMAPIProp {
[return: MarshalAs(UnmanagedType.I4)] [return: MarshalAs(UnmanagedType.I4)]
[PreserveSig] [PreserveSig]
int GetAttachmentTable(); int GetAttachmentTable();
@ -558,7 +558,7 @@ namespace Greenshot.Interop.Office {
[ComImport()] [ComImport()]
[Guid(IID_IMAPIProp)] [Guid(IID_IMAPIProp)]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)] [InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)]
interface IMAPIProp { private interface IMAPIProp {
[return: MarshalAs(UnmanagedType.I4)] [return: MarshalAs(UnmanagedType.I4)]
[PreserveSig] [PreserveSig]
int GetLastError(); int GetLastError();

View file

@ -110,7 +110,7 @@ namespace GreenshotPlugin.Controls {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void timer_Tick(object sender, EventArgs e) { private void timer_Tick(object sender, EventArgs e) {
try { try {
Animate(); Animate();
} catch (Exception ex) { } catch (Exception ex) {

View file

@ -92,8 +92,8 @@ namespace GreenshotPlugin.Controls {
_shouldClose = true; _shouldClose = true;
Application.DoEvents(); Application.DoEvents();
} }
void BackgroundFormFormClosing(object sender, FormClosingEventArgs e) { private void BackgroundFormFormClosing(object sender, FormClosingEventArgs e) {
timer_checkforclose.Stop(); timer_checkforclose.Stop();
} }
} }

View file

@ -25,14 +25,14 @@ using GreenshotInterop.Interop;
namespace GreenshotPlugin.Controls { namespace GreenshotPlugin.Controls {
public class ExtendedWebBrowser : WebBrowser { public class ExtendedWebBrowser : WebBrowser {
protected class ExtendedWebBrowserSite : WebBrowserSite, IOleCommandTarget { protected class ExtendedWebBrowserSite : WebBrowserSite, IOleCommandTarget {
const int OLECMDID_SHOWSCRIPTERROR = 40; private const int OLECMDID_SHOWSCRIPTERROR = 40;
const int OLECMDID_SHOWMESSAGE = 41; 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; private const int S_OK = 0;
const int OLECMDERR_E_NOTSUPPORTED = (-2147221248); private const int OLECMDERR_E_NOTSUPPORTED = (-2147221248);
const int OLECMDERR_E_UNKNOWNGROUP = (-2147221244); private const int OLECMDERR_E_UNKNOWNGROUP = (-2147221244);
public ExtendedWebBrowserSite(WebBrowser wb) : base(wb) { public ExtendedWebBrowserSite(WebBrowser wb) : base(wb) {
} }

View file

@ -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 /// 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. /// to notify the user what combination is currently pressed.
/// </summary> /// </summary>
void HotkeyControl_KeyDown(object sender, KeyEventArgs e) { private void HotkeyControl_KeyDown(object sender, KeyEventArgs e) {
// Clear the current hotkey // Clear the current hotkey
if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete) { if (e.KeyCode == Keys.Back || e.KeyCode == Keys.Delete) {
ResetHotkey(); ResetHotkey();
@ -217,7 +217,7 @@ namespace GreenshotPlugin.Controls {
/// Fires when all keys are released. If the current hotkey isn't valid, reset it. /// 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. /// Otherwise, do nothing and keep the text and hotkey as it was.
/// </summary> /// </summary>
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. // Somehow the PrintScreen only comes as a keyup, therefore we handle it here.
if (e.KeyCode == Keys.PrintScreen) { if (e.KeyCode == Keys.PrintScreen) {
_modifiers = e.Modifiers; _modifiers = e.Modifiers;
@ -235,7 +235,7 @@ namespace GreenshotPlugin.Controls {
/// Prevents the letter/whatever entered to show up in the TextBox /// Prevents the letter/whatever entered to show up in the TextBox
/// Without this, a "A" key press would appear as "aControl, Alt + A" /// Without this, a "A" key press would appear as "aControl, Alt + A"
/// </summary> /// </summary>
void HotkeyControl_KeyPress(object sender, KeyPressEventArgs e) { private void HotkeyControl_KeyPress(object sender, KeyPressEventArgs e) {
e.Handled = true; e.Handled = true;
} }

View file

@ -115,7 +115,7 @@ namespace GreenshotPlugin.Controls {
/// </summary> /// </summary>
/// <param name="sender"></param> /// <param name="sender"></param>
/// <param name="e"></param> /// <param name="e"></param>
void CancelButtonClick(object sender, EventArgs e) { private void CancelButtonClick(object sender, EventArgs e) {
LOG.DebugFormat("Cancel clicked on {0}", _title); LOG.DebugFormat("Cancel clicked on {0}", _title);
cancelButton.Enabled = false; cancelButton.Enabled = false;
_waitFor.Abort(); _waitFor.Abort();

View file

@ -48,8 +48,8 @@ namespace GreenshotPlugin.Controls {
textBoxJpegQuality.Text = Settings.JPGQuality.ToString(); textBoxJpegQuality.Text = Settings.JPGQuality.ToString();
ToFront = true; ToFront = true;
} }
void Button_okClick(object sender, EventArgs e) { private void Button_okClick(object sender, EventArgs e) {
Settings.JPGQuality = trackBarJpegQuality.Value; Settings.JPGQuality = trackBarJpegQuality.Value;
Settings.ReduceColors = checkBox_reduceColors.Checked; Settings.ReduceColors = checkBox_reduceColors.Checked;
if (checkbox_dontaskagain.Checked) { if (checkbox_dontaskagain.Checked) {
@ -59,8 +59,8 @@ namespace GreenshotPlugin.Controls {
IniConfig.Save(); IniConfig.Save();
} }
} }
void TrackBarJpegQualityScroll(object sender, EventArgs e) { private void TrackBarJpegQualityScroll(object sender, EventArgs e) {
textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString(); textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString();
} }
} }

View file

@ -519,7 +519,7 @@ namespace GreenshotPlugin.Core {
throw new NotImplementedException(); throw new NotImplementedException();
} }
static class Sine { private static class Sine {
public static double EaseIn(double s) { public static double EaseIn(double s) {
return Math.Sin(s * (Math.PI / 2) - (Math.PI / 2)) + 1; 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) { public static double EaseIn(double s, int power) {
return Math.Pow(s, power); return Math.Pow(s, power);
} }

View file

@ -490,7 +490,7 @@ namespace GreenshotPlugin.Core {
/// <returns>Bitmap</returns> /// <returns>Bitmap</returns>
public static Image ApplyEffect(Image sourceImage, IEffect effect, Matrix matrix) public static Image ApplyEffect(Image sourceImage, IEffect effect, Matrix matrix)
{ {
List<IEffect> effects = new List<IEffect> { effect }; var effects = new List<IEffect> { effect };
return ApplyEffects(sourceImage, effects, matrix); return ApplyEffects(sourceImage, effects, matrix);
} }
@ -501,13 +501,13 @@ namespace GreenshotPlugin.Core {
/// <param name="effects">List of IEffect</param> /// <param name="effects">List of IEffect</param>
/// <param name="matrix"></param> /// <param name="matrix"></param>
/// <returns>Bitmap</returns> /// <returns>Bitmap</returns>
public static Image ApplyEffects(Image sourceImage, List<IEffect> effects, Matrix matrix) public static Image ApplyEffects(Image sourceImage, IEnumerable<IEffect> effects, Matrix matrix)
{ {
Image currentImage = sourceImage; var currentImage = sourceImage;
bool disposeImage = false; 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 (tmpImage != null)
{ {
if (disposeImage) if (disposeImage)
@ -515,7 +515,6 @@ namespace GreenshotPlugin.Core {
currentImage.Dispose(); currentImage.Dispose();
} }
currentImage = tmpImage; currentImage = tmpImage;
tmpImage = null;
// Make sure the "new" image is disposed // Make sure the "new" image is disposed
disposeImage = true; disposeImage = true;
} }
@ -549,7 +548,7 @@ namespace GreenshotPlugin.Core {
public static Image CreateTornEdge(Image sourceImage, int toothHeight, int horizontalToothRange, int verticalToothRange, bool[] edges) 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); 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(); Random random = new Random();
int horizontalRegions = (int)Math.Round((float)sourceImage.Width / horizontalToothRange); int horizontalRegions = (int)Math.Round((float)sourceImage.Width / horizontalToothRange);

View file

@ -780,7 +780,7 @@ namespace GreenshotPlugin.Core {
} }
if (windowRect.IsEmpty) { if (windowRect.IsEmpty) {
if (GetWindowRect(out windowRect)) if (!GetWindowRect(out windowRect))
{ {
Win32Error error = Win32.GetLastErrorCode(); Win32Error error = Win32.GetLastErrorCode();
Log.WarnFormat("Couldn't retrieve the windows rectangle: {0}", Win32.GetMessage(error)); Log.WarnFormat("Couldn't retrieve the windows rectangle: {0}", Win32.GetMessage(error));

View file

@ -64,10 +64,10 @@ namespace Greenshot.Interop {
#endregion #endregion
[DllImport("ole32.dll")] [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: // Converts failure HRESULTs to exceptions:
[DllImport("oleaut32", PreserveSig=false)] [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 #region Construction

View file

@ -90,7 +90,7 @@ namespace GreenshotPlugin.UnmanagedHelpers {
public static class Win32 { public static class Win32 {
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)] [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")] [DllImport("kernel32.dll")]
public static extern void SetLastError(uint dwErrCode); public static extern void SetLastError(uint dwErrCode);