mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 14:03:23 -07:00
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:
parent
35ed3b8d60
commit
6efc7796b8
49 changed files with 322 additions and 294 deletions
|
@ -110,7 +110,7 @@ namespace GreenshotPlugin.Controls {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void timer_Tick(object sender, EventArgs e) {
|
||||
private void timer_Tick(object sender, EventArgs e) {
|
||||
try {
|
||||
Animate();
|
||||
} catch (Exception ex) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
/// </summary>
|
||||
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.
|
||||
/// </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.
|
||||
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"
|
||||
/// </summary>
|
||||
void HotkeyControl_KeyPress(object sender, KeyPressEventArgs e) {
|
||||
private void HotkeyControl_KeyPress(object sender, KeyPressEventArgs e) {
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ namespace GreenshotPlugin.Controls {
|
|||
/// </summary>
|
||||
/// <param name="sender"></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);
|
||||
cancelButton.Enabled = false;
|
||||
_waitFor.Abort();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -490,7 +490,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// <returns>Bitmap</returns>
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -501,13 +501,13 @@ namespace GreenshotPlugin.Core {
|
|||
/// <param name="effects">List of IEffect</param>
|
||||
/// <param name="matrix"></param>
|
||||
/// <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;
|
||||
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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue