Merge branch 'greenshot:release/1.3' into release/1.3

This commit is contained in:
Felipe 2025-07-16 13:02:50 -03:00 committed by GitHub
commit 4286cddd57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
34 changed files with 467 additions and 172 deletions

View file

@ -0,0 +1,14 @@
name: Purge CloudFlare Cache
on:
page_build:
jobs:
purge_cache:
runs-on: ubuntu-latest
steps:
- name: purge
uses: jakejarvis/cloudflare-purge-action@master
env:
CLOUDFLARE_ZONE: ${{ secrets.CLOUDFLARE_ZONE }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}

127
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,127 @@
name: Build and Deploy
on:
workflow_dispatch:
push:
branches:
- 'release/1.*'
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v2
- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '7.x'
- name: Restore NuGet packages
run: msbuild src/Greenshot.sln /p:Configuration=Release /restore /t:PrepareForBuild
env:
Box13_ClientId: ${{ secrets.Box13_ClientId }}
Box13_ClientSecret: ${{ secrets.Box13_ClientSecret }}
DropBox13_ClientId: ${{ secrets.DropBox13_ClientId }}
DropBox13_ClientSecret: ${{ secrets.DropBox13_ClientSecret }}
Flickr_ClientId: ${{ secrets.Flickr_ClientId }}
Flickr_ClientSecret: ${{ secrets.Flickr_ClientSecret }}
Imgur13_ClientId: ${{ secrets.Imgur13_ClientId }}
Imgur13_ClientSecret: ${{ secrets.Imgur13_ClientSecret }}
Photobucket_ClientId: ${{ secrets.Photobucket_ClientId }}
Photobucket_ClientSecret: ${{ secrets.Photobucket_ClientSecret }}
Picasa_ClientId: ${{ secrets.Picasa_ClientId }}
Picasa_ClientSecret: ${{ secrets.Picasa_ClientSecret }}
- name: Build and package
run: msbuild src/Greenshot.sln /p:Configuration=Release /t:Rebuild /v:normal
env:
Box13_ClientId: ${{ secrets.Box13_ClientId }}
Box13_ClientSecret: ${{ secrets.Box13_ClientSecret }}
DropBox13_ClientId: ${{ secrets.DropBox13_ClientId }}
DropBox13_ClientSecret: ${{ secrets.DropBox13_ClientSecret }}
Flickr_ClientId: ${{ secrets.Flickr_ClientId }}
Flickr_ClientSecret: ${{ secrets.Flickr_ClientSecret }}
Imgur13_ClientId: ${{ secrets.Imgur13_ClientId }}
Imgur13_ClientSecret: ${{ secrets.Imgur13_ClientSecret }}
Photobucket_ClientId: ${{ secrets.Photobucket_ClientId }}
Photobucket_ClientSecret: ${{ secrets.Photobucket_ClientSecret }}
Picasa_ClientId: ${{ secrets.Picasa_ClientId }}
Picasa_ClientSecret: ${{ secrets.Picasa_ClientSecret }}
- name: Copy Files
run: |
mkdir -p ${{ github.workspace }}/artifacts
cp installer/Greenshot-INSTALLER-*.exe ${{ github.workspace }}/artifacts/
- name: Upload Artifact
uses: actions/upload-artifact@v4
with:
name: drop
path: ${{ github.workspace }}/artifacts
deploy:
runs-on: windows-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: drop # Name of the artifact uploaded in previous steps
path: drop # Local folder where artifacts are downloaded
- name: Extract version from file name
id: extract_version
run: |
$file = Get-ChildItem drop -Filter "Greenshot-INSTALLER-*.exe" | Select-Object -First 1
if (-not $file) {
throw "No matching file found in 'drop' directory."
}
if ($file.Name -match "Greenshot-INSTALLER-([\d\.]+)(.*)\.exe") {
echo "version=$($matches[1])" >> $Env:GITHUB_OUTPUT
} else {
throw "Version number could not be extracted from file name: $($file.Name)"
}
shell: pwsh
- name: Create tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.extract_version.outputs.version }}" -m "v${{ steps.extract_version.outputs.version }}"
git push origin "v${{ steps.extract_version.outputs.version }}"
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "Greenshot ${{ steps.extract_version.outputs.version }} (continuous build)"
tag_name: "v${{ steps.extract_version.outputs.version }}"
files: drop/*.exe
generate_release_notes: true
draft: false
prerelease: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Trigger GitHub Pages rebuild
shell: bash
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/pages/builds

18
.github/workflows/update-gh-pages.yml vendored Normal file
View file

@ -0,0 +1,18 @@
name: Update GitHub Pages
on:
workflow_dispatch:
release:
types: [published]
jobs:
update-gh-pages:
runs-on: ubuntu-latest
steps:
- name: Trigger GitHub Pages rebuild
shell: bash
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GH_PAGES_TOKEN }}" \
-H "Accept: application/vnd.github+json" \
https://api.github.com/repos/${{ github.repository }}/pages/builds

4
.gitignore vendored
View file

@ -214,4 +214,6 @@ ModelManifest.xml
*.credentials.cs
# Rider files
.idea
.idea
/installer/Greenshot-INSTALLER-*.exe

View file

@ -1,106 +0,0 @@
# .NET Desktop
# Build and run tests for .NET Desktop or Windows classic desktop solutions.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/windows/dot-net
trigger:
batch: true
branches:
include:
- 'release/1.*'
exclude:
- 'develop'
stages:
- stage: Build
jobs:
- job: Build
variables:
- group: 'Plug-in Credentials'
- name: solution
value: 'src/Greenshot.sln'
- name: buildPlatform
value: 'Any CPU'
- name: buildConfiguration
value: 'Release'
pool:
vmImage: 'Windows-latest'
steps:
- task: MSBuild@1
displayName: Restore nuget packages and generate credential templates
inputs:
solution: '$(solution)'
platform: $(buildPlatform)
configuration: $(buildConfiguration)
msbuildArguments: '/restore /t:PrepareForBuild'
- task: MSBuild@1
displayName: Build and package
inputs:
solution: '$(solution)'
platform: $(buildPlatform)
configuration: $(buildConfiguration)
env:
Box13_ClientId: $(Box13_ClientId)
Box13_ClientSecret: $(Box13_ClientSecret)
DropBox13_ClientId: $(DropBox13_ClientId)
DropBox13_ClientSecret: $(DropBox13_ClientSecret)
Flickr_ClientId: $(Flickr_ClientId)
Flickr_ClientSecret: $(Flickr_ClientSecret)
Imgur13_ClientId: $(Imgur13_ClientId)
Imgur13_ClientSecret: $(Imgur13_ClientSecret)
Photobucket_ClientId: $(Photobucket_ClientId)
Photobucket_ClientSecret: $(Photobucket_ClientSecret)
Picasa_ClientId: $(Picasa_ClientId)
Picasa_ClientSecret: $(Picasa_ClientSecret)
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(Build.SourcesDirectory)\installer'
Contents: Greenshot-INSTALLER-*.exe
TargetFolder: '$(build.artifactstagingdirectory)'
flattenFolders: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)'
- stage: Deploy
jobs:
- deployment: GitHub_Release
pool:
vmImage: 'Windows-latest'
environment: 'GitHub Release'
strategy:
# default deployment strategy
runOnce:
deploy:
steps:
- download: current
artifact: drop
# Create a GitHub release
- task: GitHubRelease@0
inputs:
gitHubConnection: GitHub Release
repositoryName: '$(Build.Repository.Name)'
action: 'create' # Options: create, edit, delete
target: '$(Build.SourceVersion)' # Required when action == Create || Action == Edit
tagSource: 'manual' # Required when action == Create# Options: auto, manual
tag: 'v$(Build.BuildNumber)' # Required when action == Edit || Action == Delete || TagSource == Manual
title: Greenshot $(Build.BuildNumber) unstable # Optional
#releaseNotesSource: 'file' # Optional. Options: file, input
#releaseNotesFile: # Optional
#releaseNotes: # Optional
assets: '$(Pipeline.Workspace)/drop/*.exe'
#assetUploadMode: 'delete' # Optional. Options: delete, replace
isDraft: true # Optional
isPreRelease: true # Optional
addChangeLog: true # Optional
#compareWith: 'lastFullRelease' # Required when addChangeLog == True. Options: lastFullRelease, lastRelease, lastReleaseByTag
#releaseTag: # Required when compareWith == LastReleaseByTag

149
build-and-deploy.ps1 Normal file
View file

@ -0,0 +1,149 @@
# USAGE
# * Enable script execution in Powershell: 'Set-ExecutionPolicy RemoteSigned'
# * Create a GitHub personal access token (PAT) for greenshot repository
# * user must be owner of the repository
# * token needs read and write permissions ""for Contents"" and ""Pages""
# * Execute the script and paste your token
# Prompt the user to securely input the Github token
$SecureToken = Read-Host "Please enter your GitHub personal access token" -AsSecureString
$ReleaseToken = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto([System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($SecureToken))
# Variables
$RepoPath = "." # Replace with your local repo path
$ArtifactsPath = "$RepoPath\artifacts"
$SolutionFile = "$RepoPath\src\Greenshot.sln"
# Step 0: Update Local Repository
git pull
# Step 1: Restore NuGet Packages
Write-Host "Restoring NuGet packages..."
msbuild "$SolutionFile" /p:Configuration=Release /restore /t:PrepareForBuild
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to restore NuGet packages."
exit $LASTEXITCODE
}
# Step 2: Build and Package
Write-Host "Building and packaging the solution..."
msbuild "$SolutionFile" /p:Configuration=Release /t:Rebuild /v:normal
if ($LASTEXITCODE -ne 0) {
Write-Error "Build failed."
exit $LASTEXITCODE
}
# Step 3: Copy Installer Files
Write-Host "Copying installer files..."
if (-not (Test-Path $ArtifactsPath)) {
New-Item -ItemType Directory -Force -Path $ArtifactsPath
}
Copy-Item "$RepoPath\installer\Greenshot-INSTALLER-*.exe" -Destination $ArtifactsPath -Force
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to copy installer files."
exit $LASTEXITCODE
}
# Step 4: Extract Version from File Name
Write-Host "Extracting version from installer file name..."
$InstallerFile = Get-ChildItem $ArtifactsPath -Filter "Greenshot-INSTALLER-*.exe" | Select-Object -Last 1
if (-not $InstallerFile) {
Write-Error "No matching installer file found in '$ArtifactsPath'."
exit 1
}
if ($InstallerFile.Name -match "Greenshot-INSTALLER-([\d\.]+).*\.exe") {
$Version = $matches[1]
Write-Host "Extracted version: $Version"
} else {
Write-Error "Version number could not be extracted from file name: $($InstallerFile.Name)"
exit 1
}
# Step 5: Create Git Tag
Write-Host "Creating Git tag..."
cd $RepoPath
#git config user.name "local-script"
#git config user.email "local-script@example.com"
git tag -a "v$Version" -m "v$Version"
git push origin "v$Version"
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create Git tag."
exit $LASTEXITCODE
}
# Step 6: Create GitHub Release
Write-Host "Creating GitHub release..."
$Headers = @{
Authorization = "Bearer $ReleaseToken"
Accept = "application/vnd.github+json"
}
$ReleaseData = @{
tag_name = "v$Version"
name = "Greenshot $Version unstable"
body = "Pre-release of Greenshot $Version."
draft = $true
prerelease = $true
generate_release_notes = $true
}
$ReleaseResponse = Invoke-RestMethod `
-Uri "https://api.github.com/repos/greenshot/greenshot/releases" `
-Method POST `
-Headers $Headers `
-Body (ConvertTo-Json $ReleaseData -Depth 10)
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create GitHub release."
exit $LASTEXITCODE
}
Write-Host "Release created successfully."
# Get the release ID from the response
$ReleaseId = $ReleaseResponse.id
Write-Host "Release ID: $ReleaseId"
# Step 7: Upload .exe File to Release
Write-Host "Uploading .exe file to GitHub release..."
$ExeFilePath = "$ArtifactsPath\$($InstallerFile.Name)"
if (-Not (Test-Path $ExeFilePath)) {
Write-Error "Built .exe file not found: $ExeFilePath"
exit 1
}
# GitHub API for uploading release assets
$UploadUrl = $ReleaseResponse.upload_url -replace "{.*}", ""
# Upload the file
$FileHeaders = @{
Authorization = "Bearer $ReleaseToken"
ContentType = "application/octet-stream"
}
$FileName = [System.IO.Path]::GetFileName($ExeFilePath)
Invoke-RestMethod `
-Uri "$($UploadUrl)?name=$FileName" `
-Method POST `
-Headers $FileHeaders `
-InFile $ExeFilePath `
-ContentType "application/octet-stream"
if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to upload .exe file to release."
exit $LASTEXITCODE
}
Write-Host "File uploaded successfully: $FileName"
# Step 7: Trigger GitHub Pages Rebuild
#Write-Host "Triggering GitHub Pages rebuild..."
#Invoke-RestMethod `
# -Uri "https://api.github.com/repos/greenshot/greenshot/pages/builds" `
# -Method POST `
# -Headers $Headers
#if ($LASTEXITCODE -ne 0) {
# Write-Error "Failed to trigger GitHub Pages rebuild."
# exit $LASTEXITCODE
#}
#
#Write-Host "GitHub Pages rebuild triggered successfully."

View file

@ -7,6 +7,7 @@
#define BinDir "bin\Release\net472"
#define ReleaseDir "..\..\src\Greenshot\bin\Release\net472"
#define PluginDir "..\..\src\Greenshot\bin\Release\net472\Plugins"
#define CertumThumbprint GetEnv('CertumThumbprint')
; Include the scripts to install .NET Framework
; See https://www.codeproject.com/KB/install/dotnetfx_innosetup_instal.aspx
@ -132,15 +133,17 @@ InfoBeforeFile=..\additional_files\readme.txt
LicenseFile=..\additional_files\license.txt
LanguageDetectionMethod=uilanguage
MinVersion=6.1sp1
OutputBaseFilename={#ExeName}-INSTALLER-{#Version}-UNSTABLE
OutputDir=..\
PrivilegesRequired=lowest
PrivilegesRequiredOverridesAllowed=commandline
SetupIconFile=..\..\src\Greenshot\icons\applicationIcon\icon.ico
; Create a SHA1 signature
; SignTool=SignTool sign /debug /fd sha1 /tr https://time.certum.pl /td sha1 $f
; Append a SHA256 to the previous SHA1 signature (this is what as does)
; SignTool=SignTool sign /debug /as /fd sha256 /tr https://time.certum.pl /td sha256 $f
; SignedUninstaller=yes
#if CertumThumbprint != ""
OutputBaseFilename={#ExeName}-INSTALLER-{#Version}-UNSTABLE
SignTool=SignTool sign /sha1 "{#CertumThumbprint}" /tr http://time.certum.pl /td sha256 /fd sha256 /v $f
SignedUninstaller=yes
#else
OutputBaseFilename={#ExeName}-INSTALLER-{#Version}-UNSTABLE-UNSIGNED
#endif
UninstallDisplayIcon={app}\{#ExeName}.exe
Uninstallable=true
VersionInfoCompany={#ExeName}

6
nuget.config Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>

View file

@ -1,13 +1,65 @@
<Project>
<UsingTask TaskName="ApplyTokenReplacements" TaskFactory="CodeTaskFactory" AssemblyName="Microsoft.Build.Tasks.Core">
<ParameterGroup>
<InputLines ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<Tokens ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
<OutputLines ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var output = new List<ITaskItem>();
foreach (var line in InputLines)
{
string text = line.ItemSpec;
foreach (var token in Tokens)
{
string tokenName = token.ItemSpec;
// Skip if tokenName is null or empty
if (string.IsNullOrEmpty(tokenName))
continue;
string replacementValue = token.GetMetadata("ReplacementValue");
if (!string.IsNullOrEmpty(replacementValue))
{
string placeholder = "$"+ "{"+tokenName+"}"; // Token-Format wie $(Box13_ClientId)
text = text.Replace(placeholder, replacementValue);
}
}
output.Add(new Microsoft.Build.Utilities.TaskItem(text));
}
OutputLines = output.ToArray();
]]>
</Code>
</Task>
</UsingTask>
<PropertyGroup Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')">
<MSBuildCommunityTasksPath>$(PkgMSBuildTasks)\tools\</MSBuildCommunityTasksPath>
<MSBuildCommunityTasksPath>$(NuGetPackageRoot)msbuildtasks/1.5.0.235/tools/</MSBuildCommunityTasksPath>
</PropertyGroup>
<Import Project="$(MSBuildCommunityTasksPath)MSBuild.Community.Tasks.Targets" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')"/>
<Import Project="$(MSBuildCommunityTasksPath)MSBuild.Community.Tasks.Targets" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')" />
<Target Name="ProcessTemplates" BeforeTargets="PrepareForBuild" Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')">
<Message Text="Processing: $(ProjectDir)$(ProjectName).Credentials.template" Importance="high"/>
<TemplateFile Template="$(ProjectDir)$(ProjectName).Credentials.template" OutputFilename="$(ProjectDir)$(ProjectName).Credentials.cs" Tokens="@(Tokens)" />
<Message Text="Processing: $(ProjectDir)$(ProjectName).Credentials.template" Importance="high"/>
<ReadLinesFromFile File="$(ProjectDir)$(ProjectName).Credentials.template">
<Output TaskParameter="Lines" ItemName="TemplateLines" />
</ReadLinesFromFile>
<ApplyTokenReplacements InputLines="@(TemplateLines)" Tokens="@(Tokens)">
<Output TaskParameter="OutputLines" ItemName="ProcessedLines" />
</ApplyTokenReplacements>
<WriteLinesToFile
File="$(ProjectDir)$(ProjectName).Credentials.cs"
Lines="@(ProcessedLines)"
Overwrite="true" />
</Target>
</Project>
</Project>

View file

@ -24,6 +24,7 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Dapplo.Windows.Common.Extensions;
using Dapplo.Windows.Common.Structs;
using Greenshot.Base.Interfaces;
@ -187,6 +188,8 @@ namespace Greenshot.Editor.Drawing
/// <param name="rm"></param>
public override void Draw(Graphics graphics, RenderMode rm)
{
if (Width == 0 || Height == 0) { return; }
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
@ -205,9 +208,17 @@ namespace Greenshot.Editor.Drawing
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
}
float fontSize = Math.Min(Math.Abs(Width), Math.Abs(Height)) / 1.4f;
using FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name);
using Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);
using FontFamily fam = new(FontFamily.GenericSansSerif.Name);
//calculate new font size based on ratio from text height and text width
float initialFontSize = Math.Min(Math.Abs(Width), Math.Abs(Height));
using Font Measurefont = new(fam, initialFontSize, FontStyle.Bold, GraphicsUnit.Pixel);
var fontSize = initialFontSize * TextRenderer.MeasureText(text, Measurefont).Height / TextRenderer.MeasureText(text, Measurefont).Width;
//static scale for optimal fit
fontSize *= 0.7f;
using Font font = new(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font);
}

View file

@ -1023,6 +1023,9 @@ namespace Greenshot.Editor.Forms
case Keys.C:
BtnCropClick(sender, e);
break;
case Keys.Z:
BtnResizeClick(sender, e);
break;
}
}
else if (e.Modifiers.Equals(Keys.Control))

View file

@ -54,6 +54,7 @@ namespace Greenshot.Editor.Helpers
{"System.Collections.Generic.List`1[[Greenshot.Base.Interfaces.Drawing.IField", typeof(List<IField>)},
{"System.Collections.Generic.List`1[[System.Drawing.Point", typeof(List<System.Drawing.Point>)},
{"Greenshot.Editor.Drawing.ArrowContainer", typeof(ArrowContainer) },
{"Greenshot.Editor.Drawing.ArrowContainer+ArrowHeadCombination", typeof(ArrowContainer.ArrowHeadCombination) },
{"Greenshot.Editor.Drawing.LineContainer", typeof(LineContainer) },
{"Greenshot.Editor.Drawing.TextContainer", typeof(TextContainer) },
{"Greenshot.Editor.Drawing.SpeechbubbleContainer", typeof(SpeechbubbleContainer) },

View file

@ -202,7 +202,7 @@ namespace Greenshot.Editor.Helpers
{
// scaled rectangle (ratio) would be taller than original
// keep width and tweak height to maintain aspect ratio
newSize = newSize.ChangeWidth(selectedSize.Width / originalRatio * flippedRatioSign);
newSize = newSize.ChangeHeight(selectedSize.Width / originalRatio * flippedRatioSign);
}
return newSize;

View file

@ -1,4 +1,4 @@
/*
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*

View file

@ -1,43 +1,45 @@
using System.Linq;
using Microsoft.Win32;
namespace Greenshot.Plugin.Office;
/// <summary>
/// A small utility class for helping with office
/// </summary>
internal static class OfficeUtils
namespace Greenshot.Plugin.Office
{
private static readonly string[] OfficeRootKeys = { @"SOFTWARE\Microsoft\Office", @"SOFTWARE\WOW6432Node\Microsoft\Office" };
/// <summary>
/// Get the path to the office exe
/// A small utility class for helping with office
/// </summary>
/// <param name="exeName">Name of the office executable</param>
public static string GetOfficeExePath(string exeName)
internal static class OfficeUtils
{
string strKeyName = exeName switch
{
"WINWORD.EXE" => "Word",
"EXCEL.EXE" => "Excel",
"POWERPNT.EXE" => "PowerPoint",
"OUTLOOK.EXE" => "Outlook",
"ONENOTE.EXE" => "OneNote",
_ => ""
};
private static readonly string[] OfficeRootKeys = { @"SOFTWARE\Microsoft\Office", @"SOFTWARE\WOW6432Node\Microsoft\Office" };
foreach (string strRootKey in OfficeRootKeys)
/// <summary>
/// Get the path to the office exe
/// </summary>
/// <param name="exeName">Name of the office executable</param>
public static string GetOfficeExePath(string exeName)
{
using RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(strRootKey);
if (rootKey is null) continue;
foreach (string officeVersion in rootKey.GetSubKeyNames().Where(r => r.Contains(".")).Reverse())
string strKeyName = exeName switch
{
using RegistryKey installRootKey = Registry.LocalMachine.OpenSubKey($@"{strRootKey}\{officeVersion}\{strKeyName}\InstallRoot");
if (installRootKey == null) continue;
return $@"{installRootKey.GetValue("Path")}\{exeName}";
"WINWORD.EXE" => "Word",
"EXCEL.EXE" => "Excel",
"POWERPNT.EXE" => "PowerPoint",
"OUTLOOK.EXE" => "Outlook",
"ONENOTE.EXE" => "OneNote",
_ => ""
};
foreach (string strRootKey in OfficeRootKeys)
{
using RegistryKey rootKey = Registry.LocalMachine.OpenSubKey(strRootKey);
if (rootKey is null) continue;
foreach (string officeVersion in rootKey.GetSubKeyNames().Where(r => r.Contains(".")).Reverse())
{
using RegistryKey installRootKey = Registry.LocalMachine.OpenSubKey($@"{strRootKey}\{officeVersion}\{strKeyName}\InstallRoot");
if (installRootKey == null) continue;
return $@"{installRootKey.GetValue("Path")}\{exeName}";
}
}
return null;
}
return null;
}
}
}

View file

@ -95,7 +95,17 @@ namespace Greenshot.Plugin.Win10
}
// Prepare the toast notifier. Be sure to specify the AppUserModelId on your application's shortcut!
var toastNotifier = ToastNotificationManagerCompat.CreateToastNotifier();
Microsoft.Toolkit.Uwp.Notifications.ToastNotifierCompat toastNotifier = null;
try
{
toastNotifier = ToastNotificationManagerCompat.CreateToastNotifier();
}
catch (Exception ex)
{
Log.Warn("Could not create a toast notifier.", ex);
return;
}
// Here is an interesting article on reading the settings: https://www.rudyhuyn.com/blog/2018/02/10/toastnotifier-and-settings-careful-with-non-uwp-applications/
try

View file

@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29728.190
# Visual Studio Version 17
VisualStudioVersion = 17.7.34009.444
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot", "Greenshot\Greenshot.csproj", "{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}"
ProjectSection(ProjectDependencies) = postProject
@ -48,6 +48,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
..\azure-pipelines.yml = ..\azure-pipelines.yml
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
..\.github\workflows\release.yml = ..\.github\workflows\release.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Editor", "Greenshot.Editor\Greenshot.Editor.csproj", "{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}"

View file

@ -17,6 +17,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" Version="17.13.9" />
<PackageReference Include="Tools.InnoSetup" version="6.2.1" GeneratePathProperty="true" />
</ItemGroup>
@ -75,6 +76,7 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent" Condition="'$(Configuration)' == 'Release'">
<SetEnvironmentVariableTask Name="BuildVersionSimple" Value="$(BuildVersionSimple)" />
<SetEnvironmentVariableTask Name="AssemblyInformationalVersion" Value="$(AssemblyInformationalVersion)" />
<Exec Command="if not &quot;$(CertumThumbprint)&quot; == &quot;&quot; signtool.exe sign /sha1 &quot;$(CertumThumbprint)&quot; /tr http://time.certum.pl /td sha256 /fd sha256 /v &quot;$(OutDir)Greenshot.exe&quot;" />
<Exec Command="$(PkgTools_InnoSetup)\tools\ISCC.exe $(SolutionDir)\..\installer\innosetup\setup.iss" />
</Target>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">

View file

@ -305,7 +305,7 @@ Malgrat això, encara es poden utilitzar totes les característiques de Greensho
<resource name="editor_counter">Afegeix un comptador (I)</resource>
<resource name="editor_speechbubble">Afegeix una bafarada (S)</resource>
<resource name="editor_resize">Canvia la mida</resource>
<resource name="editor_resize">Canvia la mida (Z)</resource>
<resource name="editor_resize_settings">Configuració del canvi de mida</resource>
<resource name="editor_resize_aspectratio">Manté la relació d'aspecte</resource>
<resource name="editor_resize_width">Amplada</resource>

View file

@ -308,7 +308,7 @@ Všechny funkce Greenshotu jsou stále dostupné přímo z místní nabídky bez
<resource name="editor_counter">Přidat počítadlo (I)</resource>
<resource name="editor_speechbubble">Přidat textovou bublinu (S)</resource>
<resource name="editor_resize">Změnit velikost</resource>
<resource name="editor_resize">Změnit velikost (Z)</resource>
<resource name="editor_resize_settings">Nastavení změny velikosti</resource>
<resource name="editor_resize_aspectratio">Zachovat poměr stran</resource>
<resource name="editor_resize_width">Šířka</resource>

View file

@ -312,7 +312,7 @@ Sie können aber auch alle Greenshot-Funktionen über das Kontextmenü des Green
<resource name="editor_counter">Zähler hinzufügen (I)</resource>
<resource name="editor_speechbubble">Sprechblase hinzufügen (S)</resource>
<resource name="editor_resize">Skalieren</resource>
<resource name="editor_resize">Skalieren (Z)</resource>
<resource name="editor_resize_settings">Einstellungen für Skalierung</resource>
<resource name="editor_resize_aspectratio">Seitenverhältnis beibehalten</resource>
<resource name="editor_resize_width">Breite</resource>

View file

@ -312,7 +312,7 @@ All Greenshot features still work directly from the tray icon context menu witho
<resource name="editor_counter">Add counter (I)</resource>
<resource name="editor_speechbubble">Add speechbubble (S)</resource>
<resource name="editor_resize">Resize</resource>
<resource name="editor_resize">Resize (Z)</resource>
<resource name="editor_resize_settings">Resize settings</resource>
<resource name="editor_resize_aspectratio">Maintain aspect ratio</resource>
<resource name="editor_resize_width">Width</resource>

View file

@ -144,7 +144,7 @@ De plus, nous apprécierions beaucoup que vous preniez la peine de vérifier si
<resource name="editor_print">Imprimer</resource>
<resource name="editor_redo">Rétablir {0}</resource>
<resource name="editor_resetsize">Réinitialiser la taille</resource>
<resource name="editor_resize">Redimensionner</resource>
<resource name="editor_resize">Redimensionner (Z)</resource>
<resource name="editor_resize_aspectratio">Maintenir le rapport L / H</resource>
<resource name="editor_resize_height">Hauteur</resource>
<resource name="editor_resize_percent">Pourcentage</resource>

View file

@ -144,7 +144,7 @@ Juga, kami sangat terbantu apabila anda mengecek laporan lain yang sama dengan k
<resource name="editor_print">Cetak</resource>
<resource name="editor_redo">Ulang {0}</resource>
<resource name="editor_resetsize">Reset ukuran</resource>
<resource name="editor_resize">Ubah ukuran</resource>
<resource name="editor_resize">Ubah ukuran (Z)</resource>
<resource name="editor_resize_aspectratio">Pertahankan aspek rasio</resource>
<resource name="editor_resize_height">Tinggi</resource>
<resource name="editor_resize_percent">Persen</resource>

View file

@ -322,7 +322,7 @@ In alternativa alle scorciatoie di tastiera, tutte le funzioni di Greenshot sono
<resource name="editor_counter">Aggiungi conteggio</resource>
<resource name="editor_speechbubble">Aggiungi nuvoletta</resource>
<resource name="editor_resize">Ridimensiona</resource>
<resource name="editor_resize">Ridimensiona (Z)</resource>
<resource name="editor_resize_settings">Impostazioni ridimensionamento</resource>
<resource name="editor_resize_aspectratio">Mantieni rapporto dimensioni</resource>
<resource name="editor_resize_width">Larghezza</resource>

View file

@ -143,7 +143,7 @@ Greenshot には一切の保障がありません。GNU General Public License
<resource name="editor_print">印刷</resource>
<resource name="editor_redo">やり直し{0}</resource>
<resource name="editor_resetsize">サイズをリセット</resource>
<resource name="editor_resize">リサイズ</resource>
<resource name="editor_resize">リサイズ (Z)</resource>
<resource name="editor_resize_aspectratio">縦横比を維持する</resource>
<resource name="editor_resize_height">高さ</resource>
<resource name="editor_resize_percent">パーセント</resource>

View file

@ -144,7 +144,7 @@ Rnu ɣur-s, nḥemmel aṭas ma yella tesneqdeḍ aneqqis igebren ugur-agi. (Tze
<resource name="editor_print">Siggez</resource>
<resource name="editor_redo">Err-d {0}</resource>
<resource name="editor_resetsize">Wennez teɣzi</resource>
<resource name="editor_resize">Snifel tahri/teɣzi</resource>
<resource name="editor_resize">Snifel tahri/teɣzi (Z)</resource>
<resource name="editor_resize_aspectratio">Eǧǧ afmiḍi Teɣ / Teh</resource>
<resource name="editor_resize_height">Awrir</resource>
<resource name="editor_resize_percent">Afmiḍi</resource>

View file

@ -304,7 +304,7 @@ ${hostname} PC명
<resource name="editor_counter">카운터 더하기 (I)</resource>
<resource name="editor_speechbubble">설명선 더하기(S)</resource>
<resource name="editor_resize">크기조정</resource>
<resource name="editor_resize">크기조정 (Z)</resource>
<resource name="editor_resize_settings">크기조정 설정</resource>
<resource name="editor_resize_aspectratio">종횡비 유지</resource>
<resource name="editor_resize_width">너비</resource>

View file

@ -306,7 +306,7 @@ Arī bez karstiem taustiņiem visas darbības iespējams veikt izmantojot „Gre
<resource name="editor_counter">Pievienot skaitli (I)</resource>
<resource name="editor_speechbubble">Pievienot teksta norādi (S)</resource>
<resource name="editor_resize">Mainīt izmēru</resource>
<resource name="editor_resize">Mainīt izmēru (Z)</resource>
<resource name="editor_resize_settings">Izmēra maiņas iestatījumi</resource>
<resource name="editor_resize_aspectratio">Saglabāt izmēru attiecības</resource>
<resource name="editor_resize_width">Platums</resource>

View file

@ -307,7 +307,7 @@ Alle Greenshot functies werken ook zonder sneltoetsen via het context menu.</res
<resource name="editor_counter">Teller toevoegen (I)</resource>
<resource name="editor_speechbubble">Tekstballon toevoegen (S)</resource>
<resource name="editor_resize">Grootte</resource>
<resource name="editor_resize">Grootte (Z)</resource>
<resource name="editor_resize_settings">Vergrotingsinstellingen</resource>
<resource name="editor_resize_aspectratio">Verhouding behouden</resource>
<resource name="editor_resize_width">Breedte</resource>

View file

@ -305,7 +305,7 @@ Todas as funcionalidades do Greenshot funcionam directamente através do menu de
<resource name="editor_counter">Adicionar contador (I)</resource>
<resource name="editor_speechbubble">Adicionar balão de texto (S)</resource>
<resource name="editor_resize">Redimensionar</resource>
<resource name="editor_resize">Redimensionar (Z)</resource>
<resource name="editor_resize_settings">Definições de Redimensionamento</resource>
<resource name="editor_resize_aspectratio">Manter proporções</resource>
<resource name="editor_resize_width">Largura</resource>

View file

@ -305,7 +305,7 @@ Alla Greenshots funktioner fungerar fortfarande från snabbmenyn i aktivitetsfä
<resource name="editor_counter">Lägg till räknare</resource>
<resource name="editor_speechbubble">Lägg till pratbubbla</resource>
<resource name="editor_resize">Anpassa storlek</resource>
<resource name="editor_resize">Anpassa storlek (Z)</resource>
<resource name="editor_resize_settings">Storleksinställningar</resource>
<resource name="editor_resize_aspectratio">Behåll bildförhållande</resource>
<resource name="editor_resize_width">Bredd</resource>

View file

@ -306,7 +306,7 @@ ${hostname} назва комп’ютера
<resource name="editor_counter">Додати лічильник (Ш)</resource>
<resource name="editor_speechbubble">Додати словесну бульбашку (І)</resource>
<resource name="editor_resize">Змінити розмір</resource>
<resource name="editor_resize">Змінити розмір (Z)</resource>
<resource name="editor_resize_settings">Параметри зміни розміру</resource>
<resource name="editor_resize_aspectratio">Зберігати пропорції</resource>
<resource name="editor_resize_width">Ширина</resource>

View file

@ -307,7 +307,7 @@ Greenshot 所有功能仍然可以直接從通知區圖示的內容功能表動
<resource name="editor_counter">加入計數器 (I)</resource>
<resource name="editor_speechbubble">加入對話框 (S)</resource>
<resource name="editor_resize">縮放</resource>
<resource name="editor_resize">縮放 (Z)</resource>
<resource name="editor_resize_settings">縮放設定</resource>
<resource name="editor_resize_aspectratio">維持長寬比</resource>
<resource name="editor_resize_width">長度</resource>