This commit is contained in:
Jan Klass 2025-08-19 00:47:43 +08:00 committed by GitHub
commit 07d5f1f37c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 120 additions and 120 deletions

View file

@ -35,28 +35,28 @@ namespace Greenshot.Base.Core
/// doesn't show all credentials use the tool here: https://www.microsoft.com/indonesia/msdn/credmgmt.aspx
/// The following code is an example for a login, it will call the Authenticate with user/password
/// which should return true if the login worked, false if not.
/// private static bool Login(string system, string name) {
/// try {
/// CredentialsDialog dialog = new CredentialsDialog(system);
/// dialog.Name = name;
/// while (dialog.Show(dialog.Name) == DialogResult.OK) {
/// if (Authenticate(dialog.Name, dialog.Password)) {
/// if (dialog.SaveChecked) dialog.Confirm(true);
/// return true;
/// } else {
/// try {
/// dialog.Confirm(false);
/// } catch (ApplicationException) {
/// // exception handling ...
/// }
/// dialog.IncorrectPassword = true;
/// }
/// }
/// } catch (ApplicationException) {
/// // exception handling ...
/// }
/// return false;
/// }
/// private static bool Login(string system, string name) {
/// try {
/// CredentialsDialog dialog = new CredentialsDialog(system);
/// dialog.Name = name;
/// while (dialog.Show(dialog.Name) == DialogResult.OK) {
/// if (Authenticate(dialog.Name, dialog.Password)) {
/// if (dialog.SaveChecked) dialog.Confirm(true);
/// return true;
/// } else {
/// try {
/// dialog.Confirm(false);
/// } catch (ApplicationException) {
/// // exception handling ...
/// }
/// dialog.IncorrectPassword = true;
/// }
/// }
/// } catch (ApplicationException) {
/// // exception handling ...
/// }
/// return false;
/// }
/// </summary>
/// <summary>Encapsulates dialog functionality from the Credential Management API.</summary>
public sealed class CredentialsDialog

View file

@ -128,7 +128,7 @@ namespace Greenshot.Base.Core
{
ModifyRegistry("HKEY_CURRENT_USER", applicationName + ".exe", ieVersion);
#if DEBUG
ModifyRegistry("HKEY_CURRENT_USER", applicationName + ".vshost.exe", ieVersion);
ModifyRegistry("HKEY_CURRENT_USER", applicationName + ".vshost.exe", ieVersion);
#endif
}

View file

@ -1171,9 +1171,9 @@ namespace Greenshot.Base.Core
/// <summary>
/// Clone an image, taking some rules into account:
/// 1) When sourceRect is the whole bitmap there is a GDI+ bug in Clone
/// Clone will than return the same PixelFormat as the source
/// a quick workaround is using new Bitmap which uses a default of Format32bppArgb
/// 2) When going from a transparent to a non transparent bitmap, we draw the background white!
/// Clone will than return the same PixelFormat as the source
/// a quick workaround is using new Bitmap which uses a default of Format32bppArgb
/// 2) When going from a transparent to a non transparent bitmap, we draw the background white!
/// </summary>
/// <param name="sourceImage">Source bitmap to clone</param>
/// <param name="sourceRect">NativeRect to copy from the source, use NativeRect.Empty for all</param>

View file

@ -87,9 +87,9 @@ namespace Greenshot.Base.Core.OAuth
// gives as described here: https://developers.google.com/identity/protocols/OAuth2InstalledApp
// "access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
// "expires_in":3920,
// "token_type":"Bearer",
// "refresh_token":"1/xEoDL4iW3cxlI7yDbSRFYNG01kVKM2C-259HOF2aQbI"
// "expires_in":3920,
// "token_type":"Bearer",
// "refresh_token":"1/xEoDL4iW3cxlI7yDbSRFYNG01kVKM2C-259HOF2aQbI"
if (refreshTokenResult.ContainsKey(AccessToken))
{
settings.AccessToken = (string) refreshTokenResult[AccessToken];
@ -181,8 +181,8 @@ namespace Greenshot.Base.Core.OAuth
// gives as described here: https://developers.google.com/identity/protocols/OAuth2InstalledApp
// "access_token":"1/fFAGRNJru1FTz70BzhT3Zg",
// "expires_in":3920,
// "token_type":"Bearer",
// "expires_in":3920,
// "token_type":"Bearer",
IDictionary<string, object> accessTokenResult = JSONHelper.JsonDecode(accessTokenJsonResult);
if (accessTokenResult.ContainsKey("error"))

View file

@ -621,7 +621,7 @@ namespace Greenshot.Base.Core
}
/// <summary>
/// Finds the optimal (maximal) position for the cut.
/// Finds the optimal (maximal) position for the cut.
/// </summary>
private float Maximize(WuColorCube cube, int direction, int first, int last, int[] cut, long wholeRed, long wholeGreen, long wholeBlue, long wholeWeight)
{

View file

@ -274,7 +274,7 @@ namespace Greenshot.Base.Core
// See https://connect.microsoft.com/VisualStudio/feedback/details/344752/gdi-object-leak-when-calling-graphics-copyfromscreen
// Bitmap capturedBitmap = new Bitmap(captureBounds.Width, captureBounds.Height);
// using (Graphics graphics = Graphics.FromImage(capturedBitmap)) {
// graphics.CopyFromScreen(captureBounds.Location, Point.Empty, captureBounds.Size, CopyPixelOperation.CaptureBlt);
// graphics.CopyFromScreen(captureBounds.Location, Point.Empty, captureBounds.Size, CopyPixelOperation.CaptureBlt);
// }
// capture.Image = capturedBitmap;
// capture.Location = captureBounds.Location;

View file

@ -24,16 +24,16 @@ using System.Runtime.InteropServices;
namespace Greenshot.Base.IEInterop
{
// IWebBrowser: EAB22AC1-30C1-11CF-A7EB-0000C05BAE0B
// [ComVisible(true), ComImport(), Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"),
// TypeLibType(TypeLibTypeFlags.FDual),
// InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
// public interface IWebBrowser2 {
// [DispId(203)]
// object Document {
// [return: MarshalAs(UnmanagedType.IDispatch)]
// get;
// }
// }
// [ComVisible(true), ComImport(), Guid("D30C1661-CDAF-11D0-8A3E-00C04FC9E26E"),
// TypeLibType(TypeLibTypeFlags.FDual),
// InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]
// public interface IWebBrowser2 {
// [DispId(203)]
// object Document {
// [return: MarshalAs(UnmanagedType.IDispatch)]
// get;
// }
// }
[ComImport, /*SuppressUnmanagedCodeSecurity,*/
TypeLibType(TypeLibTypeFlags.FOleAutomation |
TypeLibTypeFlags.FDual |

View file

@ -443,66 +443,66 @@ namespace Greenshot.Editor.Drawing
public void SetForegroundColor(Color color)
{
var dcs = ToArray();
var field = FieldType.LINE_COLOR;
foreach (var dc in dcs)
{
if (dc is not AbstractFieldHolderWithChildren fh) continue;
if (!fh.HasField(field)) continue;
fh.SetFieldValue(field, color);
}
var dcs = ToArray();
var field = FieldType.LINE_COLOR;
foreach (var dc in dcs)
{
if (dc is not AbstractFieldHolderWithChildren fh) continue;
if (!fh.HasField(field)) continue;
fh.SetFieldValue(field, color);
}
}
public void SetBackgroundColor(Color color)
{
var dcs = ToArray();
var field = FieldType.FILL_COLOR;
foreach (var dc in dcs)
{
if (dc is not AbstractFieldHolderWithChildren fh) continue;
if (!fh.HasField(field)) continue;
var dcs = ToArray();
var field = FieldType.FILL_COLOR;
foreach (var dc in dcs)
{
if (dc is not AbstractFieldHolderWithChildren fh) continue;
if (!fh.HasField(field)) continue;
fh.SetFieldValue(field, color);
}
fh.SetFieldValue(field, color);
}
}
public int IncreaseLineThickness(int increaseBy)
{
var dcs = ToArray();
var field = FieldType.LINE_THICKNESS;
var lastThickness = 0;
foreach (var dc in dcs)
{
if (dc is not AbstractFieldHolderWithChildren fh) continue;
if (!fh.HasField(field)) continue;
var dcs = ToArray();
var field = FieldType.LINE_THICKNESS;
var lastThickness = 0;
foreach (var dc in dcs)
{
if (dc is not AbstractFieldHolderWithChildren fh) continue;
if (!fh.HasField(field)) continue;
var currentThickness = (int)fh.GetFieldValue(field);
var thickness = Math.Max(0, currentThickness + increaseBy);
fh.SetFieldValue(field, thickness);
lastThickness = thickness;
}
var currentThickness = (int)fh.GetFieldValue(field);
var thickness = Math.Max(0, currentThickness + increaseBy);
fh.SetFieldValue(field, thickness);
lastThickness = thickness;
}
return lastThickness;
return lastThickness;
}
public bool FlipShadow()
{
var dcs = ToArray();
var field = FieldType.SHADOW;
var lastShadow = false;
foreach (var dc in dcs)
{
if (dc is not AbstractFieldHolderWithChildren fh) continue;
if (!fh.HasField(field)) continue;
var dcs = ToArray();
var field = FieldType.SHADOW;
var lastShadow = false;
foreach (var dc in dcs)
{
if (dc is not AbstractFieldHolderWithChildren fh) continue;
if (!fh.HasField(field)) continue;
var currentShadow = (bool)fh.GetFieldValue(field);
var shadow = !currentShadow;
fh.SetFieldValue(field, shadow);
lastShadow = shadow;
}
var currentShadow = (bool)fh.GetFieldValue(field);
var shadow = !currentShadow;
fh.SetFieldValue(field, shadow);
lastShadow = shadow;
}
return lastShadow;
return lastShadow;
}
/// <summary>

View file

@ -80,9 +80,9 @@ namespace Greenshot.Editor.Drawing
}
/**
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
protected override void Dispose(bool disposing)
{
if (disposing)

View file

@ -2606,31 +2606,31 @@ namespace Greenshot.Editor.Drawing
// for laptops without numPads, also allow shift modifier
private void SetSelectedElementColor(Color color, bool numPad, bool shift)
{
if (numPad || shift)
{
selectedElements.SetForegroundColor(color);
UpdateForegroundColorEvent(this, color);
}
else
{
selectedElements.SetBackgroundColor(color);
UpdateBackgroundColorEvent(this, color);
}
selectedElements.Invalidate();
if (numPad || shift)
{
selectedElements.SetForegroundColor(color);
UpdateForegroundColorEvent(this, color);
}
else
{
selectedElements.SetBackgroundColor(color);
UpdateBackgroundColorEvent(this, color);
}
selectedElements.Invalidate();
}
private void ChangeLineThickness(int increaseBy)
{
var newThickness = selectedElements.IncreaseLineThickness(increaseBy);
UpdateLineThicknessEvent(this, newThickness);
selectedElements.Invalidate();
var newThickness = selectedElements.IncreaseLineThickness(increaseBy);
UpdateLineThicknessEvent(this, newThickness);
selectedElements.Invalidate();
}
private void FlipShadow()
{
var shadow = selectedElements.FlipShadow();
UpdateShadowEvent(this, shadow);
selectedElements.Invalidate();
var shadow = selectedElements.FlipShadow();
UpdateShadowEvent(this, shadow);
selectedElements.Invalidate();
}
/// <summary>

View file

@ -635,8 +635,8 @@ namespace Greenshot.Editor.Forms
}
/**
* Interfaces for plugins, see GreenshotInterface for more details!
*/
* Interfaces for plugins, see GreenshotInterface for more details!
*/
public Image GetImageForExport()
{
return _surface.GetImageForExport();

View file

@ -282,8 +282,8 @@ namespace Greenshot.Plugin.Office.OfficeExport
// Use this to change the format, it will probably lose the current selection.
//if (!OlBodyFormat.olFormatHTML.Equals(currentMail.BodyFormat)) {
// Log.Info().WriteLine("Changing format to HTML.");
// currentMail.BodyFormat = OlBodyFormat.olFormatHTML;
// Log.Info().WriteLine("Changing format to HTML.");
// currentMail.BodyFormat = OlBodyFormat.olFormatHTML;
//}
bool inlinePossible = false;

View file

@ -1019,7 +1019,7 @@ namespace Greenshot.Forms
// TODO: enable when the screen capture code works reliable
//if (capture.CaptureDetails.CaptureMode == CaptureMode.Video) {
// graphics.FillRectangle(RedOverlayBrush, fixedRect);
// graphics.FillRectangle(RedOverlayBrush, fixedRect);
//} else {
graphics.FillRectangle(GreenOverlayBrush, fixedRect);
//}

View file

@ -501,7 +501,7 @@ namespace Greenshot.Helpers
_capture = WindowCapture.CaptureRectangle(_capture, CoreConfig.LastCapturedRegion);
// TODO: Reactive / check if the elements code is activated
//if (windowDetailsThread != null) {
// windowDetailsThread.Join();
// windowDetailsThread.Join();
//}
// Set capture title, fixing bug #3569703

View file

@ -60,17 +60,17 @@ namespace Greenshot.Helpers
}
/**
* Destructor
*/
* Destructor
*/
~PrintHelper()
{
Dispose(false);
}
/**
* The public accessible Dispose
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
*/
* The public accessible Dispose
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
*/
public void Dispose()
{
Dispose(true);
@ -78,9 +78,9 @@ namespace Greenshot.Helpers
}
/**
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
protected virtual void Dispose(bool disposing)
{
if (disposing)