mirror of
https://github.com/greenshot/greenshot
synced 2025-08-23 14:46:19 -07:00
FEATURE-758: This commit enhances the already made changes to also fix the size of the icons in the destination picker and the context menu. On top of that, if a large icon size is selected we try to get a larger (more defined) icon from the application unfortunately that doesn't improve the build in icons.
This commit is contained in:
parent
1da7d028a0
commit
9df25bdd76
13 changed files with 129 additions and 27 deletions
|
@ -172,6 +172,7 @@ namespace GreenshotPlugin.Core {
|
|||
// Generate an empty ExportInformation object, for when nothing was selected.
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Language.GetString("settings_destination_picker"));
|
||||
ContextMenuStrip menu = new ContextMenuStrip();
|
||||
menu.ImageScalingSize = configuration.IconSize;
|
||||
menu.Tag = null;
|
||||
|
||||
menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) {
|
||||
|
|
|
@ -256,9 +256,18 @@ namespace GreenshotPlugin.Core {
|
|||
[IniProperty("LastCapturedRegion", Description = "The last used region, for reuse in the capture last region")]
|
||||
public Rectangle LastCapturedRegion;
|
||||
|
||||
[IniProperty("IconSize", Description = "Defines the size of the icons (e.g. for the buttons in the editor), default value 16,16 anything bigger will cause scaling", DefaultValue = "16,16")]
|
||||
public Size IconSize;
|
||||
|
||||
// Specifies what THIS build is
|
||||
public BuildStates BuildState = BuildStates.RELEASE_CANDIDATE;
|
||||
|
||||
public bool UseLargeIcons {
|
||||
get {
|
||||
return IconSize.Width >= 32 || IconSize.Height >= 32;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A helper method which returns true if the supplied experimental feature is enabled
|
||||
/// </summary>
|
||||
|
@ -432,6 +441,30 @@ namespace GreenshotPlugin.Core {
|
|||
if (OutputFileReduceColorsTo > 256) {
|
||||
OutputFileReduceColorsTo = 256;
|
||||
}
|
||||
FixIconSize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Validation & correction of the icon size
|
||||
/// </summary>
|
||||
public void FixIconSize() {
|
||||
if (IconSize == Size.Empty) {
|
||||
IconSize = new Size(16, 16);
|
||||
} else {
|
||||
if (IconSize.Width < 16) {
|
||||
IconSize.Width = 16;
|
||||
}
|
||||
if (IconSize.Width > 256) {
|
||||
IconSize.Width = 256;
|
||||
}
|
||||
if (IconSize.Height < 16) {
|
||||
IconSize.Height = 16;
|
||||
}
|
||||
if (IconSize.Height > 256) {
|
||||
IconSize.Height = 256;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1392,10 +1392,14 @@ namespace GreenshotPlugin.Core {
|
|||
Image newImage = null;
|
||||
if (maintainAspectRatio && canvasUseNewSize) {
|
||||
newImage = CreateEmpty(newWidth, newHeight, sourceImage.PixelFormat, backgroundColor, sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
|
||||
matrix.Scale((float)newWidth / sourceImage.Width, (float)newHeight / sourceImage.Height, MatrixOrder.Append);
|
||||
if (matrix != null) {
|
||||
matrix.Scale((float)newWidth / sourceImage.Width, (float)newHeight / sourceImage.Height, MatrixOrder.Append);
|
||||
}
|
||||
} else {
|
||||
newImage = CreateEmpty(destWidth, destHeight, sourceImage.PixelFormat, backgroundColor, sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
|
||||
matrix.Scale((float)destWidth / sourceImage.Width, (float)destHeight / sourceImage.Height, MatrixOrder.Append);
|
||||
if (matrix != null) {
|
||||
matrix.Scale((float)destWidth / sourceImage.Width, (float)destHeight / sourceImage.Height, MatrixOrder.Append);
|
||||
}
|
||||
}
|
||||
|
||||
using (Graphics graphics = Graphics.FromImage(newImage)) {
|
||||
|
|
|
@ -18,14 +18,16 @@
|
|||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
using log4net;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Plugin;
|
||||
using log4net;
|
||||
using Microsoft.Win32;
|
||||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
|
||||
namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
|
@ -33,6 +35,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
public static class PluginUtils {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(PluginUtils));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private const string PATH_KEY = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\";
|
||||
|
||||
/// <summary>
|
||||
|
@ -79,12 +82,12 @@ namespace GreenshotPlugin.Core {
|
|||
return null;
|
||||
}
|
||||
try {
|
||||
using (Icon appIcon = ImageHelper.ExtractAssociatedIcon(path, index, false)) {
|
||||
using (Icon appIcon = ImageHelper.ExtractAssociatedIcon(path, index, conf.UseLargeIcons)) {
|
||||
if (appIcon != null) {
|
||||
return appIcon.ToBitmap();
|
||||
}
|
||||
}
|
||||
using (Icon appIcon = Shell32.GetFileIcon(path, Shell32.IconSize.Small, false)) {
|
||||
using (Icon appIcon = Shell32.GetFileIcon(path, conf.UseLargeIcons ? Shell32.IconSize.Large : Shell32.IconSize.Small, false)) {
|
||||
if (appIcon != null) {
|
||||
return appIcon.ToBitmap();
|
||||
}
|
||||
|
|
|
@ -336,7 +336,15 @@ namespace GreenshotPlugin.Core {
|
|||
IntPtr ICON_BIG = new IntPtr(1);
|
||||
IntPtr ICON_SMALL2 = new IntPtr(2);
|
||||
|
||||
IntPtr iconHandle = User32.SendMessage(hwnd, (int)WindowsMessages.WM_GETICON, ICON_SMALL2, IntPtr.Zero);
|
||||
IntPtr iconHandle = User32.SendMessage(hwnd, (int)WindowsMessages.WM_GETICON, ICON_BIG, IntPtr.Zero);
|
||||
if (conf.UseLargeIcons) {
|
||||
iconHandle = User32.SendMessage(hwnd, (int)WindowsMessages.WM_GETICON, ICON_BIG, IntPtr.Zero);
|
||||
if (iconHandle == IntPtr.Zero) {
|
||||
iconHandle = User32.GetClassLongWrapper(hwnd, (int)ClassLongIndex.GCL_HICON);
|
||||
}
|
||||
} else {
|
||||
iconHandle = User32.SendMessage(hwnd, (int)WindowsMessages.WM_GETICON, ICON_SMALL2, IntPtr.Zero);
|
||||
}
|
||||
if (iconHandle == IntPtr.Zero) {
|
||||
iconHandle = User32.SendMessage(hwnd, (int)WindowsMessages.WM_GETICON, ICON_SMALL, IntPtr.Zero);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue