Compare commits

..

No commits in common. "release/1.3" and "v1.3.63" have entirely different histories.

1585 changed files with 83615 additions and 96368 deletions

9
.github/FUNDING.yml vendored
View file

@ -1,9 +0,0 @@
# These are supported funding model platforms
# Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
github: lakritzator
patreon: # Replace with a single Patreon username
open_collective: greenshot
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
custom: https://getgreenshot.org/support/

View file

@ -1,33 +0,0 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
This GitHub repository is for developers, if you want to report a bug for Greenshot as a user please do so in our JIRA issue system here: https://greenshot.atlassian.net/projects/BUGS/issues/filter=allopenissues
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Example steps to reproduce the behavior:
1. Capture '....'
2. Open Editor
3. Add a line
4. Resize
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Versions (please complete the following information):**
- Greenshot version
- Windows version
**Additional context**
Add any other context about the problem here.

View file

@ -1,33 +0,0 @@
---
name: Developer Bug report
about: Create a bug report to help us improve our code
title: ''
labels: ''
assignees: ''
---
This GitHub repository is for developers, if you want to report a bug for Greenshot as a user please do so in our JIRA issue system here: https://greenshot.atlassian.net/projects/BUGS/issues/filter=allopenissues
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Example steps to reproduce the behavior:
1. Capture '....'
2. Open Editor
3. Add a line
4. Resize
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Versions (please complete the following information):**
- Greenshot version
- Windows version
**Additional context**
Add any other context about the problem here.

View file

@ -1,22 +0,0 @@
---
name: Developer feature request
about: Suggest an technical idea for this project
title: ''
labels: ''
assignees: ''
---
This GitHub repository is for developers, if you want to request a feature for Greenshot as a user please do so in our JIRA issue system here: https://greenshot.atlassian.net/projects/FEATURE/issues/filter=allopenissues
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View file

@ -1,22 +0,0 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---
This GitHub repository is for developers, if you want to request a feature for Greenshot as a user please do so in our JIRA issue system here: https://greenshot.atlassian.net/projects/FEATURE/issues/filter=allopenissues
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.
**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
**Additional context**
Add any other context or screenshots about the feature request here.

View file

@ -1,14 +0,0 @@
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 }}

View file

@ -1,163 +0,0 @@
env:
IS_RELEASE_BRANCH: ${{ startsWith(github.ref, 'refs/heads/release/') }}
BRANCH_NAME: ${{ github.ref_name }}
name: Build and Deploy
on:
workflow_dispatch:
push:
branches:
- 'release/1.*'
paths-ignore:
- '.github/**'
- '.gitignore'
- '*.md'
- 'LICENSE'
- 'build-and-deploy.ps1'
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
if: env.IS_RELEASE_BRANCH == 'true'
id: version_from_filename
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: Set version from sanitized branch name
if: env.IS_RELEASE_BRANCH != 'true'
id: version_from_branchname
run: |
$branch = "${{ github.ref }}" -replace '^refs/heads/', ''
$sanitized = $branch -replace '[^a-zA-Z0-9._-]', '_'
echo "version=$sanitized" >> $Env:GITHUB_OUTPUT
shell: pwsh
- name: Set version info
id: version_info
run: |
echo "version=${{ steps.version_from_filename.outputs.version || steps.version_from_branchname.outputs.version }}" >> $GITHUB_OUTPUT
shell: bash
- name: Create tag
if: env.IS_RELEASE_BRANCH == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "v${{ steps.version_info.outputs.version }}" -m "v${{ steps.version_info.outputs.version }}"
git push origin "v${{ steps.version_info.outputs.version }}"
- name: Rename installer for non-release branch
if: env.IS_RELEASE_BRANCH != 'true'
run: |
branch="${BRANCH_NAME:-${GITHUB_REF#refs/heads/}}"
sanitized=$(echo "$branch" | sed 's/[^a-zA-Z0-9._-]/_/g')
mv drop/Greenshot-INSTALLER-*.exe "drop/Greenshot-INSTALLER-${sanitized}.exe"
shell: bash
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
name: "Greenshot ${{ steps.version_info.outputs.version }} (continuous build)"
tag_name: ${{ env.IS_RELEASE_BRANCH == 'true' && format('v{0}', steps.version_info.outputs.version) || env.BRANCH_NAME }}
files: drop/*.exe
generate_release_notes: true
draft: ${{ env.IS_RELEASE_BRANCH != 'true' }}
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

View file

@ -1,18 +0,0 @@
name: Update GitHub Pages
on:
workflow_dispatch:
release:
types: [published, unpublished, created, edited, deleted, prereleased, released]
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

7
.gitignore vendored
View file

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

View file

@ -1,46 +0,0 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at getgreenshot@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/

View file

@ -1,18 +0,0 @@
The general rule we follow is "use Visual Studio defaults".
1. We use [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style) braces, where each brace begins on a new line. A single line statement block can go without braces but the block must be properly indented on its own line and it must not be nested in other statement blocks that use braces (See issue [381](https://github.com/dotnet/corefx/issues/381) for examples).
2. We use four spaces of indentation (no tabs).
3. We use `_camelCase` for internal and private fields and use `readonly` where possible. Prefix instance fields with `_`, static fields with `s_` and thread static fields with `t_`. When used on static fields, `readonly` should come after `static` (e.g. `static readonly` not `readonly static`).
4. We avoid `this.` unless absolutely necessary.
5. We always specify the visibility, even if it's the default (e.g. `private string _foo` not `string _foo`). Visibility should be the first modifier (e.g. `public abstract` not `abstract public`).
6. Namespace imports should be specified at the top of the file, *outside* of `namespace` declarations and should be sorted alphabetically.
7. Avoid more than one empty line at any time. For example, do not have two blank lines between members of a type.
8. Avoid spurious free spaces. For example avoid `if (someVar == 0)...`, where the dots mark the spurious free spaces. Consider enabling "View White Space (Ctrl+E, S)" if using Visual Studio, to aid detection.
9. If a file happens to differ in style from these guidelines (e.g. private members are named `m_member` rather than `_member`), the existing style in that file takes precedence.
10. We only use `var` when it's obvious what the variable type is (e.g. `var stream = new FileStream(...)` not `var stream = OpenStandardInput()`).
11. We use language keywords instead of BCL types (e.g. `int, string, float` instead of `Int32, String, Single`, etc) for both type references as well as method calls (e.g. `int.Parse` instead of `Int32.Parse`). See issue [391](https://github.com/dotnet/corefx/issues/391) for examples.
12. We use PascalCasing to name all our constant local variables and fields. The only exception is for interop code where the constant value should exactly match the name and value of the code you are calling via interop.
13. We use ```nameof(...)``` instead of ```"..."``` whenever possible and relevant.
14. Fields should be specified at the top within type declarations.
15. When including non-ASCII characters in the source code use Unicode escape sequences (\uXXXX) instead of literal characters. Literal non-ASCII characters occasionally get garbled by a tool or editor.
16. Do not use labels (e.g. for goto).

View file

@ -1,116 +1,135 @@
<Project>
<PropertyGroup>
<Copyright>Copyright © Greenshot 2004-2022</Copyright>
<Authors>Greenshot</Authors>
<PackageIconUrl>https://getgreenshot.org/favicon.ico</PackageIconUrl>
<RepositoryUrl>https://github.com/greenshot/greenshot</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/greenshot/greenshot</PackageProjectUrl>
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<RuntimeIdentifiers>win10-x64;win10-x86;win-x64;win-x86</RuntimeIdentifiers>
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<TargetFramework>net472</TargetFramework>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' != 'Debug' And !$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))">
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup Condition="$(MSBuildProjectName.Contains('Tests')) Or $(MSBuildProjectName.Contains('Demo'))">
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<DebugType>embedded</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize>
<DebugType>embedded</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup Condition="!$(MSBuildProjectName.Contains('Tests')) And $(MSBuildProjectName.StartsWith('Greenshot'))">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.5.113">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>
<ItemGroup>
<Tokens Include="Box13_ClientId">
<ReplacementValue>$(Box13_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Box13_ClientSecret">
<ReplacementValue>$(Box13_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="DropBox13_ClientId">
<ReplacementValue>$(DropBox13_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="DropBox13_ClientSecret">
<ReplacementValue>$(DropBox13_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="Flickr_ClientId">
<ReplacementValue>$(Flickr_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Flickr_ClientSecret">
<ReplacementValue>$(Flickr_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="Imgur13_ClientId">
<ReplacementValue>$(Imgur13_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Imgur13_ClientSecret">
<ReplacementValue>$(Imgur13_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="Photobucket_ClientId">
<ReplacementValue>$(Photobucket_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Photobucket_ClientSecret">
<ReplacementValue>$(Photobucket_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="Picasa_ClientId">
<ReplacementValue>$(Picasa_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Picasa_ClientSecret">
<ReplacementValue>$(Picasa_ClientSecret)</ReplacementValue>
</Tokens>
</ItemGroup>
<!-- Add MSBuild.Community.Tasks to use the TemplateFile Task-->
<ItemGroup>
<PackageReference Include="MSBuildTasks" Version="1.5.0.235" GeneratePathProperty="true" DevelopmentDependency="true" />
</ItemGroup>
<Target Name="PostBuild" BeforeTargets="PostBuildEvent" Condition="$(MSBuildProjectName.StartsWith('Greenshot.Plugin.'))">
<Exec Command="
IF NOT EXIST &quot;$(SolutionDir)$(SolutionName)\$(OutDir)Plugins\$(TargetName)&quot; (&#xD;&#xA;
mkdir &quot;$(SolutionDir)$(SolutionName)\$(OutDir)Plugins\$(TargetName)&quot;&#xD;&#xA;
)&#xD;&#xA;
xcopy /f /y /d &quot;$(TargetDir)$(TargetName).*&quot; &quot;$(SolutionDir)$(SolutionName)\$(OutDir)\Plugins\$(TargetName)&quot;&#xD;&#xA;
xcopy /f /y /d &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)$(SolutionName)\$(OutDir)\Plugins\$(TargetName)&quot;&#xD;&#xA;
IF EXIST &quot;$(TargetDir)Languages&quot; (&#xD;&#xA;
IF NOT EXIST &quot;$(SolutionDir)$(SolutionName)\$(OutDir)Languages\$(TargetName)&quot; (&#xD;&#xA;
mkdir &quot;$(SolutionDir)$(SolutionName)\$(OutDir)Languages\$(TargetName)&quot;&#xD;&#xA;
)&#xD;&#xA;
xcopy /f /y /d &quot;$(TargetDir)Languages\*en-US.xml&quot; &quot;$(SolutionDir)$(SolutionName)\$(OutDir)Languages\$(TargetName)&quot;&#xD;&#xA;
)
for /f &quot;tokens=*&quot; %%F in ('dir /b /A-D $(SolutionDir)$(SolutionName)\$(OutDir)') do if EXIST &quot;$(SolutionDir)$(SolutionName)\$(OutDir)\Plugins\$(TargetName)\%%F&quot; (&#xD;&#xA;echo %%F&#xD;&#xA;del &quot;$(SolutionDir)$(SolutionName)\$(OutDir)\Plugins\$(TargetName)\%%F&quot;&#xD;&#xA;)&#xD;&#xA;
" />
</Target>
</Project>
<Project>
<PropertyGroup>
<Copyright>Copyright © Greenshot 2004-2020</Copyright>
<Authors>Greenshot</Authors>
<PackageIconUrl>https://getgreenshot.org/favicon.ico</PackageIconUrl>
<RepositoryUrl>https://github.com/greenshot/greenshot</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageProjectUrl>https://github.com/greenshot/greenshot</PackageProjectUrl>
<PackageLicenseUrl>https://www.gnu.org/licenses/gpl.html</PackageLicenseUrl>
<PackageLicenseExpression>GPL</PackageLicenseExpression>
<LangVersion>latest</LangVersion>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<RuntimeIdentifiers>win10-x64;win10-x86;win-x64;win-x86</RuntimeIdentifiers>
<!-- Optional: Publish the repository URL in the built .nupkg (in the NuSpec <Repository> element) -->
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<!-- Optional: Embed source files that are not tracked by the source control manager in the PDB -->
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<TargetFramework>net472</TargetFramework>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
</PropertyGroup>
<!-- ILLinker and single file settings -->
<ItemGroup Condition="$(MSBuildProjectName) == 'Greenshot'">
<TrimmerRootAssembly Include="netstandard" />
</ItemGroup>
<PropertyGroup Condition="$(MSBuildProjectName) == 'Greenshot'">
<IncludeSymbolsInSingleFile>false</IncludeSymbolsInSingleFile>
<ShowLinkerSizeComparison>true</ShowLinkerSizeComparison>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' != 'Debug' And !$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))">
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<IsPackable>true</IsPackable>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup Condition="$(MSBuildProjectName.Contains('Tests')) Or $(MSBuildProjectName.Contains('Demo'))">
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Debug'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<DebugType>embedded</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<Optimize>true</Optimize>
<DebugType>embedded</DebugType>
<DebugSymbols>True</DebugSymbols>
</PropertyGroup>
<ItemGroup Condition="!$(MSBuildProjectName.Contains('Tests')) And $(MSBuildProjectName.StartsWith('Greenshot'))">
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
</ItemGroup>
<Target Name="Test Variables" BeforeTargets="PrepareForBuild" >
<Message Text="Box Client Id $(Box_ClientId)" Importance="high"/>
<Message Text="DropBox Client Id $(DropBox_ClientId)" Importance="high"/>
<Message Text="Flickr Client Id $(Flickr_ClientId)" Importance="high"/>
<Message Text="Photobucket Client Id $(Photobucket_ClientId)" Importance="high"/>
<Message Text="Picasa Client Id $(Picasa_ClientId)" Importance="high"/>
</Target>
<ItemGroup>
<Tokens Include="Box_ClientId">
<ReplacementValue>$(Box_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Box_ClientSecret">
<ReplacementValue>$(Box_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="DropBox_ClientId">
<ReplacementValue>$(DropBox_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="DropBox_ClientSecret">
<ReplacementValue>$(DropBox_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="Flickr_ClientId">
<ReplacementValue>$(Flickr_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Flickr_ClientSecret">
<ReplacementValue>$(Flickr_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="Imgur_ClientId">
<ReplacementValue>$(Imgur_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Imgur_ClientSecret">
<ReplacementValue>$(Imgur_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="Photobucket_ClientId">
<ReplacementValue>$(Photobucket_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Photobucket_ClientSecret">
<ReplacementValue>$(Photobucket_ClientSecret)</ReplacementValue>
</Tokens>
<Tokens Include="Picasa_ClientId">
<ReplacementValue>$(Picasa_ClientId)</ReplacementValue>
</Tokens>
<Tokens Include="Picasa_ClientSecret">
<ReplacementValue>$(Picasa_ClientSecret)</ReplacementValue>
</Tokens>
</ItemGroup>
<ItemGroup Condition="Exists('$(ProjectDir)$(ProjectName).Credentials.template')">
<PackageReference Include="MSBuildTasks" Version="1.5.0.235" GeneratePathProperty="true"/>
</ItemGroup>
<Import Project="$(PkgTools_MSBuildTasks)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)" />
</Target>
<Target Name="PostBuild" BeforeTargets="PostBuildEvent" Condition="$(MSBuildProjectName.Contains('Plugin')) And !$(MSBuildProjectName.Contains('Test')) And !$(MSBuildProjectName.Contains('Demo'))">
<Exec Command="
xcopy /f /y /d &quot;$(TargetDir)$(TargetName).*&quot; &quot;$(SolutionDir)$(SolutionName)\$(OutDir)&quot;&#xD;&#xA;
xcopy /f /y /d &quot;$(TargetDir)*.dll&quot; &quot;$(SolutionDir)$(SolutionName)\$(OutDir)&quot;&#xD;&#xA;
IF EXIST &quot;$(TargetDir)Languages&quot; (&#xD;&#xA;
IF NOT EXIST &quot;$(SolutionDir)$(SolutionName)\$(OutDir)Languages&quot; (&#xD;&#xA;
mkdir &quot;$(SolutionDir)$(SolutionName)\$(OutDir)Languages&quot;&#xD;&#xA;
)&#xD;&#xA;
xcopy /f /y /d &quot;$(TargetDir)Languages\*en-US.xml&quot; &quot;$(SolutionDir)$(SolutionName)\$(OutDir)Languages&quot;&#xD;&#xA;
)" />
</Target>
</Project>

View file

@ -1,183 +1,232 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# 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
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB} = {92599C09-FF29-4ABD-B6E6-C48ECD781BAB}
{19FEEF09-313F-43C7-819D-F1BCA782B08B} = {19FEEF09-313F-43C7-819D-F1BCA782B08B}
{9801F62C-540F-4BFE-9211-6405DEDE563B} = {9801F62C-540F-4BFE-9211-6405DEDE563B}
{9C0ECC4C-7807-4111-916A-4F57BB29788A} = {9C0ECC4C-7807-4111-916A-4F57BB29788A}
{C3052651-598A-44E2-AAB3-2E41311D50F9} = {C3052651-598A-44E2-AAB3-2E41311D50F9}
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E} = {7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}
{697CF066-9077-4F22-99D9-D989CCE7282B} = {697CF066-9077-4F22-99D9-D989CCE7282B}
{47F23C86-604E-4CC3-8767-B3D4088F30BB} = {47F23C86-604E-4CC3-8767-B3D4088F30BB}
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50} = {80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12} = {AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}
{1893A2E4-A78A-4713-A8E7-E70058DABEE0} = {1893A2E4-A78A-4713-A8E7-E70058DABEE0}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Base", "Greenshot.Base\Greenshot.Base.csproj", "{5B924697-4DCD-4F98-85F1-105CB84B7341}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.ExternalCommand", "Greenshot.Plugin.ExternalCommand\Greenshot.Plugin.ExternalCommand.csproj", "{47F23C86-604E-4CC3-8767-B3D4088F30BB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Confluence", "Greenshot.Plugin.Confluence\Greenshot.Plugin.Confluence.csproj", "{C3052651-598A-44E2-AAB3-2E41311D50F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Imgur", "Greenshot.Plugin.Imgur\Greenshot.Plugin.Imgur.csproj", "{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Jira", "Greenshot.Plugin.Jira\Greenshot.Plugin.Jira.csproj", "{19FEEF09-313F-43C7-819D-F1BCA782B08B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Box", "Greenshot.Plugin.Box\Greenshot.Plugin.Box.csproj", "{697CF066-9077-4F22-99D9-D989CCE7282B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Dropbox", "Greenshot.Plugin.Dropbox\Greenshot.Plugin.Dropbox.csproj", "{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Flickr", "Greenshot.Plugin.Flickr\Greenshot.Plugin.Flickr.csproj", "{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.GooglePhotos", "Greenshot.Plugin.GooglePhotos\Greenshot.Plugin.GooglePhotos.csproj", "{1893A2E4-A78A-4713-A8E7-E70058DABEE0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Office", "Greenshot.Plugin.Office\Greenshot.Plugin.Office.csproj", "{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Photobucket", "Greenshot.Plugin.Photobucket\Greenshot.Plugin.Photobucket.csproj", "{9C0ECC4C-7807-4111-916A-4F57BB29788A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot.Plugin.Win10", "Greenshot.Plugin.Win10\Greenshot.Plugin.Win10.csproj", "{9801F62C-540F-4BFE-9211-6405DEDE563B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{82987F1E-D7E6-4C44-B934-981D366E4672}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
..\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}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|x86.ActiveCfg = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|x86.Build.0 = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|Any CPU.Build.0 = Release|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|x86.ActiveCfg = Release|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|x86.Build.0 = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|x86.ActiveCfg = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|x86.Build.0 = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|Any CPU.Build.0 = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|x86.ActiveCfg = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|x86.Build.0 = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|x86.ActiveCfg = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|x86.Build.0 = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|Any CPU.Build.0 = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|x86.ActiveCfg = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|x86.Build.0 = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|x86.ActiveCfg = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|x86.Build.0 = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|Any CPU.Build.0 = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|x86.ActiveCfg = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|x86.Build.0 = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|x86.ActiveCfg = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|x86.Build.0 = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|Any CPU.Build.0 = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|x86.ActiveCfg = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|x86.Build.0 = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|x86.ActiveCfg = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|x86.Build.0 = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|Any CPU.Build.0 = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|x86.ActiveCfg = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|x86.Build.0 = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|x86.ActiveCfg = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|x86.Build.0 = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|Any CPU.Build.0 = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|x86.ActiveCfg = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|x86.Build.0 = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|x86.ActiveCfg = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|x86.Build.0 = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|Any CPU.Build.0 = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|x86.ActiveCfg = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|x86.Build.0 = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|x86.ActiveCfg = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|x86.Build.0 = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|Any CPU.Build.0 = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|x86.ActiveCfg = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|x86.Build.0 = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|x86.ActiveCfg = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|x86.Build.0 = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|Any CPU.Build.0 = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|x86.ActiveCfg = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|x86.Build.0 = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|x86.ActiveCfg = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|x86.Build.0 = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|Any CPU.Build.0 = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|x86.ActiveCfg = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|x86.Build.0 = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|x86.ActiveCfg = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|x86.Build.0 = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|Any CPU.Build.0 = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|x86.ActiveCfg = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|x86.Build.0 = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.ActiveCfg = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.Build.0 = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Any CPU.Build.0 = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|x86.ActiveCfg = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|x86.Build.0 = Release|Any CPU
{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}.Debug|x86.ActiveCfg = Debug|Any CPU
{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}.Debug|x86.Build.0 = Debug|Any CPU
{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}.Release|Any CPU.Build.0 = Release|Any CPU
{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}.Release|x86.ActiveCfg = Release|Any CPU
{148D3C8B-D6EC-4A7D-80E9-243A81F19DD2}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {970967C0-60BE-4F70-9332-9ACC04B93A15}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29728.190
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Greenshot", "Greenshot\Greenshot.csproj", "{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}"
ProjectSection(ProjectDependencies) = postProject
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB} = {92599C09-FF29-4ABD-B6E6-C48ECD781BAB}
{19FEEF09-313F-43C7-819D-F1BCA782B08B} = {19FEEF09-313F-43C7-819D-F1BCA782B08B}
{9801F62C-540F-4BFE-9211-6405DEDE563B} = {9801F62C-540F-4BFE-9211-6405DEDE563B}
{9C0ECC4C-7807-4111-916A-4F57BB29788A} = {9C0ECC4C-7807-4111-916A-4F57BB29788A}
{C3052651-598A-44E2-AAB3-2E41311D50F9} = {C3052651-598A-44E2-AAB3-2E41311D50F9}
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E} = {7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}
{697CF066-9077-4F22-99D9-D989CCE7282B} = {697CF066-9077-4F22-99D9-D989CCE7282B}
{47F23C86-604E-4CC3-8767-B3D4088F30BB} = {47F23C86-604E-4CC3-8767-B3D4088F30BB}
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50} = {80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02} = {D61E6ECE-E0B6-4467-B492-F08A06BA8F02}
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12} = {AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}
{1893A2E4-A78A-4713-A8E7-E70058DABEE0} = {1893A2E4-A78A-4713-A8E7-E70058DABEE0}
{C6988EE8-2FEE-4349-9F09-F9628A0D8965} = {C6988EE8-2FEE-4349-9F09-F9628A0D8965}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotPlugin", "GreenshotPlugin\GreenshotPlugin.csproj", "{5B924697-4DCD-4F98-85F1-105CB84B7341}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotExternalCommandPlugin", "GreenshotExternalCommandPlugin\GreenshotExternalCommandPlugin.csproj", "{47F23C86-604E-4CC3-8767-B3D4088F30BB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotConfluencePlugin", "GreenshotConfluencePlugin\GreenshotConfluencePlugin.csproj", "{C3052651-598A-44E2-AAB3-2E41311D50F9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotImgurPlugin", "GreenshotImgurPlugin\GreenshotImgurPlugin.csproj", "{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotJiraPlugin", "GreenshotJiraPlugin\GreenshotJiraPlugin.csproj", "{19FEEF09-313F-43C7-819D-F1BCA782B08B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotOCRPlugin", "GreenshotOCRPlugin\GreenshotOCRPlugin.csproj", "{C6988EE8-2FEE-4349-9F09-F9628A0D8965}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotOCRCommand", "GreenshotOCRCommand\GreenshotOCRCommand.csproj", "{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}"
ProjectSection(ProjectDependencies) = postProject
{C6988EE8-2FEE-4349-9F09-F9628A0D8965} = {C6988EE8-2FEE-4349-9F09-F9628A0D8965}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotBoxPlugin", "GreenshotBoxPlugin\GreenshotBoxPlugin.csproj", "{697CF066-9077-4F22-99D9-D989CCE7282B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotDropboxPlugin", "GreenshotDropboxPlugin\GreenshotDropboxPlugin.csproj", "{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotFlickrPlugin", "GreenshotFlickrPlugin\GreenshotFlickrPlugin.csproj", "{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotPicasaPlugin", "GreenshotPicasaPlugin\GreenshotPicasaPlugin.csproj", "{1893A2E4-A78A-4713-A8E7-E70058DABEE0}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotOfficePlugin", "GreenshotOfficePlugin\GreenshotOfficePlugin.csproj", "{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotPhotobucketPlugin", "GreenshotPhotobucketPlugin\GreenshotPhotobucketPlugin.csproj", "{9C0ECC4C-7807-4111-916A-4F57BB29788A}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GreenshotWin10Plugin", "GreenshotWin10Plugin\GreenshotWin10Plugin.csproj", "{9801F62C-540F-4BFE-9211-6405DEDE563B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|x86.ActiveCfg = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Debug|x86.Build.0 = Debug|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|Any CPU.Build.0 = Release|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|x86.ActiveCfg = Release|Any CPU
{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}.Release|x86.Build.0 = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|x86.ActiveCfg = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Debug|x86.Build.0 = Debug|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|Any CPU.Build.0 = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|x86.ActiveCfg = Release|Any CPU
{5B924697-4DCD-4F98-85F1-105CB84B7341}.Release|x86.Build.0 = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|x86.ActiveCfg = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Debug|x86.Build.0 = Debug|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|Any CPU.Build.0 = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|x86.ActiveCfg = Release|Any CPU
{47F23C86-604E-4CC3-8767-B3D4088F30BB}.Release|x86.Build.0 = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|x86.ActiveCfg = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Debug|x86.Build.0 = Debug|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|Any CPU.Build.0 = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|x86.ActiveCfg = Release|Any CPU
{C3052651-598A-44E2-AAB3-2E41311D50F9}.Release|x86.Build.0 = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|x86.ActiveCfg = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Debug|x86.Build.0 = Debug|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|Any CPU.Build.0 = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|x86.ActiveCfg = Release|Any CPU
{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}.Release|x86.Build.0 = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|x86.ActiveCfg = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Debug|x86.Build.0 = Debug|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|Any CPU.Build.0 = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|x86.ActiveCfg = Release|Any CPU
{19FEEF09-313F-43C7-819D-F1BCA782B08B}.Release|x86.Build.0 = Release|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Debug|x86.ActiveCfg = Debug|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Debug|x86.Build.0 = Debug|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Release|Any CPU.Build.0 = Release|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Release|x86.ActiveCfg = Release|Any CPU
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Release|x86.Build.0 = Release|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|x86.ActiveCfg = Debug|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|x86.Build.0 = Debug|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Release|Any CPU.Build.0 = Release|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Release|x86.ActiveCfg = Release|Any CPU
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Release|x86.Build.0 = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|x86.ActiveCfg = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Debug|x86.Build.0 = Debug|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|Any CPU.Build.0 = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|x86.ActiveCfg = Release|Any CPU
{697CF066-9077-4F22-99D9-D989CCE7282B}.Release|x86.Build.0 = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|x86.ActiveCfg = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Debug|x86.Build.0 = Debug|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|Any CPU.Build.0 = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|x86.ActiveCfg = Release|Any CPU
{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}.Release|x86.Build.0 = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|x86.ActiveCfg = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Debug|x86.Build.0 = Debug|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|Any CPU.Build.0 = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|x86.ActiveCfg = Release|Any CPU
{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}.Release|x86.Build.0 = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|x86.ActiveCfg = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Debug|x86.Build.0 = Debug|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|Any CPU.Build.0 = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|x86.ActiveCfg = Release|Any CPU
{1893A2E4-A78A-4713-A8E7-E70058DABEE0}.Release|x86.Build.0 = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|x86.ActiveCfg = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Debug|x86.Build.0 = Debug|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|Any CPU.Build.0 = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|x86.ActiveCfg = Release|Any CPU
{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}.Release|x86.Build.0 = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|x86.ActiveCfg = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Debug|x86.Build.0 = Debug|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|Any CPU.Build.0 = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|x86.ActiveCfg = Release|Any CPU
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|x86.Build.0 = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.ActiveCfg = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|x86.Build.0 = Debug|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Any CPU.Build.0 = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|x86.ActiveCfg = Release|Any CPU
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {970967C0-60BE-4F70-9332-9ACC04B93A15}
EndGlobalSection
EndGlobal

15
Greenshot/App.config Normal file
View file

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<!--<system.windows.forms jitDebugging="true" />-->
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
<runtime>
<loadFromRemoteSources enabled="true" />
<relativeBindForResources enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Addons" />
<probing privatePath="App\Greenshot" />
</assemblyBinding>
</runtime>
</configuration>

View file

@ -0,0 +1,151 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Collections.Generic;
using System.Drawing;
using Greenshot.Drawing.Fields;
using GreenshotPlugin.Effects;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces.Drawing;
using GreenshotPlugin.UnmanagedHelpers.Enums;
using GreenshotPlugin.UnmanagedHelpers.Structs;
namespace Greenshot.Configuration {
/// <summary>
/// Description of CoreConfiguration.
/// </summary>
[IniSection("Editor", Description="Greenshot editor configuration")]
public class EditorConfiguration : IniSection {
[IniProperty("RecentColors", Separator="|", Description="Last used colors")]
public List<Color> RecentColors { get; set; }
[IniProperty("LastFieldValue", Separator="|", Description="Field values, make sure the last used settings are re-used")]
public Dictionary<string, object> LastUsedFieldValues { get; set; }
[IniProperty("MatchSizeToCapture", Description="Match the editor window size to the capture", DefaultValue="True")]
public bool MatchSizeToCapture { get; set; }
[IniProperty("WindowPlacementFlags", Description="Placement flags", DefaultValue="0")]
public WindowPlacementFlags WindowPlacementFlags { get; set; }
[IniProperty("WindowShowCommand", Description="Show command", DefaultValue="Normal")]
public ShowWindowCommand ShowWindowCommand { get; set; }
[IniProperty("WindowMinPosition", Description="Position of minimized window", DefaultValue="-1,-1")]
public Point WindowMinPosition { get; set; }
[IniProperty("WindowMaxPosition", Description="Position of maximized window", DefaultValue="-1,-1")]
public Point WindowMaxPosition { get; set; }
[IniProperty("WindowNormalPosition", Description="Position of normal window", DefaultValue="100,100,400,400")]
public Rectangle WindowNormalPosition { get; set; }
[IniProperty("ReuseEditor", Description = "Reuse already open editor", DefaultValue = "false")]
public bool ReuseEditor { get; set; }
[IniProperty("FreehandSensitivity", Description = "The smaller this number, the less smoothing is used. Decrease for detailed drawing, e.g. when using a pen. Increase for smoother lines. e.g. when you want to draw a smooth line.", DefaultValue = "3")]
public int FreehandSensitivity { get; set; }
[IniProperty("SuppressSaveDialogAtClose", Description="Suppressed the 'do you want to save' dialog when closing the editor.", DefaultValue="False")]
public bool SuppressSaveDialogAtClose { get; set; }
[IniProperty("DropShadowEffectSettings", Description = "Settings for the drop shadow effect.")]
public DropShadowEffect DropShadowEffectSettings { get; set; }
[IniProperty("TornEdgeEffectSettings", Description = "Settings for the torn edge effect.")]
public TornEdgeEffect TornEdgeEffectSettings { get; set; }
public override void AfterLoad() {
base.AfterLoad();
if (RecentColors == null) {
RecentColors = new List<Color>();
}
}
/// <param name="requestingType">Type of the class for which to create the field</param>
/// <param name="fieldType">FieldType of the field to construct</param>
/// <param name="preferredDefaultValue"></param>
/// <returns>a new Field of the given fieldType, with the scope of it's value being restricted to the Type scope</returns>
public IField CreateField(Type requestingType, IFieldType fieldType, object preferredDefaultValue)
{
string requestingTypeName = requestingType.Name;
string requestedField = requestingTypeName + "." + fieldType.Name;
object fieldValue = preferredDefaultValue;
// Check if the configuration exists
if (LastUsedFieldValues == null) {
LastUsedFieldValues = new Dictionary<string, object>();
}
// Check if settings for the requesting type exist, if not create!
if (LastUsedFieldValues.ContainsKey(requestedField)) {
// Check if a value is set (not null)!
if (LastUsedFieldValues[requestedField] != null) {
fieldValue = LastUsedFieldValues[requestedField];
} else {
// Overwrite null value
LastUsedFieldValues[requestedField] = fieldValue;
}
} else {
LastUsedFieldValues.Add(requestedField, fieldValue);
}
return new Field(fieldType, requestingType)
{
Value = fieldValue
};
}
public void UpdateLastFieldValue(IField field)
{
string requestedField = field.Scope + "." + field.FieldType.Name;
// Check if the configuration exists
if (LastUsedFieldValues == null) {
LastUsedFieldValues = new Dictionary<string, object>();
}
// check if settings for the requesting type exist, if not create!
if (LastUsedFieldValues.ContainsKey(requestedField)) {
LastUsedFieldValues[requestedField] = field.Value;
} else {
LastUsedFieldValues.Add(requestedField, field.Value);
}
}
public void ResetEditorPlacement()
{
WindowNormalPosition = new Rectangle(100, 100, 400, 400);
WindowMaxPosition = new Point(-1,-1);
WindowMinPosition = new Point(-1, -1);
WindowPlacementFlags = 0;
ShowWindowCommand = ShowWindowCommand.Normal;
}
public WindowPlacement GetEditorPlacement() {
WindowPlacement placement = WindowPlacement.Default;
placement.NormalPosition = new RECT(WindowNormalPosition);
placement.MaxPosition = new POINT(WindowMaxPosition);
placement.MinPosition = new POINT(WindowMinPosition);
placement.ShowCmd = ShowWindowCommand;
placement.Flags = WindowPlacementFlags;
return placement;
}
public void SetEditorPlacement(WindowPlacement placement) {
WindowNormalPosition = placement.NormalPosition.ToRectangle();
WindowMaxPosition = placement.MaxPosition.ToPoint();
WindowMinPosition = placement.MinPosition.ToPoint();
ShowWindowCommand = placement.ShowCmd;
WindowPlacementFlags = placement.Flags;
}
}
}

View file

@ -0,0 +1,243 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.Diagnostics.CodeAnalysis;
namespace Greenshot.Configuration {
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum LangKey {
none,
about_bugs,
about_donations,
about_host,
about_icons,
about_license,
about_title,
about_translation,
application_title,
bugreport_cancel,
bugreport_info,
bugreport_title,
clipboard_error,
clipboard_inuse,
colorpicker_alpha,
colorpicker_apply,
colorpicker_blue,
colorpicker_green,
colorpicker_htmlcolor,
colorpicker_recentcolors,
colorpicker_red,
colorpicker_title,
colorpicker_transparent,
config_unauthorizedaccess_write,
contextmenu_about,
contextmenu_capturearea,
contextmenu_captureclipboard,
contextmenu_capturefullscreen,
contextmenu_capturefullscreen_all,
contextmenu_capturefullscreen_left,
contextmenu_capturefullscreen_top,
contextmenu_capturefullscreen_right,
contextmenu_capturefullscreen_bottom,
contextmenu_capturelastregion,
contextmenu_capturewindow,
contextmenu_donate,
contextmenu_exit,
contextmenu_help,
contextmenu_openfile,
contextmenu_quicksettings,
contextmenu_settings,
contextmenu_captureie,
contextmenu_openrecentcapture,
editor_align_bottom,
editor_align_center,
editor_align_horizontal,
editor_align_middle,
editor_align_left,
editor_align_right,
editor_align_top,
editor_align_vertical,
editor_arrange,
editor_arrowheads,
editor_arrowheads_both,
editor_arrowheads_end,
editor_arrowheads_none,
editor_arrowheads_start,
editor_backcolor,
editor_blur_radius,
editor_bold,
editor_brightness,
editor_cancel,
editor_clipboardfailed,
editor_close,
editor_close_on_save,
editor_close_on_save_title,
editor_confirm,
editor_copyimagetoclipboard,
editor_copypathtoclipboard,
editor_copytoclipboard,
editor_crop,
editor_cursortool,
editor_cuttoclipboard,
editor_deleteelement,
editor_downonelevel,
editor_downtobottom,
editor_drawarrow,
editor_drawellipse,
editor_drawhighlighter,
editor_drawline,
editor_drawfreehand,
editor_drawrectangle,
editor_drawtextbox,
editor_duplicate,
editor_edit,
editor_email,
editor_file,
editor_fontsize,
editor_forecolor,
editor_highlight_area,
editor_highlight_grayscale,
editor_highlight_mode,
editor_highlight_text,
editor_highlight_magnify,
editor_pixel_size,
editor_imagesaved,
editor_italic,
editor_load_objects,
editor_magnification_factor,
editor_match_capture_size,
editor_obfuscate,
editor_obfuscate_blur,
editor_obfuscate_mode,
editor_obfuscate_pixelize,
editor_object,
editor_opendirinexplorer,
editor_pastefromclipboard,
editor_preview_quality,
editor_print,
editor_save,
editor_save_objects,
editor_saveas,
editor_selectall,
editor_senttoprinter,
editor_shadow,
editor_torn_edge,
editor_border,
editor_grayscale,
editor_effects,
editor_storedtoclipboard,
editor_thickness,
editor_title,
editor_uponelevel,
editor_uptotop,
editor_autocrop,
editor_undo,
editor_redo,
editor_insertwindow,
editor_resetsize,
error,
error_multipleinstances,
error_nowriteaccess,
error_openfile,
error_openlink,
error_save,
error_save_invalid_chars,
help_title,
jpegqualitydialog_choosejpegquality,
qualitydialog_dontaskagain,
qualitydialog_title,
settings_reducecolors,
print_error,
printoptions_allowcenter,
printoptions_allowenlarge,
printoptions_allowrotate,
printoptions_allowshrink,
printoptions_colors,
printoptions_dontaskagain,
printoptions_pagelayout,
printoptions_printcolor,
printoptions_printgrayscale,
printoptions_printmonochrome,
printoptions_timestamp,
printoptions_inverted,
printoptions_title,
quicksettings_destination_file,
settings_alwaysshowqualitydialog,
settings_alwaysshowprintoptionsdialog,
settings_applicationsettings,
settings_autostartshortcut,
settings_capture,
settings_capture_mousepointer,
settings_capture_windows_interactive,
settings_copypathtoclipboard,
settings_destination,
settings_destination_clipboard,
settings_destination_editor,
settings_destination_email,
settings_destination_file,
settings_destination_fileas,
settings_destination_printer,
settings_destination_picker,
settings_editor,
settings_filenamepattern,
settings_general,
settings_iecapture,
settings_jpegquality,
settings_qualitysettings,
settings_language,
settings_message_filenamepattern,
settings_output,
settings_playsound,
settings_plugins,
settings_plugins_name,
settings_plugins_version,
settings_plugins_createdby,
settings_plugins_dllpath,
settings_preferredfilesettings,
settings_primaryimageformat,
settings_printer,
settings_printoptions,
settings_registerhotkeys,
settings_showflashlight,
settings_storagelocation,
settings_title,
settings_tooltip_filenamepattern,
settings_tooltip_language,
settings_tooltip_primaryimageformat,
settings_tooltip_registerhotkeys,
settings_tooltip_storagelocation,
settings_visualization,
settings_shownotify,
settings_waittime,
settings_windowscapture,
settings_window_capture_mode,
settings_network,
settings_checkperiod,
settings_usedefaultproxy,
tooltip_firststart,
warning,
warning_hotkeys,
hotkeys,
wait_ie_capture,
update_found,
exported_to
}
}

View file

@ -0,0 +1,49 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls {
/// <summary>
/// Description of BindableToolStripButton.
/// </summary>
public class BindableToolStripButton : ToolStripButton, INotifyPropertyChanged, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
public BindableToolStripButton()
{
CheckedChanged += BindableToolStripButton_CheckedChanged;
}
private void BindableToolStripButton_CheckedChanged(object sender, EventArgs e)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Checked"));
}
}
}

View file

@ -0,0 +1,49 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls {
/// <summary>
/// A simple ToolStripComboBox implementing INotifyPropertyChanged for data binding
/// </summary>
public class BindableToolStripComboBox : ToolStripComboBox, INotifyPropertyChanged, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
public BindableToolStripComboBox()
{
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
}
private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedItem"));
}
}
}

View file

@ -0,0 +1,70 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.ComponentModel;
using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls {
/// <summary>
/// A simple ToolStripDropDownButton implementing INotifyPropertyChanged for data binding.
/// Also, when a DropDownItem is selected, the DropDownButton adopts its Tag and Image.
/// The selected tag can be accessed via SelectedTag property.
/// </summary>
public class BindableToolStripDropDownButton : ToolStripDropDownButton, INotifyPropertyChanged, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
public object SelectedTag {
get { if(Tag==null && DropDownItems.Count>0) Tag=DropDownItems[0].Tag; return Tag; }
set { AdoptFromTag(value); }
}
protected override void OnDropDownItemClicked(ToolStripItemClickedEventArgs e) {
ToolStripItem clickedItem = e.ClickedItem;
if(Tag == null || !Tag.Equals(clickedItem.Tag)) {
Tag = clickedItem.Tag;
Image = clickedItem.Image;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedTag"));
}
base.OnDropDownItemClicked(e);
}
private void AdoptFromTag(object tag) {
if(Tag == null || !Tag.Equals(tag)) {
Tag = tag;
foreach(ToolStripItem item in DropDownItems) {
if(item.Tag != null && item.Tag.Equals(tag)) {
Image = item.Image;
break;
}
}
Tag = tag;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedTag"));
}
}
}
}

View file

@ -0,0 +1,89 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls {
/// <summary>
/// Description of ColorButton.
/// </summary>
public class ColorButton : Button, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged;
private Color _selectedColor = Color.White;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
public ColorButton() {
Click += ColorButtonClick;
}
public Color SelectedColor {
get {return _selectedColor;}
set {
_selectedColor = value;
Brush brush;
if(value != Color.Transparent) {
brush = new SolidBrush(value);
} else {
brush = new HatchBrush(HatchStyle.Percent50, Color.White, Color.Gray);
}
if (Image != null)
{
using Graphics graphics = Graphics.FromImage(Image);
graphics.FillRectangle(brush, new Rectangle(4,17,16,3));
}
// cleanup GDI Object
brush.Dispose();
Invalidate();
}
}
private void ColorButtonClick(object sender, EventArgs e) {
var colorDialog = new ColorDialog
{
Color = SelectedColor
};
// Using the parent to make sure the dialog doesn't show on another window
colorDialog.ShowDialog(Parent.Parent);
if (colorDialog.DialogResult == DialogResult.Cancel)
{
return;
}
if (colorDialog.Color.Equals(SelectedColor))
{
return;
}
SelectedColor = colorDialog.Color;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedColor"));
}
}
}

View file

@ -0,0 +1,45 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 GreenshotPlugin.Core;
using System.Drawing;
using System.Windows.Forms;
using GreenshotPlugin.IniFile;
namespace Greenshot.Controls {
/// <summary>
/// ToolStripProfessionalRenderer which draws the Check correctly when the icons are larger
/// </summary>
public class ContextMenuToolStripProfessionalRenderer : ToolStripProfessionalRenderer {
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
private static Image _scaledCheckbox;
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) {
if (_scaledCheckbox == null || _scaledCheckbox.Size != CoreConfig.ScaledIconSize) {
_scaledCheckbox?.Dispose();
_scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, CoreConfig.ScaledIconSize.Width, CoreConfig.ScaledIconSize.Height, null);
}
Rectangle old = e.ImageRectangle;
ToolStripItemImageRenderEventArgs clone = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, _scaledCheckbox, new Rectangle(old.X, 0, old.Width, old.Height));
base.OnRenderItemCheck(clone);
}
}
}

View file

@ -0,0 +1,67 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.Drawing;
using System.Windows.Forms;
namespace Greenshot.Controls {
/// <summary>
/// Prevent having a gradient background in the toolstrip, and the overflow button
/// See: http://stackoverflow.com/a/16926979
/// </summary>
internal class CustomProfessionalColorTable : ProfessionalColorTable {
public override Color ToolStripGradientBegin {
get { return SystemColors.Control; }
}
public override Color ToolStripGradientMiddle {
get { return SystemColors.Control; }
}
public override Color ToolStripGradientEnd {
get { return SystemColors.Control; }
}
public override Color OverflowButtonGradientBegin {
get { return SystemColors.Control; }
}
public override Color OverflowButtonGradientMiddle {
get { return SystemColors.Control; }
}
public override Color OverflowButtonGradientEnd {
get { return SystemColors.Control; }
}
}
/// <summary>
/// ToolStripProfessionalRenderer without having a visual artifact
/// See: http://stackoverflow.com/a/16926979 and http://stackoverflow.com/a/13418840
/// </summary>
public class CustomToolStripProfessionalRenderer : ToolStripProfessionalRenderer {
public CustomToolStripProfessionalRenderer() : base(new CustomProfessionalColorTable()) {
RoundedEdges = false;
}
/// <summary>
/// By overriding the OnRenderToolStripBorder we can make the ToolStrip without border
/// </summary>
/// <param name="e"></param>
protected override void OnRenderToolStripBorder(ToolStripRenderEventArgs e) {
// Don't draw a border
}
}
}

View file

@ -0,0 +1,120 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Greenshot.Controls {
/// <summary>
/// ToolStripComboBox containing installed font families,
/// implementing INotifyPropertyChanged for data binding
/// </summary>
public class FontFamilyComboBox : ToolStripComboBox, INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
public FontFamily FontFamily {
get { return (FontFamily)SelectedItem; }
set {
if (!SelectedItem.Equals(value)) {
SelectedItem = value;
}
}
}
public FontFamilyComboBox()
{
if (ComboBox != null)
{
ComboBox.DataSource = FontFamily.Families;
ComboBox.DisplayMember = "Name";
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
ComboBox.DrawItem += ComboBox_DrawItem;
}
}
private void ComboBox_DrawItem(object sender, DrawItemEventArgs e) {
// DrawBackground handles drawing the background (i.e,. hot-tracked v. not)
// It uses the system colors (Bluish, and and white, by default)
// same as calling e.Graphics.FillRectangle ( SystemBrushes.Highlight, e.Bounds );
e.DrawBackground();
if (e.Index > -1) {
FontFamily fontFamily = Items[e.Index] as FontFamily;
FontStyle fontStyle = FontStyle.Regular;
if (fontFamily != null && !fontFamily.IsStyleAvailable(FontStyle.Regular)) {
if (fontFamily.IsStyleAvailable(FontStyle.Bold)) {
fontStyle = FontStyle.Bold;
} else if (fontFamily.IsStyleAvailable(FontStyle.Italic)) {
fontStyle = FontStyle.Italic;
} else if (fontFamily.IsStyleAvailable(FontStyle.Strikeout)) {
fontStyle = FontStyle.Strikeout;
} else if (fontFamily.IsStyleAvailable(FontStyle.Underline)) {
fontStyle = FontStyle.Underline;
}
}
try {
if (fontFamily != null)
{
DrawText(e.Graphics, fontFamily, fontStyle, e.Bounds, fontFamily.Name);
}
} catch {
// If the drawing failed, BUG-1770 seems to have a weird case that causes: Font 'Lucida Sans Typewriter' does not support style 'Regular'
if (fontFamily != null)
{
DrawText(e.Graphics, FontFamily.GenericSansSerif, FontStyle.Regular, e.Bounds, fontFamily.Name);
}
}
}
// Uncomment this if you actually like the way the focus rectangle looks
//e.DrawFocusRectangle ();
}
/// <summary>
/// Helper method to draw the string
/// </summary>
/// <param name="graphics"></param>
/// <param name="fontFamily"></param>
/// <param name="fontStyle"></param>
/// <param name="bounds"></param>
/// <param name="text"></param>
private void DrawText(Graphics graphics, FontFamily fontFamily, FontStyle fontStyle, Rectangle bounds, string text)
{
using Font font = new Font(fontFamily, Font.Size + 5, fontStyle, GraphicsUnit.Pixel);
// Make sure the text is visible by centering it in the line
using StringFormat stringFormat = new StringFormat
{
LineAlignment = StringAlignment.Center
};
graphics.DrawString(text, font, Brushes.Black, bounds, stringFormat);
}
private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) {
if (PropertyChanged == null) return;
PropertyChanged(this, new PropertyChangedEventArgs("Text"));
PropertyChanged(this, new PropertyChangedEventArgs("FontFamily"));
PropertyChanged(this, new PropertyChangedEventArgs("SelectedIndex"));
PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem"));
}
}
}

View file

@ -0,0 +1,64 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Windows.Forms;
using GreenshotPlugin.UnmanagedHelpers.Enums;
namespace Greenshot.Controls {
/// <summary>
/// This is an extension of the default MenuStrip 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
/// </summary>
public class MenuStripEx : MenuStrip {
private const int WM_MOUSEACTIVATE = 0x21;
private enum NativeConstants : uint {
MA_ACTIVATE = 1,
MA_ACTIVATEANDEAT = 2,
}
private bool _clickThrough;
/// <summary>
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does not have input focus.
/// </summary>
/// <remarks>
/// Default value is false, which is the same behavior provided by the base ToolStrip class.
/// </remarks>
public bool ClickThrough {
get {
return _clickThrough;
}
set {
_clickThrough = value;
}
}
protected override void WndProc(ref Message m) {
base.WndProc(ref m);
var windowsMessage = (WindowsMessages) m.Msg;
if (_clickThrough && windowsMessage == WindowsMessages.WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT)
{
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
}
}
}
}

View file

@ -0,0 +1,54 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.Drawing;
using System.Windows.Forms;
namespace GreenshotPlugin.Controls {
/// <summary>
/// See: http://nickstips.wordpress.com/2010/03/03/c-panel-resets-scroll-position-after-focus-is-lost-and-regained/
/// </summary>
public class NonJumpingPanel : Panel {
protected override Point ScrollToControl(Control activeControl) {
// Returning the current location prevents the panel from
// scrolling to the active control when the panel loses and regains focus
return DisplayRectangle.Location;
}
/// <summary>
/// Add horizontal scrolling to the panel, when using the wheel and the shift key is pressed
/// </summary>
/// <param name="e">MouseEventArgs</param>
protected override void OnMouseWheel(MouseEventArgs e)
{
if (VScroll && (ModifierKeys & Keys.Shift) == Keys.Shift)
{
VScroll = false;
base.OnMouseWheel(e);
VScroll = true;
}
else
{
base.OnMouseWheel(e);
}
}
}
}

View file

@ -0,0 +1,173 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Forms;
using GreenshotPlugin.UnmanagedHelpers;
using GreenshotPlugin.UnmanagedHelpers.Enums;
namespace Greenshot.Controls {
/// <summary>
/// This code was supplied by Hi-Coder as a patch for Greenshot
/// Needed some modifications to be stable.
/// </summary>
public sealed class Pipette : Label, IMessageFilter, IDisposable {
private MovableShowColorForm _movableShowColorForm;
private bool _dragging;
private Cursor _cursor;
private readonly Bitmap _image;
private const int VkEsc = 27;
public event EventHandler<PipetteUsedArgs> PipetteUsed;
public Pipette() {
BorderStyle = BorderStyle.FixedSingle;
_dragging = false;
_image = (Bitmap)new ComponentResourceManager(typeof(ColorDialog)).GetObject("pipette.Image");
Image = _image;
_cursor = CreateCursor(_image, 1, 14);
_movableShowColorForm = new MovableShowColorForm();
Application.AddMessageFilter(this);
}
/// <summary>
/// Create a cursor from the supplied bitmap & hotspot coordinates
/// </summary>
/// <param name="bitmap">Bitmap to create an icon from</param>
/// <param name="hotspotX">Hotspot X coordinate</param>
/// <param name="hotspotY">Hotspot Y coordinate</param>
/// <returns>Cursor</returns>
private static Cursor CreateCursor(Bitmap bitmap, int hotspotX, int hotspotY)
{
using SafeIconHandle iconHandle = new SafeIconHandle( bitmap.GetHicon());
User32.GetIconInfo(iconHandle, out var iconInfo);
iconInfo.xHotspot = hotspotX;
iconInfo.yHotspot = hotspotY;
iconInfo.fIcon = false;
var icon = User32.CreateIconIndirect(ref iconInfo);
return new Cursor(icon);
}
/// <summary>
/// The bulk of the clean-up code is implemented in Dispose(bool)
/// </summary>
public new void Dispose() {
Dispose(true);
}
/// <summary>
/// This Dispose is called from the Dispose and the Destructor.
/// </summary>
/// <param name="disposing">When disposing==true all non-managed resources should be freed too!</param>
protected override void Dispose(bool disposing) {
if (disposing) {
if (_cursor != null) {
_cursor.Dispose();
}
_movableShowColorForm?.Dispose();
}
_movableShowColorForm = null;
_cursor = null;
base.Dispose(disposing);
}
/// <summary>
/// Handle the mouse down on the Pipette "label", we take the capture and move the zoomer to the current location
/// </summary>
/// <param name="e">MouseEventArgs</param>
protected override void OnMouseDown(MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
User32.SetCapture(Handle);
_movableShowColorForm.MoveTo(PointToScreen(new Point(e.X, e.Y)));
}
base.OnMouseDown(e);
}
/// <summary>
/// Handle the mouse up on the Pipette "label", we release the capture and fire the PipetteUsed event
/// </summary>
/// <param name="e">MouseEventArgs</param>
protected override void OnMouseUp(MouseEventArgs e) {
if (e.Button == MouseButtons.Left)
{
//Release Capture should consume MouseUp when canceled with the escape key
User32.ReleaseCapture();
PipetteUsed?.Invoke(this, new PipetteUsedArgs(_movableShowColorForm.color));
}
base.OnMouseUp(e);
}
/// <summary>
/// Handle the mouse Move event, we move the ColorUnderCursor to the current location.
/// </summary>
/// <param name="e">MouseEventArgs</param>
protected override void OnMouseMove(MouseEventArgs e) {
if (_dragging) {
//display the form on the right side of the cursor by default;
Point zp = PointToScreen(new Point(e.X, e.Y));
_movableShowColorForm.MoveTo(zp);
}
base.OnMouseMove(e);
}
/// <summary>
/// Handle the MouseCaptureChanged event
/// </summary>
/// <param name="e"></param>
protected override void OnMouseCaptureChanged(EventArgs e) {
if (Capture) {
_dragging = true;
Image = null;
Cursor c = _cursor;
Cursor = c;
_movableShowColorForm.Visible = true;
} else {
_dragging = false;
Image = _image;
Cursor = Cursors.Arrow;
_movableShowColorForm.Visible = false;
}
Update();
base.OnMouseCaptureChanged(e);
}
public bool PreFilterMessage(ref Message m) {
if (_dragging) {
if (m.Msg == (int)WindowsMessages.WM_CHAR) {
if ((int)m.WParam == VkEsc) {
User32.ReleaseCapture();
}
}
}
return false;
}
}
public class PipetteUsedArgs : EventArgs {
public Color Color;
public PipetteUsedArgs(Color c) {
Color = c;
}
}
}

View file

@ -0,0 +1,87 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using GreenshotPlugin.Controls;
namespace Greenshot.Controls {
public class ToolStripColorButton : ToolStripButton, INotifyPropertyChanged, IGreenshotLanguageBindable {
public event PropertyChangedEventHandler PropertyChanged;
[Category("Greenshot"), DefaultValue(null), Description("Specifies key of the language file to use when displaying the text.")]
public string LanguageKey {
get;
set;
}
private Color _selectedColor = Color.Transparent;
public ToolStripColorButton() {
Click+= ColorButtonClick;
}
public Color SelectedColor {
get {return _selectedColor;}
set {
_selectedColor = value;
Brush brush;
if(value != Color.Transparent) {
brush = new SolidBrush(value);
} else {
brush = new HatchBrush(HatchStyle.Percent50, Color.White, Color.Gray);
}
if (Image != null)
{
using Graphics graphics = Graphics.FromImage(Image);
graphics.FillRectangle(brush, new Rectangle(0,13,16,3));
}
// cleanup GDI Object
brush.Dispose();
Invalidate();
}
}
private void ColorButtonClick(object sender, EventArgs e) {
var colorDialog = new ColorDialog
{
Color = SelectedColor
};
// Using the parent to make sure the dialog doesn't show on another window
colorDialog.ShowDialog(Parent.Parent);
if (colorDialog.DialogResult == DialogResult.Cancel)
{
return;
}
if (colorDialog.Color.Equals(SelectedColor))
{
return;
}
SelectedColor = colorDialog.Color;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedColor"));
}
}
}

View file

@ -0,0 +1,62 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Windows.Forms;
namespace Greenshot.Controls {
/// <summary>
/// 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
/// </summary>
internal class ToolStripEx : ToolStrip {
private const int WM_MOUSEACTIVATE = 0x21;
private enum NativeConstants : uint {
MA_ACTIVATE = 1,
MA_ACTIVATEANDEAT = 2,
}
private bool _clickThrough;
/// <summary>
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does not have input focus.
/// </summary>
/// <remarks>
/// Default value is false, which is the same behavior provided by the base ToolStrip class.
/// </remarks>
public bool ClickThrough {
get {
return _clickThrough;
}
set {
_clickThrough = value;
}
}
protected override void WndProc(ref Message m) {
base.WndProc(ref m);
if (_clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) {
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
}
}
}
}

View file

@ -0,0 +1,79 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace Greenshot.Controls {
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)]
public class ToolStripNumericUpDown : ToolStripControlHost, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public ToolStripNumericUpDown() : base(new NumericUpDown())
{
}
public NumericUpDown NumericUpDown => Control as NumericUpDown;
public decimal Value
{
get { return NumericUpDown.Value; }
set { NumericUpDown.Value = value;}
}
public decimal Minimum {
get { return NumericUpDown.Minimum; }
set { NumericUpDown.Minimum = value; }
}
public decimal Maximum {
get { return NumericUpDown.Maximum; }
set { NumericUpDown.Maximum = value; }
}
public decimal Increment {
get { return NumericUpDown.Increment; }
set { NumericUpDown.Increment = value; }
}
public int DecimalPlaces {
get { return NumericUpDown.DecimalPlaces; }
set { NumericUpDown.DecimalPlaces = value; }
}
protected override void OnSubscribeControlEvents(Control control) {
base.OnSubscribeControlEvents(control);
NumericUpDown.ValueChanged += _valueChanged;
}
protected override void OnUnsubscribeControlEvents(Control control) {
base.OnUnsubscribeControlEvents(control);
NumericUpDown.ValueChanged -= _valueChanged;
}
private void _valueChanged(object sender, EventArgs e)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Value"));
}
}
}

View file

@ -0,0 +1,78 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces;
namespace Greenshot.Destinations {
/// <summary>
/// Description of ClipboardDestination.
/// </summary>
public class ClipboardDestination : AbstractDestination {
public const string DESIGNATION = "Clipboard";
public override string Designation {
get {
return DESIGNATION;
}
}
public override string Description {
get {
return Language.GetString(LangKey.settings_destination_clipboard);
}
}
public override int Priority {
get {
return 2;
}
}
public override Keys EditorShortcutKeys {
get {
return Keys.Control | Keys.Shift | Keys.C;
}
}
public override Image DisplayIcon {
get {
return GreenshotResources.getImage("Clipboard.Image");
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(Designation, Description);
try {
ClipboardHelper.SetClipboardData(surface);
exportInformation.ExportMade = true;
} catch (Exception) {
// TODO: Change to general logic in ProcessExport
surface.SendMessageEvent(this, SurfaceMessageTyp.Error, Language.GetString(LangKey.editor_clipboardfailed));
}
ProcessExport(exportInformation, surface);
return exportInformation;
}
}
}

View file

@ -0,0 +1,122 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Collections.Generic;
using System.Drawing;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Forms;
using log4net;
namespace Greenshot.Destinations {
/// <summary>
/// Description of EditorDestination.
/// </summary>
public class EditorDestination : AbstractDestination {
private static readonly ILog LOG = LogManager.GetLogger(typeof(EditorDestination));
private static readonly EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
public const string DESIGNATION = "Editor";
private readonly IImageEditor editor;
private static readonly Image greenshotIcon = GreenshotResources.getGreenshotIcon().ToBitmap();
public EditorDestination() {
}
public EditorDestination(IImageEditor editor) {
this.editor = editor;
}
public override string Designation => DESIGNATION;
public override string Description {
get {
if (editor == null) {
return Language.GetString(LangKey.settings_destination_editor);
}
return Language.GetString(LangKey.settings_destination_editor) + " - " + editor.CaptureDetails.Title;
}
}
public override int Priority => 1;
public override bool IsDynamic => true;
public override Image DisplayIcon => greenshotIcon;
public override IEnumerable<IDestination> DynamicDestinations() {
foreach (IImageEditor someEditor in ImageEditorForm.Editors) {
yield return new EditorDestination(someEditor);
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(Designation, Description);
// Make sure we collect the garbage before opening the screenshot
GC.Collect();
GC.WaitForPendingFinalizers();
bool modified = surface.Modified;
if (editor == null) {
if (editorConfiguration.ReuseEditor) {
foreach(IImageEditor openedEditor in ImageEditorForm.Editors) {
if (openedEditor.Surface.Modified) continue;
openedEditor.Surface = surface;
exportInformation.ExportMade = true;
break;
}
}
if (!exportInformation.ExportMade) {
try {
ImageEditorForm editorForm = new ImageEditorForm(surface, !surface.Modified); // Output made??
if (!string.IsNullOrEmpty(captureDetails.Filename)) {
editorForm.SetImagePath(captureDetails.Filename);
}
editorForm.Show();
editorForm.Activate();
LOG.Debug("Finished opening Editor");
exportInformation.ExportMade = true;
} catch (Exception e) {
LOG.Error(e);
exportInformation.ErrorMessage = e.Message;
}
}
} else {
try {
using (Image image = surface.GetImageForExport()) {
editor.Surface.AddImageContainer(image, 10, 10);
}
exportInformation.ExportMade = true;
} catch (Exception e) {
LOG.Error(e);
exportInformation.ErrorMessage = e.Message;
}
}
ProcessExport(exportInformation, surface);
// Workaround for the modified flag when using the editor.
surface.Modified = modified;
return exportInformation;
}
}
}

View file

@ -0,0 +1,92 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Helpers;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces;
namespace Greenshot.Destinations {
/// <summary>
/// Description of EmailDestination.
/// </summary>
public class EmailDestination : AbstractDestination {
private static readonly Image MailIcon = GreenshotResources.getImage("Email.Image");
private static bool _isActiveFlag;
private static string _mapiClient;
public const string DESIGNATION = "EMail";
static EmailDestination() {
// Logic to decide what email implementation we use
if (!EmailConfigHelper.HasMapi()) return;
_isActiveFlag = false;
_mapiClient = EmailConfigHelper.GetMapiClient();
if (!string.IsNullOrEmpty(_mapiClient)) {
// Active as we have a mapi client, can be disabled later
_isActiveFlag = true;
}
}
public override string Designation => DESIGNATION;
public override string Description {
get
{
// Make sure there is some kind of "mail" name
return _mapiClient ??= Language.GetString(LangKey.editor_email);
}
}
public override int Priority => 3;
public override bool IsActive {
get {
if (_isActiveFlag) {
// Disable if the office plugin is installed and the client is outlook
// TODO: Change this! It always creates an exception, as the plugin has not been loaded the type is not there :(
Type outlookdestination = Type.GetType("GreenshotOfficePlugin.OutlookDestination,GreenshotOfficePlugin");
if (outlookdestination != null) {
if (_mapiClient.ToLower().Contains("microsoft outlook")) {
_isActiveFlag = false;
}
}
}
return base.IsActive && _isActiveFlag;
}
}
public override Keys EditorShortcutKeys => Keys.Control | Keys.E;
public override Image DisplayIcon => MailIcon;
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(Designation, Description);
MapiMailMessage.SendImage(surface, captureDetails);
exportInformation.ExportMade = true;
ProcessExport(exportInformation, surface);
return exportInformation;
}
}
}

View file

@ -0,0 +1,142 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
using GreenshotPlugin.Controls;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Plugin;
using log4net;
namespace Greenshot.Destinations {
/// <summary>
/// Description of FileSaveAsDestination.
/// </summary>
public class FileDestination : AbstractDestination {
private static readonly ILog Log = LogManager.GetLogger(typeof(FileDestination));
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
public const string DESIGNATION = "FileNoDialog";
public override string Designation => DESIGNATION;
public override string Description => Language.GetString(LangKey.quicksettings_destination_file);
public override int Priority => 0;
public override Keys EditorShortcutKeys => Keys.Control | Keys.S;
public override Image DisplayIcon => GreenshotResources.getImage("Save.Image");
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(Designation, Description);
bool outputMade;
bool overwrite;
string fullPath;
// Get output settings from the configuration
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();
if (captureDetails?.Filename != null) {
// As we save a pre-selected file, allow to overwrite.
overwrite = true;
Log.InfoFormat("Using previous filename");
fullPath = captureDetails.Filename;
outputSettings.Format = ImageOutput.FormatForFilename(fullPath);
} else {
fullPath = CreateNewFilename(captureDetails);
// As we generate a file, the configuration tells us if we allow to overwrite
overwrite = CoreConfig.OutputFileAllowOverwrite;
}
if (CoreConfig.OutputFilePromptQuality) {
QualityDialog qualityDialog = new QualityDialog(outputSettings);
qualityDialog.ShowDialog();
}
// Catching any exception to prevent that the user can't write in the directory.
// This is done for e.g. bugs #2974608, #2963943, #2816163, #2795317, #2789218, #3004642
try {
ImageOutput.Save(surface, fullPath, overwrite, outputSettings, CoreConfig.OutputFileCopyPathToClipboard);
outputMade = true;
} catch (ArgumentException ex1) {
// Our generated filename exists, display 'save-as'
Log.InfoFormat("Not overwriting: {0}", ex1.Message);
// when we don't allow to overwrite present a new SaveWithDialog
fullPath = ImageOutput.SaveWithDialog(surface, captureDetails);
outputMade = fullPath != null;
} catch (Exception ex2) {
Log.Error("Error saving screenshot!", ex2);
// Show the problem
MessageBox.Show(Language.GetString(LangKey.error_save), Language.GetString(LangKey.error));
// when save failed we present a SaveWithDialog
fullPath = ImageOutput.SaveWithDialog(surface, captureDetails);
outputMade = fullPath != null;
}
// Don't overwrite filename if no output is made
if (outputMade) {
exportInformation.ExportMade = true;
exportInformation.Filepath = fullPath;
if (captureDetails != null)
{
captureDetails.Filename = fullPath;
}
CoreConfig.OutputFileAsFullpath = fullPath;
}
ProcessExport(exportInformation, surface);
return exportInformation;
}
private static string CreateNewFilename(ICaptureDetails captureDetails) {
string fullPath;
Log.InfoFormat("Creating new filename");
string pattern = CoreConfig.OutputFileFilenamePattern;
if (string.IsNullOrEmpty(pattern)) {
pattern = "greenshot ${capturetime}";
}
string filename = FilenameHelper.GetFilenameFromPattern(pattern, CoreConfig.OutputFileFormat, captureDetails);
CoreConfig.ValidateAndCorrectOutputFilePath();
string filepath = FilenameHelper.FillVariables(CoreConfig.OutputFilePath, false);
try {
fullPath = Path.Combine(filepath, filename);
} catch (ArgumentException) {
// configured filename or path not valid, show error message...
Log.InfoFormat("Generated path or filename not valid: {0}, {1}", filepath, filename);
MessageBox.Show(Language.GetString(LangKey.error_save_invalid_chars), Language.GetString(LangKey.error));
// ... lets get the pattern fixed....
var dialogResult = new SettingsForm().ShowDialog();
if (dialogResult == DialogResult.OK) {
// ... OK -> then try again:
fullPath = CreateNewFilename(captureDetails);
} else {
// ... cancelled.
fullPath = null;
}
}
return fullPath;
}
}
}

View file

@ -0,0 +1,82 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.Drawing;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces;
namespace Greenshot.Destinations {
/// <summary>
/// Description of FileWithDialog.
/// </summary>
public class FileWithDialogDestination : AbstractDestination {
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
public const string DESIGNATION = "FileDialog";
public override string Designation {
get {
return DESIGNATION;
}
}
public override string Description {
get {
return Language.GetString(LangKey.settings_destination_fileas);
}
}
public override int Priority {
get {
return 0;
}
}
public override Keys EditorShortcutKeys {
get {
return Keys.Control | Keys.Shift | Keys.S;
}
}
public override Image DisplayIcon {
get {
return GreenshotResources.getImage("Save.Image");
}
}
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(Designation, Description);
// Bug #2918756 don't overwrite path if SaveWithDialog returns null!
var savedTo = ImageOutput.SaveWithDialog(surface, captureDetails);
if (savedTo != null) {
exportInformation.ExportMade = true;
exportInformation.Filepath = savedTo;
captureDetails.Filename = savedTo;
conf.OutputFileAsFullpath = savedTo;
}
ProcessExport(exportInformation, surface);
return exportInformation;
}
}
}

View file

@ -0,0 +1,65 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.Collections.Generic;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces;
namespace Greenshot.Destinations {
/// <summary>
/// The PickerDestination shows a context menu with all possible destinations, so the user can "pick" one
/// </summary>
public class PickerDestination : AbstractDestination {
public const string DESIGNATION = "Picker";
public override string Designation => DESIGNATION;
public override string Description => Language.GetString(LangKey.settings_destination_picker);
public override int Priority => 1;
/// <summary>
/// Export the capture with the destination picker
/// </summary>
/// <param name="manuallyInitiated">Did the user select this destination?</param>
/// <param name="surface">Surface to export</param>
/// <param name="captureDetails">Details of the capture</param>
/// <returns>true if export was made</returns>
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
List<IDestination> destinations = new List<IDestination>();
foreach(var destination in SimpleServiceProvider.Current.GetAllInstances<IDestination>()) {
if ("Picker".Equals(destination.Designation)) {
continue;
}
if (!destination.IsActive) {
continue;
}
destinations.Add(destination);
}
// No Processing, this is done in the selected destination (if anything was selected)
return ShowPickerMenu(true, surface, captureDetails, destinations);
}
}
}

View file

@ -0,0 +1,123 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
using Greenshot.Helpers;
using GreenshotPlugin.Interfaces;
namespace Greenshot.Destinations {
/// <summary>
/// Description of PrinterDestination.
/// </summary>
public class PrinterDestination : AbstractDestination {
public const string DESIGNATION = "Printer";
private readonly string _printerName;
public PrinterDestination() {
}
public PrinterDestination(string printerName) {
_printerName = printerName;
}
public override string Designation => DESIGNATION;
public override string Description {
get {
if (_printerName != null) {
return Language.GetString(LangKey.settings_destination_printer) + " - " + _printerName;
}
return Language.GetString(LangKey.settings_destination_printer);
}
}
public override int Priority => 2;
public override Keys EditorShortcutKeys => Keys.Control | Keys.P;
public override Image DisplayIcon => GreenshotResources.getImage("Printer.Image");
public override bool IsDynamic => true;
/// <summary>
/// Create destinations for all the installed printers
/// </summary>
/// <returns>IEnumerable of IDestination</returns>
public override IEnumerable<IDestination> DynamicDestinations() {
PrinterSettings settings = new PrinterSettings();
string defaultPrinter = settings.PrinterName;
List<string> printers = new List<string>();
foreach (string printer in PrinterSettings.InstalledPrinters) {
printers.Add(printer);
}
printers.Sort(delegate(string p1, string p2) {
if(defaultPrinter.Equals(p1)) {
return -1;
}
if(defaultPrinter.Equals(p2)) {
return 1;
}
return string.Compare(p1, p2, StringComparison.Ordinal);
});
foreach(string printer in printers) {
yield return new PrinterDestination(printer);
}
}
/// <summary>
/// Export the capture to the printer
/// </summary>
/// <param name="manuallyInitiated"></param>
/// <param name="surface"></param>
/// <param name="captureDetails"></param>
/// <returns>ExportInformation</returns>
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
ExportInformation exportInformation = new ExportInformation(Designation, Description);
PrinterSettings printerSettings;
if (!string.IsNullOrEmpty(_printerName))
{
using PrintHelper printHelper = new PrintHelper(surface, captureDetails);
printerSettings = printHelper.PrintTo(_printerName);
} else if (!manuallyInitiated) {
PrinterSettings settings = new PrinterSettings();
using PrintHelper printHelper = new PrintHelper(surface, captureDetails);
printerSettings = printHelper.PrintTo(settings.PrinterName);
} else
{
using PrintHelper printHelper = new PrintHelper(surface, captureDetails);
printerSettings = printHelper.PrintWithDialog();
}
if (printerSettings != null) {
exportInformation.ExportMade = true;
}
ProcessExport(exportInformation, surface);
return exportInformation;
}
}
}

View file

@ -0,0 +1,146 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using GreenshotPlugin.Interfaces.Drawing;
using GreenshotPlugin.Interfaces.Drawing.Adorners;
namespace Greenshot.Drawing.Adorners
{
public class AbstractAdorner : IAdorner
{
public virtual EditStatus EditStatus { get; protected set; } = EditStatus.IDLE;
protected Size _size = new Size(4, 4);
public AbstractAdorner(IDrawableContainer owner)
{
Owner = owner;
}
/// <summary>
/// Returns the cursor for when the mouse is over the adorner
/// </summary>
public virtual Cursor Cursor
{
get
{
return Cursors.SizeAll;
}
}
public virtual IDrawableContainer Owner
{
get;
set;
}
/// <summary>
/// Test if the point is inside the adorner
/// </summary>
/// <param name="point"></param>
/// <returns></returns>
public virtual bool HitTest(Point point)
{
Rectangle hitBounds = Bounds;
hitBounds.Inflate(3, 3);
return hitBounds.Contains(point);
}
/// <summary>
/// Handle the mouse down
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public virtual void MouseDown(object sender, MouseEventArgs mouseEventArgs)
{
}
/// <summary>
/// Handle the mouse move
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public virtual void MouseMove(object sender, MouseEventArgs mouseEventArgs)
{
}
/// <summary>
/// Handle the mouse up
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public virtual void MouseUp(object sender, MouseEventArgs mouseEventArgs)
{
EditStatus = EditStatus.IDLE;
}
/// <summary>
/// Return the location of the adorner
/// </summary>
public virtual Point Location
{
get;
set;
}
/// <summary>
/// Return the bounds of the Adorner
/// </summary>
public virtual Rectangle Bounds
{
get
{
Point location = Location;
return new Rectangle(location.X - (_size.Width / 2), location.Y - (_size.Height / 2), _size.Width, _size.Height);
}
}
/// <summary>
/// The adorner is active if the edit status is not idle or undrawn
/// </summary>
public virtual bool IsActive
{
get
{
return EditStatus != EditStatus.IDLE && EditStatus != EditStatus.UNDRAWN;
}
}
/// <summary>
/// Draw the adorner
/// </summary>
/// <param name="paintEventArgs">PaintEventArgs</param>
public virtual void Paint(PaintEventArgs paintEventArgs)
{
}
/// <summary>
/// We ignore the Transform, as the coordinates are directly bound to those of the owner
/// </summary>
/// <param name="matrix"></param>
public virtual void Transform(Matrix matrix)
{
}
}
}

View file

@ -0,0 +1,164 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Helpers;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Adorners
{
/// <summary>
/// This is the adorner for the line based containers
/// </summary>
public class MoveAdorner : AbstractAdorner
{
private Rectangle _boundsBeforeResize = Rectangle.Empty;
private RectangleF _boundsAfterResize = RectangleF.Empty;
public Positions Position { get; private set; }
public MoveAdorner(IDrawableContainer owner, Positions position) : base(owner)
{
Position = position;
}
/// <summary>
/// Returns the cursor for when the mouse is over the adorner
/// </summary>
public override Cursor Cursor => Cursors.SizeAll;
/// <summary>
/// Handle the mouse down
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
{
EditStatus = EditStatus.RESIZING;
_boundsBeforeResize = new Rectangle(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
_boundsAfterResize = _boundsBeforeResize;
}
/// <summary>
/// Handle the mouse move
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public override void MouseMove(object sender, MouseEventArgs mouseEventArgs)
{
if (EditStatus != EditStatus.RESIZING)
{
return;
}
Owner.Invalidate();
Owner.MakeBoundsChangeUndoable(false);
// reset "workbench" rectangle to current bounds
_boundsAfterResize.X = _boundsBeforeResize.X;
_boundsAfterResize.Y = _boundsBeforeResize.Y;
_boundsAfterResize.Width = _boundsBeforeResize.Width;
_boundsAfterResize.Height = _boundsBeforeResize.Height;
// calculate scaled rectangle
ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
// apply scaled bounds to this DrawableContainer
Owner.ApplyBounds(_boundsAfterResize);
Owner.Invalidate();
}
/// <summary>
/// Return the location of the adorner
/// </summary>
public override Point Location {
get
{
int x = 0,y = 0;
switch (Position)
{
case Positions.TopLeft:
x = Owner.Left;
y = Owner.Top;
break;
case Positions.BottomLeft:
x = Owner.Left;
y = Owner.Top + Owner.Height;
break;
case Positions.MiddleLeft:
x = Owner.Left;
y = Owner.Top + (Owner.Height / 2);
break;
case Positions.TopCenter:
x = Owner.Left + (Owner.Width / 2);
y = Owner.Top;
break;
case Positions.BottomCenter:
x = Owner.Left + (Owner.Width / 2);
y = Owner.Top + Owner.Height;
break;
case Positions.TopRight:
x = Owner.Left + Owner.Width;
y = Owner.Top;
break;
case Positions.BottomRight:
x = Owner.Left + Owner.Width;
y = Owner.Top + Owner.Height;
break;
case Positions.MiddleRight:
x = Owner.Left + Owner.Width;
y = Owner.Top + (Owner.Height / 2);
break;
}
return new Point(x, y);
}
}
/// <summary>
/// Draw the adorner
/// </summary>
/// <param name="paintEventArgs">PaintEventArgs</param>
public override void Paint(PaintEventArgs paintEventArgs)
{
Graphics targetGraphics = paintEventArgs.Graphics;
var bounds = Bounds;
GraphicsState state = targetGraphics.Save();
targetGraphics.SmoothingMode = SmoothingMode.None;
targetGraphics.CompositingMode = CompositingMode.SourceCopy;
targetGraphics.PixelOffsetMode = PixelOffsetMode.Half;
targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
try
{
targetGraphics.FillRectangle(Brushes.Black, bounds.X, bounds.Y, bounds.Width, bounds.Height);
}
catch
{
// Ignore, BUG-2065
}
targetGraphics.Restore(state);
}
}
}

View file

@ -0,0 +1,184 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Helpers;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Adorners
{
/// <summary>
/// This is the default "legacy" gripper adorner, not the one used for the tail in the speech-bubble
/// </summary>
public class ResizeAdorner : AbstractAdorner
{
private Rectangle _boundsBeforeResize = Rectangle.Empty;
private RectangleF _boundsAfterResize = RectangleF.Empty;
public Positions Position { get; private set; }
public ResizeAdorner(IDrawableContainer owner, Positions position) : base(owner)
{
Position = position;
}
/// <summary>
/// Returns the cursor for when the mouse is over the adorner
/// </summary>
public override Cursor Cursor
{
get
{
bool isNotSwitched = Owner.Width >= 0;
if (Owner.Height < 0)
{
isNotSwitched = !isNotSwitched;
}
switch (Position)
{
case Positions.TopLeft:
case Positions.BottomRight:
return isNotSwitched ? Cursors.SizeNWSE : Cursors.SizeNESW;
case Positions.TopRight:
case Positions.BottomLeft:
return isNotSwitched ? Cursors.SizeNESW : Cursors.SizeNWSE;
case Positions.MiddleLeft:
case Positions.MiddleRight:
return Cursors.SizeWE;
case Positions.TopCenter:
case Positions.BottomCenter:
return Cursors.SizeNS;
default:
return Cursors.SizeAll;
}
}
}
/// <summary>
/// Handle the mouse down
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
{
EditStatus = EditStatus.RESIZING;
_boundsBeforeResize = new Rectangle(Owner.Left, Owner.Top, Owner.Width, Owner.Height);
_boundsAfterResize = _boundsBeforeResize;
}
/// <summary>
/// Handle the mouse move
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public override void MouseMove(object sender, MouseEventArgs mouseEventArgs)
{
if (EditStatus != EditStatus.RESIZING)
{
return;
}
Owner.Invalidate();
Owner.MakeBoundsChangeUndoable(false);
// reset "workbench" rectangle to current bounds
_boundsAfterResize.X = _boundsBeforeResize.X;
_boundsAfterResize.Y = _boundsBeforeResize.Y;
_boundsAfterResize.Width = _boundsBeforeResize.Width;
_boundsAfterResize.Height = _boundsBeforeResize.Height;
// calculate scaled rectangle
ScaleHelper.Scale(ref _boundsAfterResize, Position, new PointF(mouseEventArgs.X, mouseEventArgs.Y), ScaleHelper.GetScaleOptions());
// apply scaled bounds to this DrawableContainer
Owner.ApplyBounds(_boundsAfterResize);
Owner.Invalidate();
}
/// <summary>
/// Return the location of the adorner
/// </summary>
public override Point Location {
get
{
int x = 0,y = 0;
switch (Position)
{
case Positions.TopLeft:
x = Owner.Left;
y = Owner.Top;
break;
case Positions.BottomLeft:
x = Owner.Left;
y = Owner.Top + Owner.Height;
break;
case Positions.MiddleLeft:
x = Owner.Left;
y = Owner.Top + (Owner.Height / 2);
break;
case Positions.TopCenter:
x = Owner.Left + (Owner.Width / 2);
y = Owner.Top;
break;
case Positions.BottomCenter:
x = Owner.Left + (Owner.Width / 2);
y = Owner.Top + Owner.Height;
break;
case Positions.TopRight:
x = Owner.Left + Owner.Width;
y = Owner.Top;
break;
case Positions.BottomRight:
x = Owner.Left + Owner.Width;
y = Owner.Top + Owner.Height;
break;
case Positions.MiddleRight:
x = Owner.Left + Owner.Width;
y = Owner.Top + (Owner.Height / 2);
break;
}
return new Point(x, y);
}
}
/// <summary>
/// Draw the adorner
/// </summary>
/// <param name="paintEventArgs">PaintEventArgs</param>
public override void Paint(PaintEventArgs paintEventArgs)
{
Graphics targetGraphics = paintEventArgs.Graphics;
var bounds = Bounds;
GraphicsState state = targetGraphics.Save();
targetGraphics.SmoothingMode = SmoothingMode.None;
targetGraphics.CompositingMode = CompositingMode.SourceCopy;
targetGraphics.PixelOffsetMode = PixelOffsetMode.Half;
targetGraphics.InterpolationMode = InterpolationMode.NearestNeighbor;
targetGraphics.FillRectangle(Brushes.Black, bounds.X, bounds.Y, bounds.Width , bounds.Height);
targetGraphics.Restore(state);
}
}
}

View file

@ -0,0 +1,118 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Adorners
{
/// <summary>
/// This implements the special "gripper" for the Speech-Bubble tail
/// </summary>
public class TargetAdorner : AbstractAdorner
{
public TargetAdorner(IDrawableContainer owner, Point location) : base(owner)
{
Location = location;
}
/// <summary>
/// Handle the mouse down
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public override void MouseDown(object sender, MouseEventArgs mouseEventArgs)
{
EditStatus = EditStatus.MOVING;
}
/// <summary>
/// Handle the mouse move
/// </summary>
/// <param name="sender"></param>
/// <param name="mouseEventArgs"></param>
public override void MouseMove(object sender, MouseEventArgs mouseEventArgs)
{
if (EditStatus != EditStatus.MOVING)
{
return;
}
Owner.Invalidate();
Point newGripperLocation = new Point(mouseEventArgs.X, mouseEventArgs.Y);
Rectangle surfaceBounds = new Rectangle(0, 0, Owner.Parent.Width, Owner.Parent.Height);
// Check if gripper inside the parent (surface), if not we need to move it inside
// This was made for BUG-1682
if (!surfaceBounds.Contains(newGripperLocation))
{
if (newGripperLocation.X > surfaceBounds.Right)
{
newGripperLocation.X = surfaceBounds.Right - 5;
}
if (newGripperLocation.X < surfaceBounds.Left)
{
newGripperLocation.X = surfaceBounds.Left;
}
if (newGripperLocation.Y > surfaceBounds.Bottom)
{
newGripperLocation.Y = surfaceBounds.Bottom - 5;
}
if (newGripperLocation.Y < surfaceBounds.Top)
{
newGripperLocation.Y = surfaceBounds.Top;
}
}
Location = newGripperLocation;
Owner.Invalidate();
}
/// <summary>
/// Draw the adorner
/// </summary>
/// <param name="paintEventArgs">PaintEventArgs</param>
public override void Paint(PaintEventArgs paintEventArgs)
{
Graphics targetGraphics = paintEventArgs.Graphics;
var bounds = Bounds;
targetGraphics.FillRectangle(Brushes.Green, bounds.X, bounds.Y, bounds.Width, bounds.Height);
}
/// <summary>
/// Made sure this adorner is transformed
/// </summary>
/// <param name="matrix">Matrix</param>
public override void Transform(Matrix matrix)
{
if (matrix == null)
{
return;
}
Point[] points = new[] { Location };
matrix.TransformPoints(points);
Location = points[0];
}
}
}

View file

@ -0,0 +1,141 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Drawing.Drawing2D;
using Greenshot.Drawing.Fields;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of LineContainer.
/// </summary>
[Serializable()]
public class ArrowContainer : LineContainer {
public enum ArrowHeadCombination { NONE, START_POINT, END_POINT, BOTH };
private static readonly AdjustableArrowCap ARROW_CAP = new AdjustableArrowCap(4, 6);
public ArrowContainer(Surface parent) : base(parent) {
}
/// <summary>
/// Do not use the base, just override so we have our own defaults
/// </summary>
protected override void InitializeFields() {
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.ARROWHEADS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
AddField(GetType(), FieldType.SHADOW, true);
AddField(GetType(), FieldType.ARROWHEADS, ArrowHeadCombination.END_POINT);
}
public override void Draw(Graphics graphics, RenderMode rm) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
if (lineThickness > 0 ) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
ArrowHeadCombination heads = (ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS);
if (lineThickness > 0) {
if (shadow) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while (currentStep <= steps)
{
using Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness);
SetArrowHeads(heads, shadowCapPen);
graphics.DrawLine(shadowCapPen,
Left + currentStep,
Top + currentStep,
Left + currentStep + Width,
Top + currentStep + Height);
currentStep++;
alpha -= basealpha / steps;
}
}
using Pen pen = new Pen(lineColor, lineThickness);
SetArrowHeads(heads, pen);
graphics.DrawLine(pen, Left, Top, Left + Width, Top + Height);
}
}
}
private void SetArrowHeads(ArrowHeadCombination heads, Pen pen) {
if ( heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.START_POINT ) {
pen.CustomStartCap = ARROW_CAP;
}
if ( heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.END_POINT ) {
pen.CustomEndCap = ARROW_CAP;
}
}
public override Rectangle DrawingBounds {
get {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
if (lineThickness > 0)
{
using Pen pen = new Pen(Color.White)
{
Width = lineThickness
};
SetArrowHeads((ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS), pen);
using GraphicsPath path = new GraphicsPath();
path.AddLine(Left, Top, Left + Width, Top + Height);
using Matrix matrix = new Matrix();
Rectangle drawingBounds = Rectangle.Round(path.GetBounds(matrix, pen));
drawingBounds.Inflate(2, 2);
return drawingBounds;
}
return Rectangle.Empty;
}
}
public override bool ClickableAt(int x, int y) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) + 10;
if (lineThickness > 0)
{
using Pen pen = new Pen(Color.White)
{
Width = lineThickness
};
SetArrowHeads((ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS), pen);
using GraphicsPath path = new GraphicsPath();
path.AddLine(Left, Top, Left + Width, Top + Height);
return path.IsOutlineVisible(x, y, pen);
}
return false;
}
}
}

View file

@ -0,0 +1,90 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.Drawing;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of CropContainer.
/// </summary>
public class CropContainer : DrawableContainer {
public CropContainer(Surface parent) : base(parent) {
Init();
}
protected override void OnDeserialized(StreamingContext streamingContext)
{
base.OnDeserialized(streamingContext);
Init();
}
private void Init()
{
CreateDefaultAdorners();
}
protected override void InitializeFields() {
AddField(GetType(), FieldType.FLAGS, FieldFlag.CONFIRMABLE);
}
public override void Invalidate() {
_parent?.Invalidate();
}
/// <summary>
/// We need to override the DrawingBound, return a rectangle in the size of the image, to make sure this element is always draw
/// (we create a transparent brown over the complete picture)
/// </summary>
public override Rectangle DrawingBounds => new Rectangle(0,0,_parent?.Width??0, _parent?.Height ?? 0);
public override void Draw(Graphics g, RenderMode rm) {
if (_parent == null)
{
return;
}
using Brush cropBrush = new SolidBrush(Color.FromArgb(100, 150, 150, 100));
Rectangle cropRectangle = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
Rectangle selectionRect = new Rectangle(cropRectangle.Left - 1, cropRectangle.Top - 1, cropRectangle.Width + 1, cropRectangle.Height + 1);
DrawSelectionBorder(g, selectionRect);
// top
g.FillRectangle(cropBrush, new Rectangle(0, 0, _parent.Width, cropRectangle.Top));
// left
g.FillRectangle(cropBrush, new Rectangle(0, cropRectangle.Top, cropRectangle.Left, cropRectangle.Height));
// right
g.FillRectangle(cropBrush, new Rectangle(cropRectangle.Left + cropRectangle.Width, cropRectangle.Top, _parent.Width - (cropRectangle.Left + cropRectangle.Width), cropRectangle.Height));
// bottom
g.FillRectangle(cropBrush, new Rectangle(0, cropRectangle.Top + cropRectangle.Height, _parent.Width, _parent.Height - (cropRectangle.Top + cropRectangle.Height)));
}
public override bool HasContextMenu {
get {
// No context menu for the CropContainer
return false;
}
}
}
}

View file

@ -0,0 +1,114 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
using log4net;
using System.Runtime.Serialization;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of CursorContainer.
/// </summary>
[Serializable]
public class CursorContainer : DrawableContainer, ICursorContainer {
private static readonly ILog LOG = LogManager.GetLogger(typeof(CursorContainer));
protected Cursor cursor;
public CursorContainer(Surface parent) : base(parent) {
Init();
}
protected override void OnDeserialized(StreamingContext streamingContext)
{
base.OnDeserialized(streamingContext);
Init();
}
private void Init()
{
CreateDefaultAdorners();
}
public CursorContainer(Surface parent, string filename) : this(parent) {
Load(filename);
}
public Cursor Cursor {
set {
if (cursor != null) {
cursor.Dispose();
}
// Clone cursor (is this correct??)
cursor = new Cursor(value.CopyHandle());
Width = value.Size.Width;
Height = value.Size.Height;
}
get { return cursor; }
}
/// <summary>
/// This Dispose is called from the Dispose and the Destructor.
/// When disposing==true all non-managed resources should be freed too!
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing) {
if (disposing) {
if (cursor != null) {
cursor.Dispose();
}
}
cursor = null;
base.Dispose(disposing);
}
public void Load(string filename) {
if (!File.Exists(filename)) {
return;
}
using Cursor fileCursor = new Cursor(filename);
Cursor = fileCursor;
LOG.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
}
public override void Draw(Graphics graphics, RenderMode rm) {
if (cursor == null) {
return;
}
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
graphics.CompositingQuality = CompositingQuality.Default;
graphics.PixelOffsetMode = PixelOffsetMode.None;
cursor.DrawStretched(graphics, Bounds);
}
public override Size DefaultSize {
get {
return cursor.Size;
}
}
}
}

View file

@ -0,0 +1,608 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Configuration;
using Greenshot.Drawing.Adorners;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
using Greenshot.Helpers;
using Greenshot.Memento;
using GreenshotPlugin.Interfaces.Drawing;
using log4net;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.Serialization;
using System.Windows.Forms;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces;
using GreenshotPlugin.Interfaces.Drawing.Adorners;
namespace Greenshot.Drawing
{
/// <summary>
/// represents a rectangle, ellipse, label or whatever. Can contain filters, too.
/// serializable for clipboard support
/// Subclasses should fulfill INotifyPropertyChanged contract, i.e. call
/// OnPropertyChanged whenever a public property has been changed.
/// </summary>
[Serializable]
public abstract class DrawableContainer : AbstractFieldHolderWithChildren, IDrawableContainer {
private static readonly ILog LOG = LogManager.GetLogger(typeof(DrawableContainer));
protected static readonly EditorConfiguration EditorConfig = IniConfig.GetIniSection<EditorConfiguration>();
private const int M11 = 0;
private const int M22 = 3;
[OnDeserialized]
private void OnDeserializedInit(StreamingContext context)
{
_adorners = new List<IAdorner>();
OnDeserialized(context);
}
/// <summary>
/// Override to implement your own deserialization logic, like initializing properties which are not serialized
/// </summary>
/// <param name="streamingContext"></param>
protected virtual void OnDeserialized(StreamingContext streamingContext)
{
}
protected EditStatus _defaultEditMode = EditStatus.DRAWING;
public EditStatus DefaultEditMode {
get {
return _defaultEditMode;
}
}
/// <summary>
/// The public accessible Dispose
/// Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
/// </summary>
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing) {
if (!disposing) {
return;
}
_parent?.FieldAggregator?.UnbindElement(this);
}
~DrawableContainer() {
Dispose(false);
}
[NonSerialized]
private PropertyChangedEventHandler _propertyChanged;
public event PropertyChangedEventHandler PropertyChanged {
add { _propertyChanged += value; }
remove{ _propertyChanged -= value; }
}
public IList<IFilter> Filters {
get {
List<IFilter> ret = new List<IFilter>();
foreach(IFieldHolder c in Children) {
if (c is IFilter) {
ret.Add(c as IFilter);
}
}
return ret;
}
}
[NonSerialized]
internal Surface _parent;
public ISurface Parent {
get { return _parent; }
set { SwitchParent((Surface)value); }
}
[NonSerialized]
private TargetAdorner _targetAdorner;
public TargetAdorner TargetAdorner {
get {
return _targetAdorner;
}
}
[NonSerialized]
private bool _selected;
public bool Selected {
get {return _selected;}
set {
_selected = value;
OnPropertyChanged("Selected");
}
}
[NonSerialized]
private EditStatus _status = EditStatus.UNDRAWN;
public EditStatus Status {
get {
return _status;
}
set {
_status = value;
}
}
private int left;
public int Left {
get { return left; }
set {
if (value == left) {
return;
}
left = value;
}
}
private int top;
public int Top {
get { return top; }
set {
if (value == top) {
return;
}
top = value;
}
}
private int width;
public int Width {
get { return width; }
set {
if (value == width) {
return;
}
width = value;
}
}
private int height;
public int Height {
get { return height; }
set {
if (value == height) {
return;
}
height = value;
}
}
public Point Location {
get {
return new Point(left, top);
}
set {
left = value.X;
top = value.Y;
}
}
public Size Size {
get {
return new Size(width, height);
}
set {
width = value.Width;
height = value.Height;
}
}
/// <summary>
/// List of available Adorners
/// </summary>
[NonSerialized]
private IList<IAdorner> _adorners = new List<IAdorner>();
public IList<IAdorner> Adorners
{
get
{
return _adorners;
}
}
[NonSerialized]
// will store current bounds of this DrawableContainer before starting a resize
protected Rectangle _boundsBeforeResize = Rectangle.Empty;
[NonSerialized]
// "workbench" rectangle - used for calculating bounds during resizing (to be applied to this DrawableContainer afterwards)
protected RectangleF _boundsAfterResize = RectangleF.Empty;
public Rectangle Bounds {
get { return GuiRectangle.GetGuiRectangle(Left, Top, Width, Height); }
set {
Left = Round(value.Left);
Top = Round(value.Top);
Width = Round(value.Width);
Height = Round(value.Height);
}
}
public virtual void ApplyBounds(RectangleF newBounds) {
Left = Round(newBounds.Left);
Top = Round(newBounds.Top);
Width = Round(newBounds.Width);
Height = Round(newBounds.Height);
}
public DrawableContainer(Surface parent) {
InitializeFields();
_parent = parent;
}
public void Add(IFilter filter) {
AddChild(filter);
}
public void Remove(IFilter filter) {
RemoveChild(filter);
}
private static int Round(float f) {
if(float.IsPositiveInfinity(f) || f>int.MaxValue/2) return int.MaxValue/2;
if (float.IsNegativeInfinity(f) || f<int.MinValue/2) return int.MinValue/2;
return (int)Math.Round(f);
}
private bool accountForShadowChange;
public virtual Rectangle DrawingBounds {
get {
foreach(IFilter filter in Filters) {
if (filter.Invert) {
return new Rectangle(Point.Empty, _parent.Image.Size);
}
}
// Take a base safetymargin
int lineThickness = 5;
if (HasField(FieldType.LINE_THICKNESS)) {
lineThickness += GetFieldValueAsInt(FieldType.LINE_THICKNESS);
}
int offset = lineThickness/2;
int shadow = 0;
if (accountForShadowChange || (HasField(FieldType.SHADOW) && GetFieldValueAsBool(FieldType.SHADOW))){
accountForShadowChange = false;
shadow += 10;
}
return new Rectangle(Bounds.Left-offset, Bounds.Top-offset, Bounds.Width+lineThickness+shadow, Bounds.Height+lineThickness+shadow);
}
}
public virtual void Invalidate() {
if (Status != EditStatus.UNDRAWN) {
_parent?.Invalidate(DrawingBounds);
}
}
public void AlignToParent(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) {
if (_parent == null)
{
return;
}
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
if (horizontalAlignment == HorizontalAlignment.Left) {
Left = lineThickness/2;
}
if (horizontalAlignment == HorizontalAlignment.Right) {
Left = _parent.Width - Width - lineThickness/2;
}
if (horizontalAlignment == HorizontalAlignment.Center) {
Left = (_parent.Width / 2) - (Width / 2) - lineThickness/2;
}
if (verticalAlignment == VerticalAlignment.TOP) {
Top = lineThickness/2;
}
if (verticalAlignment == VerticalAlignment.BOTTOM) {
Top = _parent.Height - Height - lineThickness/2;
}
if (verticalAlignment == VerticalAlignment.CENTER) {
Top = (_parent.Height / 2) - (Height / 2) - lineThickness/2;
}
}
public virtual bool InitContent() { return true; }
public virtual void OnDoubleClick() {}
/// <summary>
/// Initialize a target gripper
/// </summary>
protected void InitAdorner(Color gripperColor, Point location) {
_targetAdorner = new TargetAdorner(this, location);
Adorners.Add(_targetAdorner);
}
/// <summary>
/// Create the default adorners for a rectangle based container
/// </summary>
protected void CreateDefaultAdorners() {
if (Adorners.Count > 0)
{
LOG.Warn("Adorners are already defined!");
}
// Create the GripperAdorners
Adorners.Add(new ResizeAdorner(this, Positions.TopLeft));
Adorners.Add(new ResizeAdorner(this, Positions.TopCenter));
Adorners.Add(new ResizeAdorner(this, Positions.TopRight));
Adorners.Add(new ResizeAdorner(this, Positions.BottomLeft));
Adorners.Add(new ResizeAdorner(this, Positions.BottomCenter));
Adorners.Add(new ResizeAdorner(this, Positions.BottomRight));
Adorners.Add(new ResizeAdorner(this, Positions.MiddleLeft));
Adorners.Add(new ResizeAdorner(this, Positions.MiddleRight));
}
public bool hasFilters {
get {
return Filters.Count > 0;
}
}
public abstract void Draw(Graphics graphics, RenderMode renderMode);
public virtual void DrawContent(Graphics graphics, Bitmap bmp, RenderMode renderMode, Rectangle clipRectangle) {
if (Children.Count > 0) {
if (Status != EditStatus.IDLE) {
DrawSelectionBorder(graphics, Bounds);
} else {
if (clipRectangle.Width != 0 && clipRectangle.Height != 0) {
foreach(IFilter filter in Filters) {
if (filter.Invert) {
filter.Apply(graphics, bmp, Bounds, renderMode);
} else {
Rectangle drawingRect = new Rectangle(Bounds.Location, Bounds.Size);
drawingRect.Intersect(clipRectangle);
if(filter is MagnifierFilter) {
// quick&dirty bugfix, because MagnifierFilter behaves differently when drawn only partially
// what we should actually do to resolve this is add a better magnifier which is not that special
filter.Apply(graphics, bmp, Bounds, renderMode);
} else {
filter.Apply(graphics, bmp, drawingRect, renderMode);
}
}
}
}
}
}
Draw(graphics, renderMode);
}
public virtual bool Contains(int x, int y) {
return Bounds.Contains(x , y);
}
public virtual bool ClickableAt(int x, int y) {
Rectangle r = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
r.Inflate(5, 5);
return r.Contains(x, y);
}
protected void DrawSelectionBorder(Graphics g, Rectangle rect)
{
using Pen pen = new Pen(Color.MediumSeaGreen)
{
DashPattern = new float[] { 1, 2 },
Width = 1
};
g.DrawRectangle(pen, rect);
}
public void ResizeTo(int width, int height, int anchorPosition) {
Width = width;
Height = height;
}
/// <summary>
/// Make a following bounds change on this drawablecontainer undoable!
/// </summary>
/// <param name="allowMerge">true means allow the moves to be merged</param>
public void MakeBoundsChangeUndoable(bool allowMerge) {
_parent.MakeUndoable(new DrawableContainerBoundsChangeMemento(this), allowMerge);
}
public void MoveBy(int dx, int dy) {
Left += dx;
Top += dy;
}
/// <summary>
/// A handler for the MouseDown, used if you don't want the surface to handle this for you
/// </summary>
/// <param name="x">current mouse x</param>
/// <param name="y">current mouse y</param>
/// <returns>true if the event is handled, false if the surface needs to handle it</returns>
public virtual bool HandleMouseDown(int x, int y) {
Left = _boundsBeforeResize.X = x;
Top = _boundsBeforeResize.Y = y;
return true;
}
/// <summary>
/// A handler for the MouseMove, used if you don't want the surface to handle this for you
/// </summary>
/// <param name="x">current mouse x</param>
/// <param name="y">current mouse y</param>
/// <returns>true if the event is handled, false if the surface needs to handle it</returns>
public virtual bool HandleMouseMove(int x, int y) {
Invalidate();
// reset "workrbench" rectangle to current bounds
_boundsAfterResize.X = _boundsBeforeResize.Left;
_boundsAfterResize.Y = _boundsBeforeResize.Top;
_boundsAfterResize.Width = x - _boundsAfterResize.Left;
_boundsAfterResize.Height = y - _boundsAfterResize.Top;
ScaleHelper.Scale(_boundsBeforeResize, x, y, ref _boundsAfterResize, GetAngleRoundProcessor());
// apply scaled bounds to this DrawableContainer
ApplyBounds(_boundsAfterResize);
Invalidate();
return true;
}
/// <summary>
/// A handler for the MouseUp
/// </summary>
/// <param name="x">current mouse x</param>
/// <param name="y">current mouse y</param>
public virtual void HandleMouseUp(int x, int y) {
}
protected virtual void SwitchParent(Surface newParent) {
if (newParent == Parent)
{
return;
}
_parent?.FieldAggregator?.UnbindElement(this);
_parent = newParent;
foreach(IFilter filter in Filters) {
filter.Parent = this;
}
}
protected void OnPropertyChanged(string propertyName) {
if (_propertyChanged != null) {
_propertyChanged(this, new PropertyChangedEventArgs(propertyName));
Invalidate();
}
}
/// <summary>
/// This method will be called before a field is changes.
/// Using this makes it possible to invalidate the object as is before changing.
/// </summary>
/// <param name="fieldToBeChanged">The field to be changed</param>
/// <param name="newValue">The new value</param>
public virtual void BeforeFieldChange(IField fieldToBeChanged, object newValue) {
_parent?.MakeUndoable(new ChangeFieldHolderMemento(this, fieldToBeChanged), true);
Invalidate();
}
/// <summary>
/// Handle the field changed event, this should invalidate the correct bounds (e.g. when shadow comes or goes more pixels!)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void HandleFieldChanged(object sender, FieldChangedEventArgs e) {
LOG.DebugFormat("Field {0} changed", e.Field.FieldType);
if (Equals(e.Field.FieldType, FieldType.SHADOW)) {
accountForShadowChange = true;
}
}
/// <summary>
/// Retrieve the Y scale from the matrix
/// </summary>
/// <param name="matrix"></param>
/// <returns></returns>
public static float CalculateScaleY(Matrix matrix) {
return matrix.Elements[M22];
}
/// <summary>
/// Retrieve the X scale from the matrix
/// </summary>
/// <param name="matrix"></param>
/// <returns></returns>
public static float CalculateScaleX(Matrix matrix) {
return matrix.Elements[M11];
}
/// <summary>
/// Retrieve the rotation angle from the matrix
/// </summary>
/// <param name="matrix"></param>
/// <returns></returns>
public static int CalculateAngle(Matrix matrix) {
const int M11 = 0;
const int M21 = 2;
var radians = Math.Atan2(matrix.Elements[M21], matrix.Elements[M11]);
return (int)-Math.Round(radians * 180 / Math.PI);
}
/// <summary>
/// This method is called on a DrawableContainers when:
/// 1) The capture on the surface is modified in such a way, that the elements would not be placed correctly.
/// 2) Currently not implemented: an element needs to be moved, scaled or rotated.
/// This basis implementation makes sure the coordinates of the element, including the TargetGripper, is correctly rotated/scaled/translated.
/// But this implementation doesn't take care of any changes to the content!!
/// </summary>
/// <param name="matrix"></param>
public virtual void Transform(Matrix matrix) {
if (matrix == null) {
return;
}
Point topLeft = new Point(Left, Top);
Point bottomRight = new Point(Left + Width, Top + Height);
Point[] points = new[] { topLeft, bottomRight };
matrix.TransformPoints(points);
Left = points[0].X;
Top = points[0].Y;
Width = points[1].X - points[0].X;
Height = points[1].Y - points[0].Y;
}
protected virtual ScaleHelper.IDoubleProcessor GetAngleRoundProcessor() {
return ScaleHelper.ShapeAngleRoundBehavior.Instance;
}
public virtual bool HasContextMenu {
get {
return true;
}
}
public virtual bool HasDefaultSize {
get {
return false;
}
}
public virtual Size DefaultSize {
get {
throw new NotSupportedException("Object doesn't have a default size");
}
}
/// <summary>
/// Allows to override the initializing of the fields, so we can actually have our own defaults
/// </summary>
protected virtual void InitializeFields() {
}
}
}

View file

@ -0,0 +1,585 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Configuration;
using Greenshot.Memento;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces.Drawing;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Threading;
using System.Windows.Forms;
using GreenshotPlugin.Interfaces;
namespace Greenshot.Drawing {
/// <summary>
/// Dispatches most of a DrawableContainer's public properties and methods to a list of DrawableContainers.
/// </summary>
[Serializable]
public class DrawableContainerList : List<IDrawableContainer>, IDrawableContainerList
{
private static readonly ComponentResourceManager EditorFormResources = new ComponentResourceManager(typeof(ImageEditorForm));
public Guid ParentID {
get;
private set;
}
public DrawableContainerList() {
}
public DrawableContainerList(Guid parentId) {
ParentID = parentId;
}
public EditStatus Status {
get {
return this[Count-1].Status;
}
set {
foreach (var dc in this) {
dc.Status = value;
}
}
}
public List<IDrawableContainer> AsIDrawableContainerList() {
List<IDrawableContainer> interfaceList = new List<IDrawableContainer>();
foreach(IDrawableContainer container in this) {
interfaceList.Add(container);
}
return interfaceList;
}
/// <summary>
/// Gets or sets the selection status of the elements.
/// If several elements are in the list, true is only returned when all elements are selected.
/// </summary>
public bool Selected {
get {
bool ret = true;
foreach(var dc in this) {
ret &= dc.Selected;
}
return ret;
}
set {
foreach(var dc in this) {
dc.Selected = value;
}
}
}
/// <summary>
/// Gets or sets the parent control of the elements in the list.
/// If there are several elements, the parent control of the last added is returned.
/// </summary>
public ISurface Parent {
get {
if (Count > 0) {
return this[Count-1].Parent;
}
return null;
}
set {
ParentID = value?.ID ?? Guid.NewGuid();
foreach (var drawableContainer in this) {
var dc = (DrawableContainer) drawableContainer;
dc.Parent = value;
}
}
}
/// <summary>
/// Make a following bounds change on this containerlist undoable!
/// </summary>
/// <param name="allowMerge">true means allow the moves to be merged</param>
public void MakeBoundsChangeUndoable(bool allowMerge) {
if (Count > 0 && Parent != null)
{
var clone = new DrawableContainerList();
clone.AddRange(this);
Parent.MakeUndoable(new DrawableContainerBoundsChangeMemento(clone), allowMerge);
}
}
/// <summary>
/// Apply matrix to all elements
/// </summary>
public void Transform(Matrix matrix) {
// Track modifications
bool modified = false;
Invalidate();
foreach (var dc in this) {
dc.Transform(matrix);
modified = true;
}
// Invalidate after
Invalidate();
// If we moved something, tell the surface it's modified!
if (modified) {
Parent.Modified = true;
}
}
/// <summary>
/// Moves all elements in the list by the given amount of pixels.
/// </summary>
/// <param name="dx">pixels to move horizontally</param>
/// <param name="dy">pixels to move vertically</param>
public void MoveBy(int dx, int dy) {
// Track modifications
bool modified = false;
// Invalidate before moving, otherwise the old locations aren't refreshed
Invalidate();
foreach(var dc in this) {
dc.Left += dx;
dc.Top += dy;
modified = true;
}
// Invalidate after
Invalidate();
// If we moved something, tell the surface it's modified!
if (modified) {
Parent.Modified = true;
}
}
/// <summary>
/// Indicates whether on of the elements is clickable at the given location
/// </summary>
/// <param name="x">x coordinate to be checked</param>
/// <param name="y">y coordinate to be checked</param>
/// <returns>true if one of the elements in the list is clickable at the given location, false otherwise</returns>
public bool ClickableAt(int x, int y) {
bool ret = false;
foreach(var dc in this) {
ret |= dc.ClickableAt(x, y);
}
return ret;
}
/// <summary>
/// retrieves the topmost element being clickable at the given location
/// </summary>
/// <param name="x">x coordinate to be checked</param>
/// <param name="y">y coordinate to be checked</param>
/// <returns>the topmost element from the list being clickable at the given location, null if there is no clickable element</returns>
public IDrawableContainer ClickableElementAt(int x, int y) {
for (int i=Count-1; i>=0; i--) {
if (this[i].ClickableAt(x,y)) {
return this[i];
}
}
return null;
}
/// <summary>
/// Dispatches OnDoubleClick to all elements in the list.
/// </summary>
public void OnDoubleClick() {
foreach(var drawableContainer in this) {
var dc = (DrawableContainer) drawableContainer;
dc.OnDoubleClick();
}
}
/// <summary>
/// Check if there are any intersecting filters, if so we need to redraw more
/// </summary>
/// <param name="clipRectangle"></param>
/// <returns>true if an filter intersects</returns>
public bool HasIntersectingFilters(Rectangle clipRectangle) {
foreach(var dc in this) {
if (dc.DrawingBounds.IntersectsWith(clipRectangle) && dc.hasFilters && dc.Status == EditStatus.IDLE) {
return true;
}
}
return false;
}
/// <summary>
/// Check if any of the drawableContainers are inside the rectangle
/// </summary>
/// <param name="clipRectangle"></param>
/// <returns></returns>
public bool IntersectsWith(Rectangle clipRectangle) {
foreach(var dc in this) {
if (dc.DrawingBounds.IntersectsWith(clipRectangle)) {
return true;
}
}
return false;
}
/// <summary>
/// Triggers all elements in the list ot be redrawn.
/// </summary>
/// <param name="g">the to the bitmap related Graphics object</param>
/// <param name="bitmap">Bitmap to draw</param>
/// <param name="renderMode">the rendermode in which the element is to be drawn</param>
/// <param name="clipRectangle"></param>
public void Draw(Graphics g, Bitmap bitmap, RenderMode renderMode, Rectangle clipRectangle) {
if (Parent == null)
{
return;
}
foreach (var drawableContainer in this)
{
var dc = (DrawableContainer)drawableContainer;
if (dc.Parent == null)
{
continue;
}
if (dc.DrawingBounds.IntersectsWith(clipRectangle))
{
dc.DrawContent(g, bitmap, renderMode, clipRectangle);
}
}
}
/// <summary>
/// Pass the field changed event to all elements in the list
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void HandleFieldChangedEvent(object sender, FieldChangedEventArgs e) {
foreach(var drawableContainer in this) {
var dc = (DrawableContainer) drawableContainer;
dc.HandleFieldChanged(sender, e);
}
}
/// <summary>
/// Invalidate the bounds of all the DC's in this list
/// </summary>
public void Invalidate() {
if (Parent == null)
{
return;
}
Rectangle region = Rectangle.Empty;
foreach (var dc in this)
{
region = Rectangle.Union(region, dc.DrawingBounds);
}
Parent.Invalidate(region);
}
/// <summary>
/// Indicates whether the given list of elements can be pulled up,
/// i.e. whether there is at least one unselected element higher in hierarchy
/// </summary>
/// <param name="elements">list of elements to pull up</param>
/// <returns>true if the elements could be pulled up</returns>
public bool CanPullUp(IDrawableContainerList elements) {
if (elements.Count == 0 || elements.Count == Count) {
return false;
}
foreach(var element in elements) {
if (IndexOf(element) < Count - elements.Count) {
return true;
}
}
return false;
}
/// <summary>
/// Pulls one or several elements up one level in hierarchy (z-index).
/// </summary>
/// <param name="elements">list of elements to pull up</param>
public void PullElementsUp(IDrawableContainerList elements) {
for(int i=Count-1; i>=0; i--) {
var dc = this[i];
if (!elements.Contains(dc)) {
continue;
}
if (Count > i+1 && !elements.Contains(this[i+1])) {
SwapElements(i,i+1);
}
}
}
/// <summary>
/// Pulls one or several elements up to the topmost level(s) in hierarchy (z-index).
/// </summary>
/// <param name="elements">of elements to pull to top</param>
public void PullElementsToTop(IDrawableContainerList elements)
{
var dcs = ToArray();
foreach (var dc in dcs)
{
if (!elements.Contains(dc)) {
continue;
}
Remove(dc);
Add(dc);
Parent.Modified = true;
}
}
/// <summary>
/// Indicates whether the given list of elements can be pushed down,
/// i.e. whether there is at least one unselected element lower in hierarchy
/// </summary>
/// <param name="elements">list of elements to push down</param>
/// <returns>true if the elements could be pushed down</returns>
public bool CanPushDown(IDrawableContainerList elements) {
if (elements.Count == 0 || elements.Count == Count) {
return false;
}
foreach(var element in elements) {
if (IndexOf(element) >= elements.Count) {
return true;
}
}
return false;
}
/// <summary>
/// Pushes one or several elements down one level in hierarchy (z-index).
/// </summary>
/// <param name="elements">list of elements to push down</param>
public void PushElementsDown(IDrawableContainerList elements) {
for(int i=0; i<Count; i++) {
var dc = this[i];
if (!elements.Contains(dc)) {
continue;
}
if((i>0) && !elements.Contains(this[i-1])) {
SwapElements(i,i-1);
}
}
}
/// <summary>
/// Pushes one or several elements down to the bottommost level(s) in hierarchy (z-index).
/// </summary>
/// <param name="elements">of elements to push to bottom</param>
public void PushElementsToBottom(IDrawableContainerList elements) {
var dcs = ToArray();
for(int i=dcs.Length-1; i>=0; i--) {
var dc = dcs[i];
if (!elements.Contains(dc)) {
continue;
}
Remove(dc);
Insert(0, dc);
Parent.Modified = true;
}
}
/// <summary>
/// swaps two elements in hierarchy (z-index),
/// checks both indices to be in range
/// </summary>
/// <param name="index1">index of the 1st element</param>
/// <param name="index2">index of the 2nd element</param>
private void SwapElements(int index1, int index2) {
if (index1 < 0 || index1 >= Count || index2 < 0 || index2 >= Count || index1 == index2) {
return;
}
var dc = this[index1];
this[index1] = this[index2];
this[index2] = dc;
Parent.Modified = true;
}
/// <summary>
/// Add items to a context menu for the selected item
/// </summary>
/// <param name="menu"></param>
/// <param name="surface"></param>
public virtual void AddContextMenuItems(ContextMenuStrip menu, ISurface surface) {
bool push = surface.Elements.CanPushDown(this);
bool pull = surface.Elements.CanPullUp(this);
ToolStripMenuItem item;
// Pull "up"
if (pull) {
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_uptotop));
item.Click += delegate {
surface.Elements.PullElementsToTop(this);
surface.Elements.Invalidate();
};
menu.Items.Add(item);
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_uponelevel));
item.Click += delegate {
surface.Elements.PullElementsUp(this);
surface.Elements.Invalidate();
};
menu.Items.Add(item);
}
// Push "down"
if (push) {
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_downtobottom));
item.Click += delegate {
surface.Elements.PushElementsToBottom(this);
surface.Elements.Invalidate();
};
menu.Items.Add(item);
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_downonelevel));
item.Click += delegate {
surface.Elements.PushElementsDown(this);
surface.Elements.Invalidate();
};
menu.Items.Add(item);
}
// Duplicate
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_duplicate));
item.Click += delegate {
IDrawableContainerList dcs = this.Clone();
dcs.Parent = surface;
dcs.MoveBy(10, 10);
surface.AddElements(dcs);
surface.DeselectAllElements();
surface.SelectElements(dcs);
};
menu.Items.Add(item);
// Copy
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_copytoclipboard))
{
Image = (Image) EditorFormResources.GetObject("copyToolStripMenuItem.Image")
};
item.Click += delegate {
ClipboardHelper.SetClipboardData(typeof(IDrawableContainerList), this);
};
menu.Items.Add(item);
// Cut
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_cuttoclipboard))
{
Image = (Image) EditorFormResources.GetObject("btnCut.Image")
};
item.Click += delegate {
ClipboardHelper.SetClipboardData(typeof(IDrawableContainerList), this);
surface.RemoveElements(this);
};
menu.Items.Add(item);
// Delete
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_deleteelement))
{
Image = (Image)EditorFormResources.GetObject("removeObjectToolStripMenuItem.Image")
};
item.Click += delegate {
surface.RemoveElements(this);
};
menu.Items.Add(item);
// Reset
bool canReset = false;
foreach (var drawableContainer in this)
{
var container = (DrawableContainer)drawableContainer;
if (container.HasDefaultSize)
{
canReset = true;
}
}
if (canReset) {
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_resetsize));
//item.Image = ((System.Drawing.Image)(editorFormResources.GetObject("removeObjectToolStripMenuItem.Image")));
item.Click += delegate {
MakeBoundsChangeUndoable(false);
foreach (var drawableContainer in this) {
var container = (DrawableContainer) drawableContainer;
if (!container.HasDefaultSize) {
continue;
}
Size defaultSize = container.DefaultSize;
container.MakeBoundsChangeUndoable(false);
container.Width = defaultSize.Width;
container.Height = defaultSize.Height;
}
surface.Invalidate();
};
menu.Items.Add(item);
}
}
public virtual void ShowContextMenu(MouseEventArgs e, ISurface surface)
{
if (!(surface is Surface))
{
return;
}
bool hasMenu = false;
foreach (var drawableContainer in this) {
var container = (DrawableContainer) drawableContainer;
if (!container.HasContextMenu) {
continue;
}
hasMenu = true;
break;
}
if (hasMenu) {
ContextMenuStrip menu = new ContextMenuStrip();
AddContextMenuItems(menu, surface);
if (menu.Items.Count > 0) {
// TODO: cast should be somehow avoided
menu.Show((Surface)surface, e.Location);
while (true) {
if (menu.Visible) {
Application.DoEvents();
Thread.Sleep(100);
} else {
menu.Dispose();
break;
}
}
}
}
}
private bool _disposedValue; // To detect redundant calls
protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)
{
if (disposing)
{
foreach (var drawableContainer in this)
{
drawableContainer.Dispose();
}
}
_disposedValue = true;
}
}
// This code added to correctly implement the disposable pattern.
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing) above.
Dispose(true);
}
}
}

View file

@ -0,0 +1,148 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Drawing.Drawing2D;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of EllipseContainer.
/// </summary>
[Serializable()]
public class EllipseContainer : DrawableContainer {
public EllipseContainer(Surface parent) : base(parent) {
CreateDefaultAdorners();
}
protected override void InitializeFields() {
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
AddField(GetType(), FieldType.SHADOW, true);
}
public override void Draw(Graphics graphics, RenderMode renderMode) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
DrawEllipse(rect, graphics, renderMode, lineThickness, lineColor, fillColor, shadow);
}
/// <summary>
/// This allows another container to draw an ellipse
/// </summary>
/// <param name="rect"></param>
/// <param name="graphics"></param>
/// <param name="renderMode"></param>
/// <param name="lineThickness"></param>
/// <param name="lineColor"></param>
/// <param name="fillColor"></param>
/// <param name="shadow"></param>
public static void DrawEllipse(Rectangle rect, Graphics graphics, RenderMode renderMode, int lineThickness, Color lineColor, Color fillColor, bool shadow) {
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
// draw shadow before anything else
if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps)
{
using Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))
{
Width = lineVisible ? lineThickness : 1
};
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(rect.Left + currentStep, rect.Top + currentStep, rect.Width, rect.Height);
graphics.DrawEllipse(shadowPen, shadowRect);
currentStep++;
alpha -= basealpha / steps;
}
}
//draw the original shape
if (Colors.IsVisible(fillColor))
{
using Brush brush = new SolidBrush(fillColor);
graphics.FillEllipse(brush, rect);
}
if (lineVisible)
{
using Pen pen = new Pen(lineColor, lineThickness);
graphics.DrawEllipse(pen, rect);
}
}
public override bool Contains(int x, int y) {
return EllipseContains(this, x, y);
}
/// <summary>
/// Allow the code to be used externally
/// </summary>
/// <param name="caller"></param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns></returns>
public static bool EllipseContains(DrawableContainer caller, int x, int y) {
double xDistanceFromCenter = x - (caller.Left + caller.Width / 2);
double yDistanceFromCenter = y - (caller.Top + caller.Height / 2);
// ellipse: x^2/a^2 + y^2/b^2 = 1
return Math.Pow(xDistanceFromCenter, 2) / Math.Pow(caller.Width / 2, 2) + Math.Pow(yDistanceFromCenter, 2) / Math.Pow(caller.Height / 2, 2) < 1;
}
public override bool ClickableAt(int x, int y) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) + 10;
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
return EllipseClickableAt(rect, lineThickness, fillColor, x, y);
}
public static bool EllipseClickableAt(Rectangle rect, int lineThickness, Color fillColor, int x, int y) {
// If we clicked inside the rectangle and it's visible we are clickable at.
if (!Color.Transparent.Equals(fillColor)) {
if (rect.Contains(x, y)) {
return true;
}
}
// check the rest of the lines
if (lineThickness > 0)
{
using Pen pen = new Pen(Color.White, lineThickness);
using GraphicsPath path = new GraphicsPath();
path.AddEllipse(rect);
return path.IsOutlineVisible(x, y, pen);
}
return false;
}
}
}

View file

@ -0,0 +1,200 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.Serialization;
using Greenshot.Configuration;
using GreenshotPlugin.IniFile;
using log4net;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Fields
{
/// <summary>
/// Basic IFieldHolder implementation, providing access to a set of fields
/// </summary>
[Serializable]
public abstract class AbstractFieldHolder : IFieldHolder
{
private static readonly ILog LOG = LogManager.GetLogger(typeof(AbstractFieldHolder));
private static readonly EditorConfiguration EditorConfig = IniConfig.GetIniSection<EditorConfiguration>();
[NonSerialized]
private readonly IDictionary<IField, PropertyChangedEventHandler> _handlers = new Dictionary<IField, PropertyChangedEventHandler>();
/// <summary>
/// called when a field's value has changed
/// </summary>
[NonSerialized]
private FieldChangedEventHandler _fieldChanged;
public event FieldChangedEventHandler FieldChanged
{
add { _fieldChanged += value; }
remove { _fieldChanged -= value; }
}
// we keep two Collections of our fields, dictionary for quick access, list for serialization
// this allows us to use default serialization
[NonSerialized]
private IDictionary<IFieldType, IField> _fieldsByType = new Dictionary<IFieldType, IField>();
private readonly IList<IField> fields = new List<IField>();
[OnDeserialized]
private void OnDeserialized(StreamingContext context)
{
_fieldsByType = new Dictionary<IFieldType, IField>();
// listen to changing properties
foreach (var field in fields)
{
field.PropertyChanged += delegate {
_fieldChanged?.Invoke(this, new FieldChangedEventArgs(field));
};
_fieldsByType[field.FieldType] = field;
}
}
public void AddField(Type requestingType, IFieldType fieldType, object fieldValue)
{
AddField(EditorConfig.CreateField(requestingType, fieldType, fieldValue));
}
public virtual void AddField(IField field)
{
fields.Add(field);
if (_fieldsByType == null)
{
return;
}
if (_fieldsByType.ContainsKey(field.FieldType))
{
if (LOG.IsDebugEnabled)
{
LOG.DebugFormat("A field with of type '{0}' already exists in this {1}, will overwrite.", field.FieldType, GetType());
}
}
_fieldsByType[field.FieldType] = field;
_handlers[field] = (sender, args) =>
{
_fieldChanged?.Invoke(this, new FieldChangedEventArgs(field));
};
field.PropertyChanged += _handlers[field];
}
public void RemoveField(IField field)
{
fields.Remove(field);
_fieldsByType.Remove(field.FieldType);
field.PropertyChanged -= _handlers[field];
_handlers.Remove(field);
}
public IList<IField> GetFields()
{
return fields;
}
public IField GetField(IFieldType fieldType)
{
try
{
return _fieldsByType[fieldType];
}
catch (KeyNotFoundException e)
{
throw new ArgumentException("Field '" + fieldType + "' does not exist in " + GetType(), e);
}
}
public object GetFieldValue(IFieldType fieldType)
{
return GetField(fieldType)?.Value;
}
public string GetFieldValueAsString(IFieldType fieldType)
{
return Convert.ToString(GetFieldValue(fieldType));
}
public int GetFieldValueAsInt(IFieldType fieldType)
{
return Convert.ToInt32(GetFieldValue(fieldType));
}
public decimal GetFieldValueAsDecimal(IFieldType fieldType)
{
return Convert.ToDecimal(GetFieldValue(fieldType));
}
public double GetFieldValueAsDouble(IFieldType fieldType)
{
return Convert.ToDouble(GetFieldValue(fieldType));
}
public float GetFieldValueAsFloat(IFieldType fieldType)
{
return Convert.ToSingle(GetFieldValue(fieldType));
}
public bool GetFieldValueAsBool(IFieldType fieldType)
{
return Convert.ToBoolean(GetFieldValue(fieldType));
}
public Color GetFieldValueAsColor(IFieldType fieldType, Color defaultColor = default)
{
return (Color)(GetFieldValue(fieldType) ?? defaultColor);
}
public bool HasField(IFieldType fieldType)
{
return _fieldsByType.ContainsKey(fieldType);
}
public bool HasFieldValue(IFieldType fieldType)
{
return HasField(fieldType) && _fieldsByType[fieldType].HasValue;
}
public void SetFieldValue(IFieldType fieldType, object value)
{
try
{
_fieldsByType[fieldType].Value = value;
}
catch (KeyNotFoundException e)
{
throw new ArgumentException("Field '" + fieldType + "' does not exist in " + GetType(), e);
}
}
protected void OnFieldChanged(object sender, FieldChangedEventArgs e)
{
_fieldChanged?.Invoke(sender, e);
}
}
}

View file

@ -0,0 +1,146 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 GreenshotPlugin.Interfaces.Drawing;
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
namespace Greenshot.Drawing.Fields
{
/// <summary>
/// Basic IFieldHolderWithChildren implementation. Similar to IFieldHolder,
/// but has a List of IFieldHolder for children.
/// Field values are passed to and from children as well.
/// </summary>
[Serializable]
public abstract class AbstractFieldHolderWithChildren : AbstractFieldHolder
{
[NonSerialized]
private readonly FieldChangedEventHandler _fieldChangedEventHandler;
[NonSerialized]
private EventHandler childrenChanged;
public event EventHandler ChildrenChanged
{
add { childrenChanged += value; }
remove { childrenChanged -= value; }
}
public IList<IFieldHolder> Children = new List<IFieldHolder>();
public AbstractFieldHolderWithChildren()
{
_fieldChangedEventHandler = OnFieldChanged;
}
[OnDeserialized()]
private void OnDeserialized(StreamingContext context)
{
// listen to changing properties
foreach (IFieldHolder fieldHolder in Children)
{
fieldHolder.FieldChanged += _fieldChangedEventHandler;
}
childrenChanged?.Invoke(this, EventArgs.Empty);
}
public void AddChild(IFieldHolder fieldHolder)
{
Children.Add(fieldHolder);
fieldHolder.FieldChanged += _fieldChangedEventHandler;
childrenChanged?.Invoke(this, EventArgs.Empty);
}
public void RemoveChild(IFieldHolder fieldHolder)
{
Children.Remove(fieldHolder);
fieldHolder.FieldChanged -= _fieldChangedEventHandler;
childrenChanged?.Invoke(this, EventArgs.Empty);
}
public new IList<IField> GetFields()
{
var ret = new List<IField>();
ret.AddRange(base.GetFields());
foreach (IFieldHolder fh in Children)
{
ret.AddRange(fh.GetFields());
}
return ret;
}
public new IField GetField(IFieldType fieldType)
{
IField ret = null;
if (base.HasField(fieldType))
{
ret = base.GetField(fieldType);
}
else
{
foreach (IFieldHolder fh in Children)
{
if (fh.HasField(fieldType))
{
ret = fh.GetField(fieldType);
break;
}
}
}
if (ret == null)
{
throw new ArgumentException("Field '" + fieldType + "' does not exist in " + GetType());
}
return ret;
}
public new bool HasField(IFieldType fieldType)
{
bool ret = base.HasField(fieldType);
if (!ret)
{
foreach (IFieldHolder fh in Children)
{
if (fh.HasField(fieldType))
{
ret = true;
break;
}
}
}
return ret;
}
public new bool HasFieldValue(IFieldType fieldType)
{
IField f = GetField(fieldType);
return f != null && f.HasValue;
}
public new void SetFieldValue(IFieldType fieldType, object value)
{
IField f = GetField(fieldType);
if (f != null) f.Value = value;
}
}
}

View file

@ -0,0 +1,46 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Basic IBindingConverter implementation
/// </summary>
public abstract class AbstractBindingConverter<T1,T2> : IBindingConverter
{
public object convert(object o) {
if(o == null) {
return null;
}
if(o is T1) {
return convert((T1)o);
}
if(o is T2) {
return convert((T2)o);
}
throw new ArgumentException("Cannot handle argument of type "+o.GetType());
}
protected abstract T2 convert(T1 o);
protected abstract T1 convert(T2 o);
}
}

View file

@ -0,0 +1,158 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Reflection;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Bidirectional binding of properties of two INotifyPropertyChanged instances.
/// This implementation synchronizes null values, too. If you do not want this
/// behavior (e.g. when binding to a
/// </summary>
public class BidirectionalBinding {
private readonly INotifyPropertyChanged _controlObject;
private readonly INotifyPropertyChanged _fieldObject;
private readonly string _controlPropertyName;
private readonly string _fieldPropertyName;
private bool _updatingControl;
private bool _updatingField;
private IBindingConverter _converter;
private readonly IBindingValidator _validator;
/// <summary>
/// Whether or not null values are passed on to the other object.
/// </summary>
protected bool AllowSynchronizeNull = true;
/// <summary>
/// Bind properties of two objects bidirectionally
/// </summary>
/// <param name="controlObject">Object containing 1st property to bind</param>
/// <param name="controlPropertyName">Property of 1st object to bind</param>
/// <param name="fieldObject">Object containing 2nd property to bind</param>
/// <param name="fieldPropertyName">Property of 2nd object to bind</param>
public BidirectionalBinding(INotifyPropertyChanged controlObject, string controlPropertyName, INotifyPropertyChanged fieldObject, string fieldPropertyName) {
_controlObject = controlObject;
_fieldObject = fieldObject;
_controlPropertyName = controlPropertyName;
_fieldPropertyName = fieldPropertyName;
_controlObject.PropertyChanged += ControlPropertyChanged;
_fieldObject.PropertyChanged += FieldPropertyChanged;
}
/// <summary>
/// Bind properties of two objects bidirectionally, converting the values using a converter
/// </summary>
/// <param name="controlObject">Object containing 1st property to bind</param>
/// <param name="controlPropertyName">Property of 1st object to bind</param>
/// <param name="fieldObject">Object containing 2nd property to bind</param>
/// <param name="fieldPropertyName">Property of 2nd object to bind</param>
/// <param name="converter">taking care of converting the synchronized value to the correct target format and back</param>
public BidirectionalBinding(INotifyPropertyChanged controlObject, string controlPropertyName, INotifyPropertyChanged fieldObject, string fieldPropertyName, IBindingConverter converter) : this(controlObject, controlPropertyName, fieldObject, fieldPropertyName) {
_converter = converter;
}
/// <summary>
/// Bind properties of two objects bidirectionally, converting the values using a converter.
/// Synchronization can be intercepted by adding a validator.
/// </summary>
/// <param name="controlObject">Object containing 1st property to bind</param>
/// <param name="controlPropertyName">Property of 1st object to bind</param>
/// <param name="fieldObject">Object containing 2nd property to bind</param>
/// <param name="fieldPropertyName">Property of 2nd object to bind</param>
/// <param name="validator">validator to intercept synchronization if the value does not match certain criteria</param>
public BidirectionalBinding(INotifyPropertyChanged controlObject, string controlPropertyName, INotifyPropertyChanged fieldObject, string fieldPropertyName, IBindingValidator validator) : this(controlObject, controlPropertyName, fieldObject, fieldPropertyName) {
_validator = validator;
}
/// <summary>
/// Bind properties of two objects bidirectionally, converting the values using a converter.
/// Synchronization can be intercepted by adding a validator.
/// </summary>
/// <param name="controlObject">Object containing 1st property to bind</param>
/// <param name="controlPropertyName">Property of 1st object to bind</param>
/// <param name="fieldObject">Object containing 2nd property to bind</param>
/// <param name="fieldPropertyName">Property of 2nd object to bind</param>
/// <param name="converter">taking care of converting the synchronized value to the correct target format and back</param>
/// <param name="validator">validator to intercept synchronization if the value does not match certain criteria</param>
public BidirectionalBinding(INotifyPropertyChanged controlObject, string controlPropertyName, INotifyPropertyChanged fieldObject, string fieldPropertyName, IBindingConverter converter, IBindingValidator validator) : this(controlObject, controlPropertyName, fieldObject, fieldPropertyName, converter) {
_validator = validator;
}
public void ControlPropertyChanged(object sender, PropertyChangedEventArgs e) {
if (!_updatingControl && e.PropertyName.Equals(_controlPropertyName)) {
_updatingField = true;
Synchronize(_controlObject, _controlPropertyName, _fieldObject, _fieldPropertyName);
_updatingField = false;
}
}
public void FieldPropertyChanged(object sender, PropertyChangedEventArgs e) {
if (!_updatingField && e.PropertyName.Equals(_fieldPropertyName)) {
_updatingControl = true;
Synchronize(_fieldObject, _fieldPropertyName, _controlObject, _controlPropertyName);
_updatingControl = false;
}
}
private void Synchronize(INotifyPropertyChanged sourceObject, string sourceProperty, INotifyPropertyChanged targetObject, string targetProperty) {
PropertyInfo targetPropertyInfo = ResolvePropertyInfo(targetObject, targetProperty);
PropertyInfo sourcePropertyInfo = ResolvePropertyInfo(sourceObject, sourceProperty);
if (sourcePropertyInfo != null && targetPropertyInfo != null && targetPropertyInfo.CanWrite) {
object bValue = sourcePropertyInfo.GetValue(sourceObject, null);
if (_converter != null && bValue != null) {
bValue = _converter.convert(bValue);
}
try {
if (_validator == null || _validator.validate(bValue)) {
targetPropertyInfo.SetValue(targetObject, bValue, null);
}
} catch (Exception e) {
throw new MemberAccessException("Could not set property '"+targetProperty+"' to '"+bValue+"' ["+(bValue?.GetType().Name ?? string.Empty)+"] on "+targetObject+". Probably other type than expected, IBindingCoverter to the rescue.", e);
}
}
}
private static PropertyInfo ResolvePropertyInfo(object obj, string property) {
PropertyInfo ret = null;
string[] properties = property.Split(".".ToCharArray());
for(int i=0; i<properties.Length; i++) {
string prop = properties[i];
ret = obj.GetType().GetProperty(prop);
if(ret != null && ret.CanRead && i<prop.Length-1) {
obj = ret.GetValue(obj, null);
}
}
return ret;
}
public IBindingConverter Converter {
get { return _converter; }
set { _converter = value; }
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Converts decimal to double (%) and vice versa, e.g. 95f to 0.95d
/// </summary>
public class DecimalDoublePercentageConverter : AbstractBindingConverter<double, decimal>
{
private static DecimalDoublePercentageConverter _uniqueInstance;
private DecimalDoublePercentageConverter() {}
protected override decimal convert(double o) {
return Convert.ToDecimal(o)*100;
}
protected override double convert(decimal o) {
return Convert.ToDouble(o)/100;
}
public static DecimalDoublePercentageConverter GetInstance()
{
return _uniqueInstance ??= new DecimalDoublePercentageConverter();
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Converts decimal to float and vice versa.
/// </summary>
public class DecimalFloatConverter : AbstractBindingConverter<float, decimal>
{
private static DecimalFloatConverter _uniqueInstance;
private DecimalFloatConverter() {}
protected override decimal convert(float o) {
return Convert.ToDecimal(o);
}
protected override float convert(decimal o) {
return Convert.ToInt16(o);
}
public static DecimalFloatConverter GetInstance()
{
return _uniqueInstance ??= new DecimalFloatConverter();
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Converts decimal to int and vice versa.
/// </summary>
public class DecimalIntConverter : AbstractBindingConverter<int, decimal>
{
private static DecimalIntConverter _uniqueInstance;
private DecimalIntConverter() {}
protected override decimal convert(int o) {
return Convert.ToDecimal(o);
}
protected override int convert(decimal o) {
return Convert.ToInt16(o);
}
public static DecimalIntConverter GetInstance()
{
return _uniqueInstance ??= new DecimalIntConverter();
}
}
}

View file

@ -0,0 +1,33 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Interface for a bidirectional converter, for use with BidirectionalBinding.
/// convert(object) implementation must deal with both directions.
/// see DecimalIntConverter
/// </summary>
public interface IBindingConverter {
object convert(object o);
}
}

View file

@ -0,0 +1,34 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Interface for a bidirectional validator, for use with BidirectionalBinding.
/// Useful if you do not want to synchronize values which would be illegal on
/// one of the bound objects (e.g. null value on some form components)
/// see NotNullValidator
/// </summary>
public interface IBindingValidator {
bool validate(object o);
}
}

View file

@ -0,0 +1,41 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Validates a value not to be null.
/// </summary>
public class NotNullValidator : IBindingValidator {
private static NotNullValidator _uniqueInstance;
private NotNullValidator() {
}
public bool validate(object o) {
return o != null;
}
public static NotNullValidator GetInstance()
{
return _uniqueInstance ??= new NotNullValidator();
}
}
}

View file

@ -0,0 +1,130 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 GreenshotPlugin.Interfaces.Drawing;
using System;
using System.ComponentModel;
namespace Greenshot.Drawing.Fields
{
/// <summary>
/// Represents a single field of a drawable element, i.e.
/// line thickness of a rectangle.
/// </summary>
[Serializable]
public class Field : IField
{
[field: NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;
private object _myValue;
public object Value
{
get
{
return _myValue;
}
set
{
if (!Equals(_myValue, value))
{
_myValue = value;
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Value"));
}
}
}
public IFieldType FieldType
{
get;
set;
}
public string Scope
{
get;
set;
}
/// <summary>
/// Constructs a new Field instance, usually you should be using FieldFactory
/// to create Fields.
/// </summary>
/// <param name="fieldType">FieldType of the Field to be created</param>
/// <param name="scope">The scope to which the value of this Field is relevant.
/// Depending on the scope the Field's value may be shared for other elements
/// containing the same FieldType for defaulting to the last used value.
/// When scope is set to a Type (e.g. typeof(RectangleContainer)), its value
/// should not be reused for FieldHolders of another Type (e.g. typeof(EllipseContainer))
/// </param>
public Field(IFieldType fieldType, Type scope)
{
FieldType = fieldType;
Scope = scope.Name;
}
public Field(IFieldType fieldType, string scope)
{
FieldType = fieldType;
Scope = scope;
}
public Field(IFieldType fieldType)
{
FieldType = fieldType;
}
/// <summary>
/// Returns true if this field holds a value other than null.
/// </summary>
public bool HasValue => Value != null;
/// <summary>
/// Creates a flat clone of this Field. The fields value itself is not cloned.
/// </summary>
/// <returns></returns>
public Field Clone()
{
return new Field(FieldType, Scope) {Value = Value};
}
public override int GetHashCode()
{
int hashCode = 0;
unchecked
{
hashCode += 1000000009 * FieldType.GetHashCode();
if (Scope != null)
hashCode += 1000000021 * Scope.GetHashCode();
}
return hashCode;
}
public override bool Equals(object obj)
{
if (!(obj is Field other))
{
return false;
}
return FieldType == other.FieldType && Equals(Scope, other.Scope);
}
public override string ToString()
{
return string.Format("[Field FieldType={1} Value={0} Scope={2}]", _myValue, FieldType, Scope);
}
}
}

View file

@ -0,0 +1,218 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using Greenshot.Configuration;
using GreenshotPlugin.Interfaces.Drawing;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using GreenshotPlugin.IniFile;
using GreenshotPlugin.Interfaces;
namespace Greenshot.Drawing.Fields
{
/// <summary>
/// Represents the current set of properties for the editor.
/// When one of EditorProperties' properties is updated, the change will be promoted
/// to all bound elements.
/// * If an element is selected:
/// This class represents the element's properties
/// * I n>1 elements are selected:
/// This class represents the properties of all elements.
/// Properties that do not apply for ALL selected elements are null (or 0 respectively)
/// If the property values of the selected elements differ, the value of the last bound element wins.
/// </summary>
[Serializable]
public sealed class FieldAggregator : AbstractFieldHolder
{
private readonly IDrawableContainerList _boundContainers;
private bool _internalUpdateRunning;
private static readonly EditorConfiguration EditorConfig = IniConfig.GetIniSection<EditorConfiguration>();
public FieldAggregator(ISurface parent)
{
foreach (var fieldType in FieldType.Values)
{
var field = new Field(fieldType, GetType());
AddField(field);
}
_boundContainers = new DrawableContainerList
{
Parent = parent
};
}
public override void AddField(IField field)
{
base.AddField(field);
field.PropertyChanged += OwnPropertyChanged;
}
public void BindElements(IDrawableContainerList dcs)
{
foreach (var dc in dcs)
{
BindElement(dc);
}
}
public void BindElement(IDrawableContainer dc)
{
if (!(dc is DrawableContainer container) || _boundContainers.Contains(container))
{
return;
}
_boundContainers.Add(container);
container.ChildrenChanged += delegate {
UpdateFromBoundElements();
};
UpdateFromBoundElements();
}
public void BindAndUpdateElement(IDrawableContainer dc)
{
UpdateElement(dc);
BindElement(dc);
}
public void UpdateElement(IDrawableContainer dc)
{
if (!(dc is DrawableContainer container))
{
return;
}
_internalUpdateRunning = true;
foreach (var field in GetFields())
{
if (container.HasField(field.FieldType) && field.HasValue)
{
//if(LOG.IsDebugEnabled) LOG.Debug(" "+field+ ": "+field.Value);
container.SetFieldValue(field.FieldType, field.Value);
}
}
_internalUpdateRunning = false;
}
public void UnbindElement(IDrawableContainer dc)
{
if (_boundContainers.Contains(dc))
{
_boundContainers.Remove(dc);
UpdateFromBoundElements();
}
}
public void Clear()
{
ClearFields();
_boundContainers.Clear();
UpdateFromBoundElements();
}
/// <summary>
/// sets all field values to null, however does not remove fields
/// </summary>
private void ClearFields()
{
_internalUpdateRunning = true;
foreach (var field in GetFields())
{
field.Value = null;
}
_internalUpdateRunning = false;
}
/// <summary>
/// Updates this instance using the respective fields from the bound elements.
/// Fields that do not apply to every bound element are set to null, or 0 respectively.
/// All other fields will be set to the field value of the least bound element.
/// </summary>
private void UpdateFromBoundElements()
{
ClearFields();
_internalUpdateRunning = true;
foreach (var field in FindCommonFields())
{
SetFieldValue(field.FieldType, field.Value);
}
_internalUpdateRunning = false;
}
private IList<IField> FindCommonFields()
{
IList<IField> returnFields = null;
if (_boundContainers.Count > 0)
{
// take all fields from the least selected container...
if (_boundContainers[_boundContainers.Count - 1] is DrawableContainer leastSelectedContainer)
{
returnFields = leastSelectedContainer.GetFields();
for (int i = 0; i < _boundContainers.Count - 1; i++)
{
if (!(_boundContainers[i] is DrawableContainer dc)) continue;
IList<IField> fieldsToRemove = new List<IField>();
foreach (IField field in returnFields)
{
// ... throw out those that do not apply to one of the other containers
if (!dc.HasField(field.FieldType))
{
fieldsToRemove.Add(field);
}
}
foreach (var field in fieldsToRemove)
{
returnFields.Remove(field);
}
}
}
}
return returnFields ?? new List<IField>();
}
public void OwnPropertyChanged(object sender, PropertyChangedEventArgs ea)
{
IField field = (IField)sender;
if (_internalUpdateRunning || field.Value == null)
{
return;
}
foreach (var drawableContainer1 in _boundContainers.ToList())
{
var drawableContainer = (DrawableContainer) drawableContainer1;
if (!drawableContainer.HasField(field.FieldType))
{
continue;
}
IField drawableContainerField = drawableContainer.GetField(field.FieldType);
// Notify before change, so we can e.g. invalidate the area
drawableContainer.BeforeFieldChange(drawableContainerField, field.Value);
drawableContainerField.Value = field.Value;
// update last used from DC field, so that scope is honored
EditorConfig.UpdateLastFieldValue(drawableContainerField);
}
}
}
}

View file

@ -0,0 +1,123 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 GreenshotPlugin.Interfaces.Drawing;
using System;
namespace Greenshot.Drawing.Fields
{
/// <summary>
/// Defines all FieldTypes + their default value.
/// (The additional value is why this is not an enum)
/// </summary>
[Serializable]
public class FieldType : IFieldType
{
public static readonly IFieldType ARROWHEADS = new FieldType("ARROWHEADS");
public static readonly IFieldType BLUR_RADIUS = new FieldType("BLUR_RADIUS");
public static readonly IFieldType BRIGHTNESS = new FieldType("BRIGHTNESS");
public static readonly IFieldType FILL_COLOR = new FieldType("FILL_COLOR");
public static readonly IFieldType FONT_BOLD = new FieldType("FONT_BOLD");
public static readonly IFieldType FONT_FAMILY = new FieldType("FONT_FAMILY");
public static readonly IFieldType FONT_ITALIC = new FieldType("FONT_ITALIC");
public static readonly IFieldType FONT_SIZE = new FieldType("FONT_SIZE");
public static readonly IFieldType TEXT_HORIZONTAL_ALIGNMENT = new FieldType("TEXT_HORIZONTAL_ALIGNMENT");
public static readonly IFieldType TEXT_VERTICAL_ALIGNMENT = new FieldType("TEXT_VERTICAL_ALIGNMENT");
public static readonly IFieldType HIGHLIGHT_COLOR = new FieldType("HIGHLIGHT_COLOR");
public static readonly IFieldType LINE_COLOR = new FieldType("LINE_COLOR");
public static readonly IFieldType LINE_THICKNESS = new FieldType("LINE_THICKNESS");
public static readonly IFieldType MAGNIFICATION_FACTOR = new FieldType("MAGNIFICATION_FACTOR");
public static readonly IFieldType PIXEL_SIZE = new FieldType("PIXEL_SIZE");
public static readonly IFieldType PREVIEW_QUALITY = new FieldType("PREVIEW_QUALITY");
public static readonly IFieldType SHADOW = new FieldType("SHADOW");
public static readonly IFieldType PREPARED_FILTER_OBFUSCATE = new FieldType("PREPARED_FILTER_OBFUSCATE");
public static readonly IFieldType PREPARED_FILTER_HIGHLIGHT = new FieldType("PREPARED_FILTER_HIGHLIGHT");
public static readonly IFieldType FLAGS = new FieldType("FLAGS");
public static IFieldType[] Values = {
ARROWHEADS,
BLUR_RADIUS,
BRIGHTNESS,
FILL_COLOR,
FONT_BOLD,
FONT_FAMILY,
FONT_ITALIC,
FONT_SIZE,
TEXT_HORIZONTAL_ALIGNMENT,
TEXT_VERTICAL_ALIGNMENT,
HIGHLIGHT_COLOR,
LINE_COLOR,
LINE_THICKNESS,
MAGNIFICATION_FACTOR,
PIXEL_SIZE,
PREVIEW_QUALITY,
SHADOW,
PREPARED_FILTER_OBFUSCATE,
PREPARED_FILTER_HIGHLIGHT,
FLAGS
};
public string Name
{
get;
set;
}
private FieldType(string name)
{
Name = name;
}
public override string ToString()
{
return Name;
}
public override int GetHashCode()
{
int hashCode = 0;
unchecked
{
if (Name != null)
hashCode += 1000000009 * Name.GetHashCode();
}
return hashCode;
}
public override bool Equals(object obj)
{
FieldType other = obj as FieldType;
if (other == null)
{
return false;
}
return Equals(Name, other.Name);
}
public static bool operator ==(FieldType a, FieldType b)
{
return Equals(a, b);
}
public static bool operator !=(FieldType a, FieldType b)
{
return !Equals(a, b);
}
}
}

View file

@ -0,0 +1,98 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using System.Drawing.Drawing2D;
using System.Runtime.Serialization;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// empty container for filter-only elements
/// </summary>
[Serializable()]
public abstract class FilterContainer : DrawableContainer {
public enum PreparedFilterMode {OBFUSCATE, HIGHLIGHT};
public enum PreparedFilter {BLUR, PIXELIZE, TEXT_HIGHTLIGHT, AREA_HIGHLIGHT, GRAYSCALE, MAGNIFICATION};
public PreparedFilter Filter {
get { return (PreparedFilter)GetFieldValue(FieldType.PREPARED_FILTER_HIGHLIGHT); }
}
public FilterContainer(Surface parent) : base(parent) {
Init();
}
protected override void OnDeserialized(StreamingContext streamingContext)
{
base.OnDeserialized(streamingContext);
Init();
}
private void Init()
{
CreateDefaultAdorners();
}
protected override void InitializeFields() {
AddField(GetType(), FieldType.LINE_THICKNESS, 0);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.SHADOW, false);
}
public override void Draw(Graphics graphics, RenderMode rm) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
if (lineVisible) {
graphics.SmoothingMode = SmoothingMode.HighSpeed;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
//draw shadow first
if (shadow) {
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps)
{
using Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness);
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + currentStep, Top + currentStep, Width, Height);
graphics.DrawRectangle(shadowPen, shadowRect);
currentStep++;
alpha -= basealpha / steps;
}
}
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
if (lineThickness > 0)
{
using Pen pen = new Pen(lineColor, lineThickness);
graphics.DrawRectangle(pen, rect);
}
}
}
}
}

View file

@ -0,0 +1,80 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.ComponentModel;
using System.Drawing;
using Greenshot.Drawing.Fields;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Filters {
/// <summary>
/// Graphical filter which can be added to DrawableContainer.
/// Subclasses should fulfill INotifyPropertyChanged contract, i.e. call
/// OnPropertyChanged whenever a public property has been changed.
/// </summary>
[Serializable]
public abstract class AbstractFilter : AbstractFieldHolder, IFilter {
[NonSerialized]
private PropertyChangedEventHandler propertyChanged;
public event PropertyChangedEventHandler PropertyChanged {
add { propertyChanged += value; }
remove{ propertyChanged -= value; }
}
private bool invert;
public bool Invert {
get {
return invert;
}
set {
invert = value;
OnPropertyChanged("Invert");
}
}
protected DrawableContainer parent;
public DrawableContainer Parent {
get {
return parent;
}
set {
parent = value;
}
}
public AbstractFilter(DrawableContainer parent) {
this.parent = parent;
}
public DrawableContainer GetParent() {
return parent;
}
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode);
protected void OnPropertyChanged(string propertyName)
{
propertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View file

@ -0,0 +1,66 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using Greenshot.Drawing.Fields;
using GreenshotPlugin.Core;
using GreenshotPlugin.UnmanagedHelpers;
using System.Drawing.Drawing2D;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable]
public class BlurFilter : AbstractFilter {
public double previewQuality;
public double PreviewQuality {
get { return previewQuality; }
set { previewQuality = value; OnPropertyChanged("PreviewQuality"); }
}
public BlurFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.BLUR_RADIUS, 3);
AddField(GetType(), FieldType.PREVIEW_QUALITY, 1.0d);
}
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0) {
return;
}
GraphicsState state = graphics.Save();
if (Invert) {
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
if (GDIplus.IsBlurPossible(blurRadius)) {
GDIplus.DrawWithBlur(graphics, applyBitmap, applyRect, null, null, blurRadius, false);
} else
{
using IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect);
ImageHelper.ApplyBoxBlur(fastBitmap, blurRadius);
fastBitmap.DrawTo(graphics, applyRect);
}
graphics.Restore(state);
}
}
}

View file

@ -0,0 +1,64 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using Greenshot.Drawing.Fields;
using GreenshotPlugin.Core;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class BrightnessFilter : AbstractFilter {
public BrightnessFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.BRIGHTNESS, 0.9d);
}
/// <summary>
/// Implements the Apply code for the Brightness Filet
/// </summary>
/// <param name="graphics"></param>
/// <param name="applyBitmap"></param>
/// <param name="rect"></param>
/// <param name="renderMode"></param>
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0) {
// nothing to do
return;
}
GraphicsState state = graphics.Save();
if (Invert) {
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
float brightness = GetFieldValueAsFloat(FieldType.BRIGHTNESS);
using (ImageAttributes ia = ImageHelper.CreateAdjustAttributes(brightness, 1f, 1f)) {
graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia);
}
graphics.Restore(state);
}
}
}

View file

@ -0,0 +1,64 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using GreenshotPlugin.Core;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Filters {
/// <summary>
/// Description of GrayscaleFilter.
/// </summary>
[Serializable()]
public class GrayscaleFilter : AbstractFilter {
public GrayscaleFilter(DrawableContainer parent) : base(parent) {
}
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0) {
// nothing to do
return;
}
GraphicsState state = graphics.Save();
if (Invert) {
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
ColorMatrix grayscaleMatrix = new ColorMatrix(new[] {
new[] {.3f, .3f, .3f, 0, 0},
new[] {.59f, .59f, .59f, 0, 0},
new[] {.11f, .11f, .11f, 0, 0},
new float[] {0, 0, 0, 1, 0},
new float[] {0, 0, 0, 0, 1}
});
using (ImageAttributes ia = new ImageAttributes()) {
ia.SetColorMatrix(grayscaleMatrix);
graphics.DrawImage(applyBitmap, applyRect, applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height, GraphicsUnit.Pixel, ia);
}
graphics.Restore(state);
}
}
}

View file

@ -0,0 +1,68 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using Greenshot.Drawing.Fields;
using GreenshotPlugin.Core;
using System.Drawing.Drawing2D;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class HighlightFilter : AbstractFilter {
public HighlightFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.FILL_COLOR, Color.Yellow);
}
/// <summary>
/// Implements the Apply code for the Brightness Filet
/// </summary>
/// <param name="graphics"></param>
/// <param name="applyBitmap"></param>
/// <param name="rect"></param>
/// <param name="renderMode"></param>
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0) {
// nothing to do
return;
}
GraphicsState state = graphics.Save();
if (Invert) {
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
using (IFastBitmap fastBitmap = FastBitmap.CreateCloneOf(applyBitmap, applyRect)) {
Color highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
for (int y = fastBitmap.Top; y < fastBitmap.Bottom; y++) {
for (int x = fastBitmap.Left; x < fastBitmap.Right; x++) {
Color color = fastBitmap.GetColorAt(x, y);
color = Color.FromArgb(color.A, Math.Min(highlightColor.R, color.R), Math.Min(highlightColor.G, color.G), Math.Min(highlightColor.B, color.B));
fastBitmap.SetColorAt(x, y, color);
}
}
fastBitmap.DrawTo(graphics, applyRect.Location);
}
graphics.Restore(state);
}
}
}

View file

@ -0,0 +1,34 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System.ComponentModel;
using System.Drawing;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Filters
{
public interface IFilter : INotifyPropertyChanged, IFieldHolder {
DrawableContainer Parent {get; set; }
void Apply(Graphics graphics, Bitmap bmp, Rectangle rect, RenderMode renderMode);
DrawableContainer GetParent();
bool Invert {get; set;}
}
}

View file

@ -0,0 +1,61 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using Greenshot.Drawing.Fields;
using GreenshotPlugin.Core;
using System.Drawing.Drawing2D;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable]
public class MagnifierFilter : AbstractFilter {
public MagnifierFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.MAGNIFICATION_FACTOR, 2);
}
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (applyRect.Width == 0 || applyRect.Height == 0) {
// nothing to do
return;
}
int magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR);
GraphicsState state = graphics.Save();
if (Invert) {
graphics.SetClip(applyRect);
graphics.ExcludeClip(rect);
}
graphics.SmoothingMode = SmoothingMode.None;
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
int halfWidth = rect.Width / 2;
int halfHeight = rect.Height / 2;
int newWidth = rect.Width / magnificationFactor;
int newHeight = rect.Height / magnificationFactor;
Rectangle source = new Rectangle(rect.X + halfWidth - newWidth / 2, rect.Y + halfHeight - newHeight / 2, newWidth, newHeight);
graphics.DrawImage(applyBitmap, rect, source, GraphicsUnit.Pixel);
graphics.Restore(state);
}
}
}

View file

@ -1,109 +1,84 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using Dapplo.Windows.Common.Structs;
using Greenshot.Base.Core;
using Greenshot.Base.Interfaces.Drawing;
using Greenshot.Editor.Drawing.Fields;
using Greenshot.Editor.Helpers;
namespace Greenshot.Editor.Drawing.Filters
{
/// <summary>
/// Pixelate an area
/// </summary>
[Serializable()]
public class PixelizationFilter : AbstractFilter
{
public PixelizationFilter(DrawableContainer parent) : base(parent)
{
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
}
public override void Apply(Graphics graphics, Bitmap applyBitmap, NativeRect rect, RenderMode renderMode)
{
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (pixelSize <= 1 || rect.Width == 0 || rect.Height == 0)
{
// Nothing to do
return;
}
if (rect.Width < pixelSize)
{
pixelSize = rect.Width;
}
if (rect.Height < pixelSize)
{
pixelSize = rect.Height;
}
using IFastBitmap dest = FastBitmap.CreateCloneOf(applyBitmap, rect);
using (IFastBitmap src = FastBitmap.Create(applyBitmap, rect))
{
List<Color> colors = new List<Color>();
int halbPixelSize = pixelSize / 2;
for (int y = src.Top - halbPixelSize; y < src.Bottom + halbPixelSize; y += pixelSize)
{
for (int x = src.Left - halbPixelSize; x <= src.Right + halbPixelSize; x += pixelSize)
{
colors.Clear();
for (int yy = y; yy < y + pixelSize; yy++)
{
if (yy >= src.Top && yy < src.Bottom)
{
for (int xx = x; xx < x + pixelSize; xx++)
{
if (xx >= src.Left && xx < src.Right)
{
colors.Add(src.GetColorAt(xx, yy));
}
}
}
}
Color currentAvgColor = Colors.Mix(colors);
for (int yy = y; yy <= y + pixelSize; yy++)
{
if (yy >= src.Top && yy < src.Bottom)
{
for (int xx = x; xx <= x + pixelSize; xx++)
{
if (xx >= src.Left && xx < src.Right)
{
dest.SetColorAt(xx, yy, currentAvgColor);
}
}
}
}
}
}
}
dest.DrawTo(graphics, rect.Location);
}
}
}
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Collections.Generic;
using System.Drawing;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using GreenshotPlugin.Core;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class PixelizationFilter : AbstractFilter {
public PixelizationFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
}
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
if (pixelSize <= 1 || rect.Width == 0 || rect.Height == 0) {
// Nothing to do
return;
}
if (rect.Width < pixelSize) {
pixelSize = rect.Width;
}
if (rect.Height < pixelSize) {
pixelSize = rect.Height;
}
using IFastBitmap dest = FastBitmap.CreateCloneOf(applyBitmap, rect);
using (IFastBitmap src = FastBitmap.Create(applyBitmap, rect)) {
List<Color> colors = new List<Color>();
int halbPixelSize = pixelSize / 2;
for (int y = src.Top - halbPixelSize; y < src.Bottom + halbPixelSize; y += pixelSize) {
for (int x = src.Left - halbPixelSize; x <= src.Right + halbPixelSize; x += pixelSize) {
colors.Clear();
for (int yy = y; yy < y + pixelSize; yy++) {
if (yy >= src.Top && yy < src.Bottom) {
for (int xx = x; xx < x + pixelSize; xx++) {
if (xx >= src.Left && xx < src.Right) {
colors.Add(src.GetColorAt(xx, yy));
}
}
}
}
Color currentAvgColor = Colors.Mix(colors);
for (int yy = y; yy <= y + pixelSize; yy++) {
if (yy >= src.Top && yy < src.Bottom) {
for (int xx = x; xx <= x + pixelSize; xx++) {
if (xx >= src.Left && xx < src.Right) {
dest.SetColorAt(xx, yy, currentAvgColor);
}
}
}
}
}
}
}
dest.DrawTo(graphics, rect.Location);
}
}
}

View file

@ -0,0 +1,278 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Drawing.Fields;
using Greenshot.Helpers;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.Serialization;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of PathContainer.
/// </summary>
[Serializable]
public class FreehandContainer : DrawableContainer {
private static readonly float [] PointOffset = {0.5f, 0.25f, 0.75f};
[NonSerialized]
private GraphicsPath freehandPath = new GraphicsPath();
private Rectangle myBounds = Rectangle.Empty;
private Point lastMouse = Point.Empty;
private readonly List<Point> capturePoints = new List<Point>();
private bool isRecalculated;
/// <summary>
/// Constructor
/// </summary>
public FreehandContainer(Surface parent) : base(parent) {
Width = parent.Width;
Height = parent.Height;
Top = 0;
Left = 0;
}
protected override void InitializeFields() {
AddField(GetType(), FieldType.LINE_THICKNESS, 3);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
}
public override void Transform(Matrix matrix) {
Point[] points = capturePoints.ToArray();
matrix.TransformPoints(points);
capturePoints.Clear();
capturePoints.AddRange(points);
RecalculatePath();
}
protected override void OnDeserialized(StreamingContext context) {
RecalculatePath();
}
/// <summary>
/// This Dispose is called from the Dispose and the Destructor.
/// </summary>
/// <param name="disposing">When disposing==true all non-managed resources should be freed too!</param>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (disposing)
{
freehandPath?.Dispose();
}
freehandPath = null;
}
/// <summary>
/// Called from Surface (the parent) when the drawing begins (mouse-down)
/// </summary>
/// <returns>true if the surface doesn't need to handle the event</returns>
public override bool HandleMouseDown(int mouseX, int mouseY) {
lastMouse = new Point(mouseX, mouseY);
capturePoints.Add(lastMouse);
return true;
}
/// <summary>
/// Called from Surface (the parent) if a mouse move is made while drawing
/// </summary>
/// <returns>true if the surface doesn't need to handle the event</returns>
public override bool HandleMouseMove(int mouseX, int mouseY) {
Point previousPoint = capturePoints[capturePoints.Count-1];
if (GeometryHelper.Distance2D(previousPoint.X, previousPoint.Y, mouseX, mouseY) >= 2*EditorConfig.FreehandSensitivity) {
capturePoints.Add(new Point(mouseX, mouseY));
}
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) < EditorConfig.FreehandSensitivity)
{
return true;
}
//path.AddCurve(new Point[]{lastMouse, new Point(mouseX, mouseY)});
lastMouse = new Point(mouseX, mouseY);
freehandPath.AddLine(lastMouse, new Point(mouseX, mouseY));
// Only re-calculate the bounds & redraw when we added something to the path
myBounds = Rectangle.Round(freehandPath.GetBounds());
Invalidate();
return true;
}
/// <summary>
/// Called when the surface finishes drawing the element
/// </summary>
public override void HandleMouseUp(int mouseX, int mouseY) {
// Make sure we don't loose the ending point
if (GeometryHelper.Distance2D(lastMouse.X, lastMouse.Y, mouseX, mouseY) >= EditorConfig.FreehandSensitivity) {
capturePoints.Add(new Point(mouseX, mouseY));
}
RecalculatePath();
}
/// <summary>
/// Here we recalculate the freehand path by smoothing out the lines with Beziers.
/// </summary>
private void RecalculatePath() {
// Store the previous path, to dispose it later when we are finished
var previousFreehandPath = freehandPath;
var newFreehandPath = new GraphicsPath();
// Here we can put some cleanup... like losing all the uninteresting points.
if (capturePoints.Count >= 3)
{
int index = 0;
while ((capturePoints.Count - 1) % 3 != 0)
{
// duplicate points, first at 50% than 25% than 75%
capturePoints.Insert((int)(capturePoints.Count * PointOffset[index]), capturePoints[(int)(capturePoints.Count * PointOffset[index++])]);
}
newFreehandPath.AddBeziers(capturePoints.ToArray());
}
else if (capturePoints.Count == 2)
{
newFreehandPath.AddLine(capturePoints[0], capturePoints[1]);
}
// Recalculate the bounds
myBounds = Rectangle.Round(newFreehandPath.GetBounds());
// assign
isRecalculated = true;
freehandPath = newFreehandPath;
// dispose previous
previousFreehandPath?.Dispose();
}
/// <summary>
/// Do the drawing of the freehand "stroke"
/// </summary>
/// <param name="graphics"></param>
/// <param name="renderMode"></param>
public override void Draw(Graphics graphics, RenderMode renderMode) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
using var pen = new Pen(lineColor)
{
Width = lineThickness
};
if (!(pen.Width > 0))
{
return;
}
// Make sure the lines are nicely rounded
pen.EndCap = LineCap.Round;
pen.StartCap = LineCap.Round;
pen.LineJoin = LineJoin.Round;
// Move to where we need to draw
graphics.TranslateTransform(Left, Top);
var currentFreehandPath = freehandPath;
if (currentFreehandPath != null)
{
if (isRecalculated && Selected && renderMode == RenderMode.EDIT)
{
isRecalculated = false;
DrawSelectionBorder(graphics, pen, currentFreehandPath);
}
graphics.DrawPath(pen, currentFreehandPath);
}
// Move back, otherwise everything is shifted
graphics.TranslateTransform(-Left,-Top);
}
/// <summary>
/// Draw a selectionborder around the freehand path
/// </summary>
/// <param name="graphics">Graphics</param>
/// <param name="linePen">Pen</param>
/// <param name="path">GraphicsPath</param>
protected static void DrawSelectionBorder(Graphics graphics, Pen linePen, GraphicsPath path)
{
using var selectionPen = (Pen) linePen.Clone();
using var selectionPath = (GraphicsPath)path.Clone();
selectionPen.Width += 5;
selectionPen.Color = Color.FromArgb(120, Color.LightSeaGreen);
graphics.DrawPath(selectionPen, selectionPath);
selectionPath.Widen(selectionPen);
selectionPen.DashPattern = new float[]{2,2};
selectionPen.Color = Color.LightSeaGreen;
selectionPen.Width = 1;
graphics.DrawPath(selectionPen, selectionPath);
}
/// <summary>
/// Get the bounds in which we have something drawn, plus safety margin, these are not the normal bounds...
/// </summary>
public override Rectangle DrawingBounds {
get {
if (!myBounds.IsEmpty) {
int lineThickness = Math.Max(10, GetFieldValueAsInt(FieldType.LINE_THICKNESS));
int safetymargin = 10;
return new Rectangle(myBounds.Left + Left - (safetymargin+lineThickness), myBounds.Top + Top - (safetymargin+lineThickness), myBounds.Width + 2*(lineThickness+safetymargin), myBounds.Height + 2*(lineThickness+safetymargin));
}
return new Rectangle(0, 0, _parent?.Width??0, _parent?.Height?? 0);
}
}
/// <summary>
/// FreehandContainer are regarded equal if they are of the same type and their paths are equal.
/// </summary>
/// <param name="obj">object</param>
/// <returns>bool</returns>
public override bool Equals(object obj) {
bool ret = false;
if (obj == null || GetType() != obj.GetType())
{
return false;
}
if (obj is FreehandContainer other && Equals(freehandPath, other.freehandPath)) {
ret = true;
}
return ret;
}
public override int GetHashCode() {
return freehandPath?.GetHashCode() ?? 0;
}
public override bool ClickableAt(int x, int y) {
bool returnValue = base.ClickableAt(x, y);
if (returnValue) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
using var pen = new Pen(Color.White)
{
Width = lineThickness + 10
};
returnValue = freehandPath.IsOutlineVisible(x - Left, y - Top, pen);
}
return returnValue;
}
}
}

View file

@ -0,0 +1,99 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of ObfuscateContainer.
/// </summary>
[Serializable]
public class HighlightContainer : FilterContainer {
public HighlightContainer(Surface parent) : base(parent) {
Init();
}
/// <summary>
/// Use settings from base, extend with our own field
/// </summary>
protected override void InitializeFields() {
base.InitializeFields();
AddField(GetType(), FieldType.PREPARED_FILTER_HIGHLIGHT, PreparedFilter.TEXT_HIGHTLIGHT);
}
protected override void OnDeserialized(StreamingContext context)
{
Init();
}
private void Init() {
FieldChanged += HighlightContainer_OnFieldChanged;
ConfigurePreparedFilters();
}
protected void HighlightContainer_OnFieldChanged(object sender, FieldChangedEventArgs e) {
if (!sender.Equals(this)) {
return;
}
if (Equals(e.Field.FieldType, FieldType.PREPARED_FILTER_HIGHLIGHT)) {
ConfigurePreparedFilters();
}
}
private void ConfigurePreparedFilters() {
PreparedFilter preset = (PreparedFilter)GetFieldValue(FieldType.PREPARED_FILTER_HIGHLIGHT);
while(Filters.Count>0) {
Remove(Filters[0]);
}
switch(preset) {
case PreparedFilter.TEXT_HIGHTLIGHT:
Add(new HighlightFilter(this));
break;
case PreparedFilter.AREA_HIGHLIGHT:
var brightnessFilter = new BrightnessFilter(this)
{
Invert = true
};
Add(brightnessFilter);
var blurFilter = new BlurFilter(this)
{
Invert = true
};
Add(blurFilter);
break;
case PreparedFilter.GRAYSCALE:
AbstractFilter f = new GrayscaleFilter(this)
{
Invert = true
};
Add(f);
break;
case PreparedFilter.MAGNIFICATION:
Add(new MagnifierFilter(this));
break;
}
}
}
}

View file

@ -0,0 +1,104 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.IO;
using System.Drawing.Drawing2D;
using log4net;
using System.Runtime.Serialization;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of IconContainer.
/// </summary>
[Serializable]
public class IconContainer : DrawableContainer, IIconContainer {
private static readonly ILog Log = LogManager.GetLogger(typeof(IconContainer));
protected Icon icon;
public IconContainer(Surface parent) : base(parent) {
Init();
}
protected override void OnDeserialized(StreamingContext streamingContext)
{
base.OnDeserialized(streamingContext);
Init();
}
private void Init()
{
CreateDefaultAdorners();
}
public IconContainer(Surface parent, string filename) : base(parent) {
Load(filename);
}
public Icon Icon {
set {
icon?.Dispose();
icon = (Icon)value.Clone();
Width = value.Width;
Height = value.Height;
}
get { return icon; }
}
/**
* 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)
{
icon?.Dispose();
}
icon = null;
base.Dispose(disposing);
}
public void Load(string filename) {
if (File.Exists(filename))
{
using Icon fileIcon = new Icon(filename);
Icon = fileIcon;
Log.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
}
}
public override void Draw(Graphics graphics, RenderMode rm) {
if (icon != null) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
graphics.CompositingQuality = CompositingQuality.Default;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.DrawIcon(icon, Bounds);
}
}
public override bool HasDefaultSize => true;
public override Size DefaultSize => icon.Size;
}
}

View file

@ -0,0 +1,226 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.IO;
using Greenshot.Drawing.Fields;
using GreenshotPlugin.Core;
using System.Drawing.Drawing2D;
using log4net;
using System.Runtime.Serialization;
using GreenshotPlugin.Effects;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of BitmapContainer.
/// </summary>
[Serializable]
public class ImageContainer : DrawableContainer, IImageContainer {
private static readonly ILog Log = LogManager.GetLogger(typeof(ImageContainer));
private Image image;
/// <summary>
/// This is the shadow version of the bitmap, rendered once to save performance
/// Do not serialize, as the shadow is recreated from the original bitmap if it's not available
/// </summary>
[NonSerialized]
private Image _shadowBitmap;
/// <summary>
/// This is the offset for the shadow version of the bitmap
/// Do not serialize, as the offset is recreated
/// </summary>
[NonSerialized]
private Point _shadowOffset = new Point(-1, -1);
public ImageContainer(Surface parent, string filename) : this(parent) {
Load(filename);
}
public ImageContainer(Surface parent) : base(parent) {
FieldChanged += BitmapContainer_OnFieldChanged;
Init();
}
protected override void OnDeserialized(StreamingContext streamingContext)
{
base.OnDeserialized(streamingContext);
Init();
}
private void Init()
{
CreateDefaultAdorners();
}
protected override void InitializeFields() {
AddField(GetType(), FieldType.SHADOW, false);
}
protected void BitmapContainer_OnFieldChanged(object sender, FieldChangedEventArgs e) {
if (sender.Equals(this)) {
if (FieldType.SHADOW.Equals(e.Field.FieldType)) {
ChangeShadowField();
}
}
}
public void ChangeShadowField() {
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
if (shadow) {
CheckShadow(true);
Width = _shadowBitmap.Width;
Height = _shadowBitmap.Height;
Left -= _shadowOffset.X;
Top -= _shadowOffset.Y;
} else {
Width = image.Width;
Height = image.Height;
if (_shadowBitmap != null) {
Left += _shadowOffset.X;
Top += _shadowOffset.Y;
}
}
}
public Image Image {
set {
// Remove all current bitmaps
DisposeImage();
DisposeShadow();
image = ImageHelper.Clone(value);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
CheckShadow(shadow);
if (!shadow) {
Width = image.Width;
Height = image.Height;
} else {
Width = _shadowBitmap.Width;
Height = _shadowBitmap.Height;
Left -= _shadowOffset.X;
Top -= _shadowOffset.Y;
}
}
get { return image; }
}
/// <summary>
/// The bulk of the clean-up code is implemented in Dispose(bool)
/// This Dispose is called from the Dispose and the Destructor.
/// When disposing==true all non-managed resources should be freed too!
/// </summary>
/// <param name="disposing"></param>
protected override void Dispose(bool disposing) {
if (disposing) {
DisposeImage();
DisposeShadow();
}
base.Dispose(disposing);
}
private void DisposeImage() {
image?.Dispose();
image = null;
}
private void DisposeShadow() {
_shadowBitmap?.Dispose();
_shadowBitmap = null;
}
/// <summary>
/// Make sure the content is also transformed.
/// </summary>
/// <param name="matrix"></param>
public override void Transform(Matrix matrix) {
int rotateAngle = CalculateAngle(matrix);
// we currently assume only one transformation has been made.
if (rotateAngle != 0) {
Log.DebugFormat("Rotating element with {0} degrees.", rotateAngle);
DisposeShadow();
using var tmpMatrix = new Matrix();
using (image)
{
image = ImageHelper.ApplyEffect(image, new RotateEffect(rotateAngle), tmpMatrix);
}
}
base.Transform(matrix);
}
/// <summary>
///
/// </summary>
/// <param name="filename"></param>
public void Load(string filename) {
if (!File.Exists(filename))
{
return;
}
// Always make sure ImageHelper.LoadBitmap results are disposed some time,
// as we close the bitmap internally, we need to do it afterwards
using (var tmpImage = ImageHelper.LoadImage(filename)) {
Image = tmpImage;
}
Log.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
}
/// <summary>
/// This checks if a shadow is already generated
/// </summary>
/// <param name="shadow"></param>
private void CheckShadow(bool shadow) {
if (shadow && _shadowBitmap == null)
{
using var matrix = new Matrix();
_shadowBitmap = ImageHelper.ApplyEffect(image, new DropShadowEffect(), matrix);
}
}
/// <summary>
/// Draw the actual container to the graphics object
/// </summary>
/// <param name="graphics"></param>
/// <param name="rm"></param>
public override void Draw(Graphics graphics, RenderMode rm) {
if (image != null) {
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
if (shadow) {
CheckShadow(true);
graphics.DrawImage(_shadowBitmap, Bounds);
} else {
graphics.DrawImage(image, Bounds);
}
}
}
public override bool HasDefaultSize => true;
public override Size DefaultSize => image.Size;
}
}

View file

@ -0,0 +1,114 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Drawing.Adorners;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of LineContainer.
/// </summary>
[Serializable()]
public class LineContainer : DrawableContainer {
public static readonly int MAX_CLICK_DISTANCE_TOLERANCE = 10;
public LineContainer(Surface parent) : base(parent) {
Init();
}
protected override void InitializeFields() {
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.SHADOW, true);
}
protected override void OnDeserialized(StreamingContext context)
{
Init();
}
protected void Init() {
Adorners.Add(new MoveAdorner(this, Positions.TopLeft));
Adorners.Add(new MoveAdorner(this, Positions.BottomRight));
}
public override void Draw(Graphics graphics, RenderMode rm) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
if (lineThickness > 0) {
if (shadow) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while (currentStep <= steps)
{
using Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100), lineThickness);
graphics.DrawLine(shadowCapPen,
Left + currentStep,
Top + currentStep,
Left + currentStep + Width,
Top + currentStep + Height);
currentStep++;
alpha -= basealpha / steps;
}
}
using Pen pen = new Pen(lineColor, lineThickness);
graphics.DrawLine(pen, Left, Top, Left + Width, Top + Height);
}
}
public override bool ClickableAt(int x, int y) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) +5;
if (lineThickness > 0)
{
using Pen pen = new Pen(Color.White)
{
Width = lineThickness
};
using GraphicsPath path = new GraphicsPath();
path.AddLine(Left, Top, Left + Width, Top + Height);
return path.IsOutlineVisible(x, y, pen);
}
return false;
}
protected override ScaleHelper.IDoubleProcessor GetAngleRoundProcessor() {
return ScaleHelper.LineAngleRoundBehavior.Instance;
}
}
}

View file

@ -0,0 +1,76 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of ObfuscateContainer.
/// </summary>
[Serializable]
public class ObfuscateContainer : FilterContainer {
public ObfuscateContainer(Surface parent) : base(parent) {
Init();
}
protected override void InitializeFields() {
base.InitializeFields();
AddField(GetType(), FieldType.PREPARED_FILTER_OBFUSCATE, PreparedFilter.PIXELIZE);
}
protected override void OnDeserialized(StreamingContext context)
{
Init();
}
private void Init() {
FieldChanged += ObfuscateContainer_OnFieldChanged;
ConfigurePreparedFilters();
CreateDefaultAdorners();
}
protected void ObfuscateContainer_OnFieldChanged(object sender, FieldChangedEventArgs e) {
if(sender.Equals(this)) {
if(Equals(e.Field.FieldType, FieldType.PREPARED_FILTER_OBFUSCATE)) {
ConfigurePreparedFilters();
}
}
}
private void ConfigurePreparedFilters() {
PreparedFilter preset = (PreparedFilter)GetFieldValue(FieldType.PREPARED_FILTER_OBFUSCATE);
while(Filters.Count>0) {
Remove(Filters[0]);
}
switch(preset) {
case PreparedFilter.BLUR:
Add(new BlurFilter(this));
break;
case PreparedFilter.PIXELIZE:
Add(new PixelizationFilter(this));
break;
}
}
}
}

View file

@ -0,0 +1,38 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Drawing
{
/// <summary>
/// Position
/// </summary>
public enum Positions : int
{
TopLeft = 0,
TopCenter = 1,
TopRight = 2,
MiddleRight = 3,
BottomRight = 4,
BottomCenter = 5,
BottomLeft = 6,
MiddleLeft = 7
}
}

View file

@ -0,0 +1,157 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Drawing.Drawing2D;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using System.Runtime.Serialization;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Represents a rectangular shape on the Surface
/// </summary>
[Serializable]
public class RectangleContainer : DrawableContainer {
public RectangleContainer(Surface parent) : base(parent) {
Init();
}
/// <summary>
/// Do some logic to make sure all field are initiated correctly
/// </summary>
/// <param name="streamingContext">StreamingContext</param>
protected override void OnDeserialized(StreamingContext streamingContext)
{
base.OnDeserialized(streamingContext);
Init();
}
private void Init()
{
CreateDefaultAdorners();
}
protected override void InitializeFields() {
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
AddField(GetType(), FieldType.SHADOW, true);
}
public override void Draw(Graphics graphics, RenderMode rm) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR, Color.Red);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR, Color.Transparent);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
DrawRectangle(rect, graphics, rm, lineThickness, lineColor, fillColor, shadow);
}
/// <summary>
/// This method can also be used from other containers, if the right values are passed!
/// </summary>
/// <param name="rect"></param>
/// <param name="graphics"></param>
/// <param name="rm"></param>
/// <param name="lineThickness"></param>
/// <param name="lineColor"></param>
/// <param name="fillColor"></param>
/// <param name="shadow"></param>
public static void DrawRectangle(Rectangle rect, Graphics graphics, RenderMode rm, int lineThickness, Color lineColor, Color fillColor, bool shadow) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps)
{
using Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))
{
Width = lineVisible ? lineThickness : 1
};
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(
rect.Left + currentStep,
rect.Top + currentStep,
rect.Width,
rect.Height);
graphics.DrawRectangle(shadowPen, shadowRect);
currentStep++;
alpha -= basealpha / steps;
}
}
if (Colors.IsVisible(fillColor))
{
using Brush brush = new SolidBrush(fillColor);
graphics.FillRectangle(brush, rect);
}
graphics.SmoothingMode = SmoothingMode.HighSpeed;
if (lineVisible)
{
using Pen pen = new Pen(lineColor, lineThickness);
graphics.DrawRectangle(pen, rect);
}
}
public override bool ClickableAt(int x, int y) {
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS) + 10;
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
return RectangleClickableAt(rect, lineThickness, fillColor, x, y);
}
public static bool RectangleClickableAt(Rectangle rect, int lineThickness, Color fillColor, int x, int y) {
// If we clicked inside the rectangle and it's visible we are clickable at.
if (!Color.Transparent.Equals(fillColor)) {
if (rect.Contains(x,y)) {
return true;
}
}
// check the rest of the lines
if (lineThickness > 0)
{
using Pen pen = new Pen(Color.White, lineThickness);
using GraphicsPath path = new GraphicsPath();
path.AddRectangle(rect);
return path.IsOutlineVisible(x, y, pen);
}
return false;
}
}
}

View file

@ -0,0 +1,135 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace Greenshot.Drawing {
/// <summary>
/// TODO: currently this is only used in the capture form, we might move this code directly to there!
/// </summary>
public abstract class RoundedRectangle {
[Flags]
public enum RectangleCorners {
None = 0, TopLeft = 1, TopRight = 2,
BottomLeft = 4, BottomRight = 8,
All = TopLeft | TopRight | BottomLeft | BottomRight
}
public static GraphicsPath Create2(int x, int y, int width, int height, int radius) {
GraphicsPath gp = new GraphicsPath();
gp.AddLine(x + radius, y, x + width - radius * 2, y); // Line
gp.AddArc(x + width - radius * 2, y, radius * 2, radius * 2, 270, 90); // Corner
gp.AddLine(x + width, y + radius, x + width, y + height - radius * 2); // Line
gp.AddArc(x + width - radius * 2, y + height - radius * 2, radius * 2, radius * 2, 0, 90); // Corner
gp.AddLine(x + width - radius * 2, y + height, x + radius, y + height); // Line
gp.AddArc(x, y + height - radius * 2, radius * 2, radius * 2, 90, 90); // Corner
gp.AddLine(x, y + height - radius * 2, x, y + radius); // Line
gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); // Corner
gp.CloseFigure();
return gp;
}
public static GraphicsPath Create(int x, int y, int width, int height, int radius, RectangleCorners corners) {
int xw = x + width;
int yh = y + height;
int xwr = xw - radius;
int yhr = yh - radius;
int xr = x + radius;
int yr = y + radius;
int r2 = radius * 2;
int xwr2 = xw - r2;
int yhr2 = yh - r2;
GraphicsPath p = new GraphicsPath();
p.StartFigure();
//Top Left Corner
if ((RectangleCorners.TopLeft & corners) == RectangleCorners.TopLeft) {
p.AddArc(x, y, r2, r2, 180, 90);
} else {
p.AddLine(x, yr, x, y);
p.AddLine(x, y, xr, y);
}
//Top Edge
p.AddLine(xr, y, xwr, y);
//Top Right Corner
if ((RectangleCorners.TopRight & corners) == RectangleCorners.TopRight) {
p.AddArc(xwr2, y, r2, r2, 270, 90);
} else {
p.AddLine(xwr, y, xw, y);
p.AddLine(xw, y, xw, yr);
}
//Right Edge
p.AddLine(xw, yr, xw, yhr);
//Bottom Right Corner
if ((RectangleCorners.BottomRight & corners) == RectangleCorners.BottomRight) {
p.AddArc(xwr2, yhr2, r2, r2, 0, 90);
} else {
p.AddLine(xw, yhr, xw, yh);
p.AddLine(xw, yh, xwr, yh);
}
//Bottom Edge
p.AddLine(xwr, yh, xr, yh);
//Bottom Left Corner
if ((RectangleCorners.BottomLeft & corners) == RectangleCorners.BottomLeft) {
p.AddArc(x, yhr2, r2, r2, 90, 90);
} else {
p.AddLine(xr, yh, x, yh);
p.AddLine(x, yh, x, yhr);
}
//Left Edge
p.AddLine(x, yhr, x, yr);
p.CloseFigure();
return p;
}
public static GraphicsPath Create(Rectangle rect, int radius, RectangleCorners corners) {
return Create(rect.X, rect.Y, rect.Width, rect.Height, radius, corners);
}
public static GraphicsPath Create(int x, int y, int width, int height, int radius) {
return Create(x, y, width, height, radius, RectangleCorners.All);
}
public static GraphicsPath Create(Rectangle rect, int radius) {
return Create(rect.X, rect.Y, rect.Width, rect.Height, radius);
}
public static GraphicsPath Create(int x, int y, int width, int height) {
return Create(x, y, width, height, 5);
}
public static GraphicsPath Create(Rectangle rect) {
return Create(rect.X, rect.Y, rect.Width, rect.Height);
}
}
}

View file

@ -0,0 +1,333 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Drawing.Fields;
using Greenshot.Helpers;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Runtime.Serialization;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing
{
/// <summary>
/// Description of SpeechbubbleContainer.
/// </summary>
[Serializable]
public class SpeechbubbleContainer : TextContainer {
private Point _initialGripperPoint;
// Only used for serializing the TargetGripper location
private Point _storedTargetGripperLocation;
/// <summary>
/// Store the current location of the target gripper
/// </summary>
/// <param name="context"></param>
[OnSerializing]
private void SetValuesOnSerializing(StreamingContext context) {
if (TargetAdorner != null) {
_storedTargetGripperLocation = TargetAdorner.Location;
}
}
/// <summary>
/// Restore the target gripper
/// </summary>
/// <param name="streamingContext">StreamingContext</param>
protected override void OnDeserialized(StreamingContext streamingContext)
{
base.OnDeserialized(streamingContext);
InitAdorner(Color.Green, _storedTargetGripperLocation);
}
public SpeechbubbleContainer(Surface parent)
: base(parent) {
}
/// <summary>
/// We set our own field values
/// </summary>
protected override void InitializeFields() {
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Blue);
AddField(GetType(), FieldType.SHADOW, false);
AddField(GetType(), FieldType.FONT_ITALIC, false);
AddField(GetType(), FieldType.FONT_BOLD, true);
AddField(GetType(), FieldType.FILL_COLOR, Color.White);
AddField(GetType(), FieldType.FONT_FAMILY, FontFamily.GenericSansSerif.Name);
AddField(GetType(), FieldType.FONT_SIZE, 20f);
AddField(GetType(), FieldType.TEXT_HORIZONTAL_ALIGNMENT, StringAlignment.Center);
AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, StringAlignment.Center);
}
/// <summary>
/// Called from Surface (the _parent) when the drawing begins (mouse-down)
/// </summary>
/// <returns>true if the surface doesn't need to handle the event</returns>
public override bool HandleMouseDown(int mouseX, int mouseY) {
if (TargetAdorner == null) {
_initialGripperPoint = new Point(mouseX, mouseY);
InitAdorner(Color.Green, new Point(mouseX, mouseY));
}
return base.HandleMouseDown(mouseX, mouseY);
}
/// <summary>
/// Overriding the HandleMouseMove will help us to make sure the tail is always visible.
/// Should fix BUG-1682
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
/// <returns>base.HandleMouseMove</returns>
public override bool HandleMouseMove(int x, int y) {
bool returnValue = base.HandleMouseMove(x, y);
bool leftAligned = _boundsAfterResize.Right - _boundsAfterResize.Left >= 0;
bool topAligned = _boundsAfterResize.Bottom - _boundsAfterResize.Top >= 0;
int xOffset = leftAligned ? -20 : 20;
int yOffset = topAligned ? -20 : 20;
Point newGripperLocation = _initialGripperPoint;
newGripperLocation.Offset(xOffset, yOffset);
if (TargetAdorner.Location != newGripperLocation) {
Invalidate();
TargetAdorner.Location = newGripperLocation;
Invalidate();
}
return returnValue;
}
/// <summary>
/// The DrawingBound should be so close as possible to the shape, so we don't invalidate to much.
/// </summary>
public override Rectangle DrawingBounds {
get {
if (Status != EditStatus.UNDRAWN) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
using Pen pen = new Pen(lineColor, lineThickness);
int inflateValue = lineThickness + 2 + (shadow ? 6 : 0);
using GraphicsPath tailPath = CreateTail();
return Rectangle.Inflate(Rectangle.Union(Rectangle.Round(tailPath.GetBounds(new Matrix(), pen)), GuiRectangle.GetGuiRectangle(Left, Top, Width, Height)), inflateValue, inflateValue);
}
return Rectangle.Empty;
}
}
/// <summary>
/// Helper method to create the bubble GraphicsPath, so we can also calculate the bounds
/// </summary>
/// <param name="lineThickness"></param>
/// <returns></returns>
private GraphicsPath CreateBubble(int lineThickness) {
GraphicsPath bubble = new GraphicsPath();
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
Rectangle bubbleRect = GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height);
// adapt corner radius to small rectangle dimensions
int smallerSideLength = Math.Min(bubbleRect.Width, bubbleRect.Height);
int cornerRadius = Math.Min(30, smallerSideLength / 2 - lineThickness);
if (cornerRadius > 0) {
bubble.AddArc(bubbleRect.X, bubbleRect.Y, cornerRadius, cornerRadius, 180, 90);
bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y, cornerRadius, cornerRadius, 270, 90);
bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 0, 90);
bubble.AddArc(bubbleRect.X, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 90, 90);
} else {
bubble.AddRectangle(bubbleRect);
}
bubble.CloseAllFigures();
using (Matrix bubbleMatrix = new Matrix()) {
bubbleMatrix.Translate(rect.Left, rect.Top);
bubble.Transform(bubbleMatrix);
}
return bubble;
}
/// <summary>
/// Helper method to create the tail of the bubble, so we can also calculate the bounds
/// </summary>
/// <returns></returns>
private GraphicsPath CreateTail() {
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
int tailLength = GeometryHelper.Distance2D(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2), TargetAdorner.Location.X, TargetAdorner.Location.Y);
int tailWidth = (Math.Abs(rect.Width) + Math.Abs(rect.Height)) / 20;
// This should fix a problem with the tail being to wide
tailWidth = Math.Min(Math.Abs(rect.Width) / 2, tailWidth);
tailWidth = Math.Min(Math.Abs(rect.Height) / 2, tailWidth);
GraphicsPath tail = new GraphicsPath();
tail.AddLine(-tailWidth, 0, tailWidth, 0);
tail.AddLine(tailWidth, 0, 0, -tailLength);
tail.CloseFigure();
int tailAngle = 90 + (int)GeometryHelper.Angle2D(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2, TargetAdorner.Location.X, TargetAdorner.Location.Y);
using (Matrix tailMatrix = new Matrix()) {
tailMatrix.Translate(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);
tailMatrix.Rotate(tailAngle);
tail.Transform(tailMatrix);
}
return tail;
}
/// <summary>
/// This is to draw the actual container
/// </summary>
/// <param name="graphics"></param>
/// <param name="renderMode"></param>
public override void Draw(Graphics graphics, RenderMode renderMode) {
if (TargetAdorner == null) {
return;
}
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
if (Selected && renderMode == RenderMode.EDIT) {
DrawSelectionBorder(graphics, rect);
}
GraphicsPath bubble = CreateBubble(lineThickness);
GraphicsPath tail = CreateTail();
//draw shadow first
if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
const int basealpha = 100;
int alpha = basealpha;
const int steps = 5;
int currentStep = lineVisible ? 1 : 0;
using Matrix shadowMatrix = new Matrix();
using GraphicsPath bubbleClone = (GraphicsPath)bubble.Clone();
using GraphicsPath tailClone = (GraphicsPath)tail.Clone();
shadowMatrix.Translate(1, 1);
while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowPen.Width = lineVisible ? lineThickness : 1;
tailClone.Transform(shadowMatrix);
graphics.DrawPath(shadowPen, tailClone);
bubbleClone.Transform(shadowMatrix);
graphics.DrawPath(shadowPen, bubbleClone);
}
currentStep++;
alpha -= basealpha / steps;
}
}
GraphicsState state = graphics.Save();
// draw the tail border where the bubble is not visible
using (Region clipRegion = new Region(bubble)) {
graphics.SetClip(clipRegion, CombineMode.Exclude);
using Pen pen = new Pen(lineColor, lineThickness);
graphics.DrawPath(pen, tail);
}
graphics.Restore(state);
if (Colors.IsVisible(fillColor)) {
//draw the bubbleshape
state = graphics.Save();
using (Brush brush = new SolidBrush(fillColor)) {
graphics.FillPath(brush, bubble);
}
graphics.Restore(state);
}
if (lineVisible) {
//draw the bubble border
state = graphics.Save();
// Draw bubble where the Tail is not visible.
using (Region clipRegion = new Region(tail)) {
graphics.SetClip(clipRegion, CombineMode.Exclude);
using Pen pen = new Pen(lineColor, lineThickness);
//pen.EndCap = pen.StartCap = LineCap.Round;
graphics.DrawPath(pen, bubble);
}
graphics.Restore(state);
}
if (Colors.IsVisible(fillColor)) {
// Draw the tail border
state = graphics.Save();
using (Brush brush = new SolidBrush(fillColor)) {
graphics.FillPath(brush, tail);
}
graphics.Restore(state);
}
// cleanup the paths
bubble.Dispose();
tail.Dispose();
// Draw the text
DrawText(graphics, rect, lineThickness, lineColor, shadow, StringFormat, Text, Font);
}
public override bool Contains(int x, int y) {
if (base.Contains(x, y)) {
return true;
}
Point clickedPoint = new Point(x, y);
if (Status != EditStatus.UNDRAWN) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
using Pen pen = new Pen(lineColor, lineThickness);
using (GraphicsPath bubblePath = CreateBubble(lineThickness)) {
bubblePath.Widen(pen);
if (bubblePath.IsVisible(clickedPoint)) {
return true;
}
}
using GraphicsPath tailPath = CreateTail();
tailPath.Widen(pen);
if (tailPath.IsVisible(clickedPoint)) {
return true;
}
}
return false;
}
public override bool ClickableAt(int x, int y) {
return Contains(x,y);
}
}
}

View file

@ -0,0 +1,227 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Drawing.Fields;
using Greenshot.Helpers;
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Text;
using System.Runtime.Serialization;
using GreenshotPlugin.Interfaces.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// This is an enumerated label, every single StepLabelContainer shows the number of the order it was created.
/// To make sure that deleting recalculates, we check the location before every draw.
/// </summary>
[Serializable]
public sealed class StepLabelContainer : DrawableContainer {
[NonSerialized]
private StringFormat _stringFormat = new StringFormat();
private readonly bool _drawAsRectangle = false;
private float fontSize = 16;
public StepLabelContainer(Surface parent) : base(parent) {
parent.AddStepLabel(this);
InitContent();
Init();
}
private void Init()
{
CreateDefaultAdorners();
}
// Used to store the number of this label, so when deserializing it can be placed back to the StepLabels list in the right location
private int _number;
// Used to store the counter start of the Surface, as the surface is NOT stored.
private int _counterStart = 1;
public int Number {
get {
return _number;
}
set {
_number = value;
}
}
/// <summary>
/// Retrieve the counter before serializing
/// </summary>
/// <param name="context"></param>
[OnSerializing]
private void SetValuesOnSerializing(StreamingContext context) {
if (Parent != null) {
Number = ((Surface)Parent).CountStepLabels(this);
_counterStart = ((Surface) Parent).CounterStart;
}
}
/// <summary>
/// Restore values that don't serialize
/// </summary>
/// <param name="context"></param>
protected override void OnDeserialized(StreamingContext context)
{
Init();
_stringFormat = new StringFormat
{
Alignment = StringAlignment.Center,
LineAlignment = StringAlignment.Center
};
}
/// <summary>
/// Add the StepLabel to the parent
/// </summary>
/// <param name="newParent"></param>
protected override void SwitchParent(Surface newParent) {
if (newParent == Parent)
{
return;
}
((Surface) Parent)?.RemoveStepLabel(this);
base.SwitchParent(newParent);
if (newParent == null)
{
return;
}
// Make sure the counter start is restored (this unfortunately happens multiple times... -> hack)
newParent.CounterStart = _counterStart;
newParent.AddStepLabel(this);
}
public override Size DefaultSize => new Size(30, 30);
public override bool InitContent() {
_defaultEditMode = EditStatus.IDLE;
_stringFormat.Alignment = StringAlignment.Center;
_stringFormat.LineAlignment = StringAlignment.Center;
// Set defaults
Width = DefaultSize.Width;
Height = DefaultSize.Height;
return true;
}
/// <summary>
/// This makes it possible for the label to be placed exactly in the middle of the pointer.
/// </summary>
public override bool HandleMouseDown(int mouseX, int mouseY) {
return base.HandleMouseDown(mouseX - Width / 2, mouseY - Height / 2);
}
/// <summary>
/// We set our own field values
/// </summary>
protected override void InitializeFields() {
AddField(GetType(), FieldType.FILL_COLOR, Color.DarkRed);
AddField(GetType(), FieldType.LINE_COLOR, Color.White);
AddField(GetType(), FieldType.FLAGS, FieldFlag.COUNTER);
}
/// <summary>
/// Make sure this element is no longer referenced from the surface
/// </summary>
protected override void Dispose(bool disposing) {
base.Dispose(disposing);
if (!disposing) {
return;
}
((Surface) Parent)?.RemoveStepLabel(this);
if (_stringFormat == null)
{
return;
}
_stringFormat.Dispose();
_stringFormat = null;
}
public override bool HandleMouseMove(int x, int y) {
Invalidate();
Left = x - Width / 2;
Top = y - Height / 2;
Invalidate();
return true;
}
/// <summary>
/// Make sure the size of the font is scaled
/// </summary>
/// <param name="matrix"></param>
public override void Transform(Matrix matrix) {
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
int widthBefore = rect.Width;
int heightBefore = rect.Height;
// Transform this container
base.Transform(matrix);
rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
int widthAfter = rect.Width;
int heightAfter = rect.Height;
float factor = ((float)widthAfter / widthBefore + (float)heightAfter / heightBefore) / 2;
fontSize *= factor;
}
/// <summary>
/// Override the parent, calculate the label number, than draw
/// </summary>
/// <param name="graphics"></param>
/// <param name="rm"></param>
public override void Draw(Graphics graphics, RenderMode rm) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
string text = ((Surface)Parent).CountStepLabels(this).ToString();
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
if (_drawAsRectangle) {
RectangleContainer.DrawRectangle(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
} else {
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
}
using FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name);
using Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font);
}
public override bool ClickableAt(int x, int y) {
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
if (_drawAsRectangle) {
return RectangleContainer.RectangleClickableAt(rect, 0, fillColor, x, y);
} else {
return EllipseContainer.EllipseClickableAt(rect, 0, fillColor, x, y);
}
}
}
}

2038
Greenshot/Drawing/Surface.cs Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://getgreenshot.org/
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
@ -16,12 +16,10 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using System.Windows.Forms;
using Greenshot.Base.Controls;
using Greenshot.Base.Core;
using Greenshot.Helpers;
namespace Greenshot.Forms {
@ -51,28 +49,26 @@ namespace Greenshot.Forms {
/// </summary>
private void InitializeComponent() {
this.lblTitle = new System.Windows.Forms.Label();
this.lblLicense = new GreenshotLabel();
this.lblHost = new GreenshotLabel();
this.lblLicense = new GreenshotPlugin.Controls.GreenshotLabel();
this.lblHost = new GreenshotPlugin.Controls.GreenshotLabel();
this.linkLblLicense = new System.Windows.Forms.LinkLabel();
this.linkLblHost = new System.Windows.Forms.LinkLabel();
this.linkLblBugs = new System.Windows.Forms.LinkLabel();
this.lblBugs = new GreenshotLabel();
this.lblBugs = new GreenshotPlugin.Controls.GreenshotLabel();
this.linkLblDonations = new System.Windows.Forms.LinkLabel();
this.lblDonations = new GreenshotLabel();
this.lblDonations = new GreenshotPlugin.Controls.GreenshotLabel();
this.linkLblIcons = new System.Windows.Forms.LinkLabel();
this.lblIcons = new GreenshotLabel();
this.lblIcons = new GreenshotPlugin.Controls.GreenshotLabel();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.lblTranslation = new GreenshotLabel();
this.lblTranslation = new GreenshotPlugin.Controls.GreenshotLabel();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// lblTitle
//
var fontsize = (this.DeviceDpi / 96) * lblTitle.Font.Size;
this.lblTitle.AutoSize = true;
this.lblTitle.Font = new System.Drawing.Font(System.Drawing.FontFamily.GenericSansSerif, fontsize, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblTitle.Location = new System.Drawing.Point(108, 12);
this.lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblTitle.Location = new System.Drawing.Point(108, 12);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(263, 19);
this.lblTitle.TabIndex = 2;
@ -101,7 +97,7 @@ namespace Greenshot.Forms {
this.linkLblLicense.Size = new System.Drawing.Size(369, 23);
this.linkLblLicense.TabIndex = 5;
this.linkLblLicense.TabStop = true;
this.linkLblLicense.Text = "https://www.gnu.org/licenses/gpl.html";
this.linkLblLicense.Text = "http://www.gnu.org/licenses/gpl.html";
this.linkLblLicense.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// linkLblHost
@ -121,9 +117,8 @@ namespace Greenshot.Forms {
this.linkLblBugs.Size = new System.Drawing.Size(465, 23);
this.linkLblBugs.TabIndex = 8;
this.linkLblBugs.TabStop = true;
this.linkLblBugs.Text = "https://getgreenshot.org/tickets";
this.linkLblBugs.Tag = "https://getgreenshot.org/tickets/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
this.linkLblBugs.Text = "http://getgreenshot.org/tickets/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// lblBugs
//
@ -140,9 +135,8 @@ namespace Greenshot.Forms {
this.linkLblDonations.Size = new System.Drawing.Size(465, 23);
this.linkLblDonations.TabIndex = 10;
this.linkLblDonations.TabStop = true;
this.linkLblDonations.Text = "https://getgreenshot.org/support";
this.linkLblDonations.Tag = "https://getgreenshot.org/support/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLblDonations.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
this.linkLblDonations.Text = "http://getgreenshot.org/support/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLblDonations.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// lblDonations
//
@ -159,7 +153,7 @@ namespace Greenshot.Forms {
this.linkLblIcons.Size = new System.Drawing.Size(279, 23);
this.linkLblIcons.TabIndex = 12;
this.linkLblIcons.TabStop = true;
this.linkLblIcons.Text = "https://p.yusukekamiyamane.com";
this.linkLblIcons.Text = "http://p.yusukekamiyamane.com";
this.linkLblIcons.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// lblIcons
@ -177,10 +171,9 @@ namespace Greenshot.Forms {
this.linkLabel1.Size = new System.Drawing.Size(130, 23);
this.linkLabel1.TabIndex = 13;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "https://getgreenshot.org";
this.linkLabel1.Text = "http://getgreenshot.org/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.linkLabel1.Tag = "https://getgreenshot.org/?version=" + EnvironmentInfo.GetGreenshotVersion(true);
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// pictureBox1
//
@ -202,11 +195,8 @@ namespace Greenshot.Forms {
//
// AboutForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
//this.AutoScaleDimensions = new System.Drawing.SizeF(96, 96);
//this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(530, 293);
this.Controls.Add(this.lblTranslation);
this.Controls.Add(this.pictureBox1);
@ -242,11 +232,11 @@ namespace Greenshot.Forms {
private System.Windows.Forms.LinkLabel linkLblIcons;
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.PictureBox pictureBox1;
private GreenshotLabel lblTranslation;
private GreenshotLabel lblHost;
private GreenshotLabel lblDonations;
private GreenshotLabel lblBugs;
private GreenshotLabel lblIcons;
private GreenshotLabel lblLicense;
private GreenshotPlugin.Controls.GreenshotLabel lblTranslation;
private GreenshotPlugin.Controls.GreenshotLabel lblHost;
private GreenshotPlugin.Controls.GreenshotLabel lblDonations;
private GreenshotPlugin.Controls.GreenshotLabel lblBugs;
private GreenshotPlugin.Controls.GreenshotLabel lblIcons;
private GreenshotPlugin.Controls.GreenshotLabel lblLicense;
}
}

View file

@ -0,0 +1,333 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.IO;
using System.Security.Permissions;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Helpers;
using GreenshotPlugin.Core;
using GreenshotPlugin.IniFile;
using log4net;
namespace Greenshot.Forms {
/// <summary>
/// The about form
/// </summary>
public sealed partial class AboutForm : AnimatingBaseForm {
private static readonly ILog Log = LogManager.GetLogger(typeof(AboutForm));
private Bitmap _bitmap;
private readonly ColorAnimator _backgroundAnimation;
private readonly List<RectangleAnimator> _pixels = new List<RectangleAnimator>();
private readonly List<Color> _colorFlow = new List<Color>();
private readonly List<Color> _pixelColors = new List<Color>();
private readonly Random _rand = new Random();
private readonly Color _backColor = Color.FromArgb(61, 61, 61);
private readonly Color _pixelColor = Color.FromArgb(138, 255, 0);
// Variables used for the color-cycle
private int _waitFrames;
private int _colorIndex;
private int _scrollCount;
private bool _hasAnimationsLeft;
// Variables are used to define the location of the dots
private const int W = 13;
private const int P1 = 7;
private const int P2 = P1 + W;
private const int P3 = P2 + W;
private const int P4 = P3 + W;
private const int P5 = P4 + W;
private const int P6 = P5 + W;
private const int P7 = P6 + W;
/// <summary>
/// The location of every dot in the "G"
/// </summary>
private readonly List<Point> _gSpots = new List<Point>
{
// Top row
new Point(P2, P1), // 0
new Point(P3, P1), // 1
new Point(P4, P1), // 2
new Point(P5, P1), // 3
new Point(P6, P1), // 4
// Second row
new Point(P1, P2), // 5
new Point(P2, P2), // 6
// Third row
new Point(P1, P3), // 7
new Point(P2, P3), // 8
// Fourth row
new Point(P1, P4), // 9
new Point(P2, P4), // 10
new Point(P5, P4), // 11
new Point(P6, P4), // 12
new Point(P7, P4), // 13
// Fifth row
new Point(P1, P5), // 14
new Point(P2, P5), // 15
new Point(P6, P5), // 16
new Point(P7, P5), // 17
// Sixth row
new Point(P1, P6), // 18
new Point(P2, P6), // 19
new Point(P3, P6), // 20
new Point(P4, P6), // 21
new Point(P5, P6), // 22
new Point(P6, P6) // 23
};
// 0 1 2 3 4
// 5 6
// 7 8
// 9 10 11 12 13
// 14 15 16 17
// 18 19 20 21 22 23
// The order in which we draw the dots & flow the colors.
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>
/// Cleanup all the allocated resources
/// </summary>
private void Cleanup(object sender, EventArgs e) {
if (_bitmap == null) return;
_bitmap.Dispose();
_bitmap = null;
}
/// <summary>
/// Constructor
/// </summary>
public AboutForm() {
// Make sure our resources are removed again.
Disposed += Cleanup;
FormClosing += Cleanup;
// Enable animation for this form, when we don't set this the timer doesn't start as soon as the form is loaded.
EnableAnimation = true;
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
// Only use double-buffering when we are NOT in a Terminal Server session
DoubleBuffered = !IsTerminalServerSession;
// Use the self drawn image, first we create the background to be the back-color (as we animate from this)
_bitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96);
pictureBox1.Image = _bitmap;
lblTitle.Text = $@"Greenshot {EnvironmentInfo.GetGreenshotVersion()} {(IniConfig.IsPortable ? " Portable" : "")} ({OsInfo.Bits}) bit)";
// Number of frames the pixel animation takes
int frames = FramesForMillis(2000);
// The number of frames the color-cycle waits before it starts
_waitFrames = FramesForMillis(6000);
// Every pixel is created after pixelWaitFrames frames, which is increased in the loop.
int pixelWaitFrames = FramesForMillis(2000);
// Create pixels
for (int index = 0; index < _gSpots.Count; index++) {
// Read the pixels in the order of the flow
Point gSpot = _gSpots[_flowOrder[index]];
// Create the animation, first we do nothing (on the final destination)
RectangleAnimator pixelAnimation;
// Make the pixel grow from the middle, if this offset isn't used it looks like it's shifted
int offset = (W - 2) / 2;
// If the optimize for Terminal Server is set we make the animation without much ado
if (IsTerminalServerSession) {
// No animation
pixelAnimation = new RectangleAnimator(new Rectangle(gSpot.X, gSpot.Y, W - 2, W - 2), new Rectangle(gSpot.X, gSpot.Y, W - 2, W - 2), 1, EasingType.Cubic, EasingMode.EaseIn);
} else {
// Create the animation, first we do nothing (on the final destination)
Rectangle standingStill = new Rectangle(gSpot.X + offset, gSpot.Y + offset, 0, 0);
pixelAnimation = new RectangleAnimator(standingStill, standingStill, pixelWaitFrames, EasingType.Quintic, EasingMode.EaseIn);
// And than we size to the wanted size.
pixelAnimation.QueueDestinationLeg(new Rectangle(gSpot.X, gSpot.Y, W - 2, W - 2), frames);
}
// Increase the wait frames
pixelWaitFrames += FramesForMillis(100);
// Add to the list of to be animated pixels
_pixels.Add(pixelAnimation);
// Add a color to the list for this pixel.
_pixelColors.Add(_pixelColor);
}
// Make sure the frame "loop" knows we have to animate
_hasAnimationsLeft = true;
// Pixel Color cycle colors, here we use a pre-animated loop which stores the values.
ColorAnimator pixelColorAnimator = new ColorAnimator(_pixelColor, Color.FromArgb(255, 255, 255), 6, EasingType.Quadratic, EasingMode.EaseIn);
pixelColorAnimator.QueueDestinationLeg(_pixelColor, 6, EasingType.Quadratic, EasingMode.EaseOut);
do {
_colorFlow.Add(pixelColorAnimator.Current);
pixelColorAnimator.Next();
} while (pixelColorAnimator.HasNext);
// color animation for the background
_backgroundAnimation = new ColorAnimator(BackColor, _backColor, FramesForMillis(5000), EasingType.Linear, EasingMode.EaseIn);
}
/// <summary>
/// This is called when a link is clicked
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void LinkLabelClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
if (!(sender is LinkLabel linkLabel)) return;
try {
linkLabel.LinkVisited = true;
Process.Start(linkLabel.Text);
} catch (Exception) {
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, linkLabel.Text), Language.GetString(LangKey.error));
}
}
/// <summary>
/// Called from the AnimatingForm, for every frame
/// </summary>
protected override void Animate() {
if (_bitmap == null) {
return;
}
if (!IsTerminalServerSession) {
// Color cycle
if (_waitFrames != 0) {
_waitFrames--;
// Check if there is something else to do, if not we return so we don't occupy the CPU
if (!_hasAnimationsLeft) {
return;
}
} else if (_scrollCount < _pixelColors.Count + _colorFlow.Count) {
// Scroll colors, the scrollCount is the amount of pixels + the amount of colors to cycle.
for (int index = _pixelColors.Count - 1; index > 0; index--) {
_pixelColors[index] = _pixelColors[index - 1];
}
// Keep adding from the colors to cycle until there is nothing left
if (_colorIndex < _colorFlow.Count) {
_pixelColors[0] = _colorFlow[_colorIndex++];
}
_scrollCount++;
} else {
// Reset values, wait X time for the next one
_waitFrames = FramesForMillis(3000 + _rand.Next(35000));
_colorIndex = 0;
_scrollCount = 0;
// Check if there is something else to do, if not we return so we don't occupy the CPU
if (!_hasAnimationsLeft) {
return;
}
}
} else if (!_hasAnimationsLeft) {
return;
}
// Draw the "G"
using (Graphics graphics = Graphics.FromImage(_bitmap)) {
graphics.SmoothingMode = SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBilinear;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
graphics.Clear(_backgroundAnimation.Next());
graphics.TranslateTransform(2, -2);
graphics.RotateTransform(20);
using SolidBrush brush = new SolidBrush(_pixelColor);
int index = 0;
// We assume there is nothing to animate in the next Animate loop
_hasAnimationsLeft = false;
// Pixels of the G
foreach (RectangleAnimator pixel in _pixels) {
brush.Color = _pixelColors[index++];
graphics.FillEllipse(brush, pixel.Current);
// If a pixel still has frames left, the hasAnimationsLeft will be true
_hasAnimationsLeft |= pixel.HasNext;
pixel.Next();
}
}
pictureBox1.Invalidate();
}
/// <summary>
/// CmdKey handler
/// </summary>
/// <param name="msg"></param>
/// <param name="keyData"></param>
/// <returns></returns>
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
try {
switch (keyData) {
case Keys.Escape:
DialogResult = DialogResult.Cancel;
break;
case Keys.E:
MessageBox.Show(EnvironmentInfo.EnvironmentToString(true));
break;
case Keys.L:
try {
if (File.Exists(MainForm.LogFileLocation)) {
using (Process.Start("\"" + MainForm.LogFileLocation + "\"")) {
// nothing to do, just using dispose to cleanup
}
} else {
MessageBox.Show(@"Greenshot can't find the logfile, it should have been here: " + MainForm.LogFileLocation);
}
} catch (Exception) {
MessageBox.Show(@"Couldn't open the greenshot.log, it's located here: " + MainForm.LogFileLocation, @"Error opening greenshot.log", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
break;
case Keys.I:
try {
using (Process.Start("\"" + IniConfig.ConfigLocation + "\"")) {
}
} catch (Exception) {
MessageBox.Show(@"Couldn't open the greenshot.ini, it's located here: " + IniConfig.ConfigLocation, @"Error opening greenshot.ini", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
}
break;
default:
return base.ProcessCmdKey(ref msg, keyData);
}
} catch (Exception ex) {
Log.Error($"Error handling key '{keyData}'", ex);
}
return true;
}
}
}

View file

@ -0,0 +1,30 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 GreenshotPlugin.Controls;
namespace Greenshot {
/// <summary>
/// This class is only here to help in the Designer mode, so it's clear where the language files are
/// </summary>
public class AnimatingBaseForm : AnimatingForm {
}
}

View file

@ -0,0 +1,30 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 GreenshotPlugin.Controls;
namespace Greenshot {
/// <summary>
/// This class is only here to help in the Designer mode, so it's clear where the language files are
/// </summary>
public class BaseForm : GreenshotForm {
}
}

View file

@ -1,8 +1,8 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://getgreenshot.org/
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
@ -16,11 +16,8 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
using Greenshot.Base.Controls;
namespace Greenshot.Forms {
partial class BugReportForm {
/// <summary>
@ -49,9 +46,9 @@ namespace Greenshot.Forms {
/// </summary>
private void InitializeComponent()
{
this.labelBugReportInfo = new GreenshotLabel();
this.labelBugReportInfo = new GreenshotPlugin.Controls.GreenshotLabel();
this.textBoxDescription = new System.Windows.Forms.TextBox();
this.btnClose = new GreenshotButton();
this.btnClose = new GreenshotPlugin.Controls.GreenshotButton();
this.linkLblBugs = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
@ -94,7 +91,7 @@ namespace Greenshot.Forms {
this.linkLblBugs.Size = new System.Drawing.Size(465, 23);
this.linkLblBugs.TabIndex = 9;
this.linkLblBugs.TabStop = true;
this.linkLblBugs.Text = "https://getgreenshot.org/tickets/";
this.linkLblBugs.Text = "http://getgreenshot.org/tickets/";
this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLblBugsLinkClicked);
//
// BugReportForm
@ -115,8 +112,8 @@ namespace Greenshot.Forms {
}
private System.Windows.Forms.LinkLabel linkLblBugs;
private GreenshotButton btnClose;
private GreenshotPlugin.Controls.GreenshotButton btnClose;
private System.Windows.Forms.TextBox textBoxDescription;
private GreenshotLabel labelBugReportInfo;
private GreenshotPlugin.Controls.GreenshotLabel labelBugReportInfo;
}
}

View file

@ -0,0 +1,54 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Diagnostics;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
namespace Greenshot.Forms {
public partial class BugReportForm : BaseForm {
private BugReportForm() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
ToFront = true;
}
public BugReportForm(string bugText) : this() {
textBoxDescription.Text = bugText;
}
private void LinkLblBugsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
openLink((LinkLabel)sender);
}
private void openLink(LinkLabel link) {
try {
link.LinkVisited = true;
Process.Start(link.Text);
} catch (Exception) {
MessageBox.Show(Language.GetFormattedString(LangKey.error_openlink, link.Text), Language.GetString(LangKey.error));
}
}
}
}

View file

@ -1,8 +1,8 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://getgreenshot.org/
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Forms {
partial class CaptureForm {
@ -55,8 +55,8 @@ namespace Greenshot.Forms {
//
// CaptureForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(0, 0);
this.Cursor = System.Windows.Forms.Cursors.Cross;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

File diff suppressed because it is too large Load diff

View file

@ -1,288 +1,284 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Greenshot.Base.Controls;
using Greenshot.Editor.Controls;
namespace Greenshot.Editor.Forms {
public partial class ColorDialog {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog));
this.btnTransparent = new GreenshotButton();
this.colorPanel = new System.Windows.Forms.Panel();
this.labelHtmlColor = new GreenshotLabel();
this.textBoxHtmlColor = new System.Windows.Forms.TextBox();
this.labelRed = new GreenshotLabel();
this.labelGreen = new GreenshotLabel();
this.labelBlue = new GreenshotLabel();
this.textBoxRed = new System.Windows.Forms.TextBox();
this.textBoxGreen = new System.Windows.Forms.TextBox();
this.textBoxBlue = new System.Windows.Forms.TextBox();
this.labelRecentColors = new GreenshotLabel();
this.textBoxAlpha = new System.Windows.Forms.TextBox();
this.labelAlpha = new GreenshotLabel();
this.btnApply = new GreenshotButton();
this.pipette = new Pipette();
this.SuspendLayout();
//
// btnTransparent
//
this.btnTransparent.BackColor = System.Drawing.Color.Transparent;
this.btnTransparent.LanguageKey = "colorpicker_transparent";
this.btnTransparent.Location = new System.Drawing.Point(210, 4);
this.btnTransparent.Name = "btnTransparent";
this.btnTransparent.Size = new System.Drawing.Size(78, 23);
this.btnTransparent.TabIndex = 0;
this.btnTransparent.TabStop = false;
this.btnTransparent.Text = "Transparent";
this.btnTransparent.UseVisualStyleBackColor = false;
this.btnTransparent.Click += new System.EventHandler(this.BtnTransparentClick);
//
// colorPanel
//
this.colorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.colorPanel.Location = new System.Drawing.Point(213, 30);
this.colorPanel.Name = "colorPanel";
this.colorPanel.Size = new System.Drawing.Size(33, 23);
this.colorPanel.TabIndex = 1;
//
// labelHtmlColor
//
this.labelHtmlColor.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelHtmlColor.LanguageKey = "colorpicker_htmlcolor";
this.labelHtmlColor.Location = new System.Drawing.Point(210, 57);
this.labelHtmlColor.Name = "labelHtmlColor";
this.labelHtmlColor.Size = new System.Drawing.Size(78, 17);
this.labelHtmlColor.TabIndex = 2;
this.labelHtmlColor.Text = "HTML color";
//
// textBoxHtmlColor
//
this.textBoxHtmlColor.Location = new System.Drawing.Point(210, 71);
this.textBoxHtmlColor.Name = "textBoxHtmlColor";
this.textBoxHtmlColor.Size = new System.Drawing.Size(78, 20);
this.textBoxHtmlColor.TabIndex = 1;
this.textBoxHtmlColor.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxHtmlColor.TextChanged += new System.EventHandler(this.TextBoxHexadecimalTextChanged);
this.textBoxHtmlColor.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxHtmlColor.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// labelRed
//
this.labelRed.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelRed.LanguageKey = "colorpicker_red";
this.labelRed.Location = new System.Drawing.Point(210, 98);
this.labelRed.Name = "labelRed";
this.labelRed.Size = new System.Drawing.Size(78, 18);
this.labelRed.TabIndex = 4;
this.labelRed.Text = "Red";
//
// labelGreen
//
this.labelGreen.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelGreen.LanguageKey = "colorpicker_green";
this.labelGreen.Location = new System.Drawing.Point(210, 122);
this.labelGreen.Name = "labelGreen";
this.labelGreen.Size = new System.Drawing.Size(78, 18);
this.labelGreen.TabIndex = 5;
this.labelGreen.Text = "Green";
//
// labelBlue
//
this.labelBlue.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelBlue.LanguageKey = "colorpicker_blue";
this.labelBlue.Location = new System.Drawing.Point(210, 146);
this.labelBlue.Name = "labelBlue";
this.labelBlue.Size = new System.Drawing.Size(78, 18);
this.labelBlue.TabIndex = 6;
this.labelBlue.Text = "Blue";
//
// textBoxRed
//
this.textBoxRed.Location = new System.Drawing.Point(258, 95);
this.textBoxRed.Name = "textBoxRed";
this.textBoxRed.Size = new System.Drawing.Size(30, 20);
this.textBoxRed.TabIndex = 2;
this.textBoxRed.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.textBoxRed.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxRed.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
this.textBoxRed.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxRed.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// textBoxGreen
//
this.textBoxGreen.Location = new System.Drawing.Point(258, 119);
this.textBoxGreen.Name = "textBoxGreen";
this.textBoxGreen.Size = new System.Drawing.Size(30, 20);
this.textBoxGreen.TabIndex = 3;
this.textBoxGreen.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.textBoxGreen.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxGreen.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
this.textBoxGreen.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxGreen.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// textBoxBlue
//
this.textBoxBlue.Location = new System.Drawing.Point(258, 143);
this.textBoxBlue.Name = "textBoxBlue";
this.textBoxBlue.Size = new System.Drawing.Size(30, 20);
this.textBoxBlue.TabIndex = 4;
this.textBoxBlue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.textBoxBlue.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxBlue.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
this.textBoxBlue.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxBlue.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// labelRecentColors
//
this.labelRecentColors.LanguageKey = "colorpicker_recentcolors";
this.labelRecentColors.Location = new System.Drawing.Point(3, 175);
this.labelRecentColors.Name = "labelRecentColors";
this.labelRecentColors.Size = new System.Drawing.Size(148, 13);
this.labelRecentColors.TabIndex = 10;
this.labelRecentColors.Text = "Recently used colors";
//
// textBoxAlpha
//
this.textBoxAlpha.Location = new System.Drawing.Point(258, 167);
this.textBoxAlpha.Name = "textBoxAlpha";
this.textBoxAlpha.Size = new System.Drawing.Size(30, 20);
this.textBoxAlpha.TabIndex = 5;
this.textBoxAlpha.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.textBoxAlpha.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxAlpha.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
this.textBoxAlpha.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxAlpha.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// labelAlpha
//
this.labelAlpha.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelAlpha.LanguageKey = "colorpicker_alpha";
this.labelAlpha.Location = new System.Drawing.Point(210, 170);
this.labelAlpha.Name = "labelAlpha";
this.labelAlpha.Size = new System.Drawing.Size(78, 18);
this.labelAlpha.TabIndex = 11;
this.labelAlpha.Text = "Alpha";
//
// btnApply
//
this.btnApply.BackColor = System.Drawing.Color.Transparent;
this.btnApply.LanguageKey = "colorpicker_apply";
this.btnApply.Location = new System.Drawing.Point(210, 191);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(78, 23);
this.btnApply.TabIndex = 12;
this.btnApply.TabStop = false;
this.btnApply.Text = "Apply";
this.btnApply.UseVisualStyleBackColor = false;
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
//
// pipette
//
this.pipette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pipette.Cursor = System.Windows.Forms.Cursors.Arrow;
this.pipette.Image = ((System.Drawing.Image)(resources.GetObject("pipette.Image")));
this.pipette.Location = new System.Drawing.Point(255, 30);
this.pipette.Name = "pipette";
this.pipette.Size = new System.Drawing.Size(33, 23);
this.pipette.TabIndex = 13;
this.pipette.PipetteUsed += new System.EventHandler<PipetteUsedArgs>(this.PipetteUsed);
//
// ColorDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(292, 218);
this.Controls.Add(this.pipette);
this.Controls.Add(this.btnApply);
this.Controls.Add(this.textBoxAlpha);
this.Controls.Add(this.labelAlpha);
this.Controls.Add(this.labelRecentColors);
this.Controls.Add(this.textBoxBlue);
this.Controls.Add(this.textBoxGreen);
this.Controls.Add(this.textBoxRed);
this.Controls.Add(this.labelBlue);
this.Controls.Add(this.labelGreen);
this.Controls.Add(this.labelRed);
this.Controls.Add(this.textBoxHtmlColor);
this.Controls.Add(this.labelHtmlColor);
this.Controls.Add(this.colorPanel);
this.Controls.Add(this.btnTransparent);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.LanguageKey = "colorpicker_title";
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ColorDialog";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Color picker";
this.ResumeLayout(false);
this.PerformLayout();
}
private GreenshotLabel labelRed;
private GreenshotLabel labelGreen;
private GreenshotLabel labelBlue;
private System.Windows.Forms.TextBox textBoxHtmlColor;
private GreenshotLabel labelRecentColors;
private GreenshotLabel labelAlpha;
private GreenshotLabel labelHtmlColor;
private GreenshotButton btnApply;
private System.Windows.Forms.TextBox textBoxAlpha;
private System.Windows.Forms.TextBox textBoxRed;
private System.Windows.Forms.TextBox textBoxGreen;
private System.Windows.Forms.TextBox textBoxBlue;
private System.Windows.Forms.Panel colorPanel;
private GreenshotButton btnTransparent;
private Pipette pipette;
}
}
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot {
public partial class ColorDialog {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ColorDialog));
this.btnTransparent = new GreenshotPlugin.Controls.GreenshotButton();
this.colorPanel = new System.Windows.Forms.Panel();
this.labelHtmlColor = new GreenshotPlugin.Controls.GreenshotLabel();
this.textBoxHtmlColor = new System.Windows.Forms.TextBox();
this.labelRed = new GreenshotPlugin.Controls.GreenshotLabel();
this.labelGreen = new GreenshotPlugin.Controls.GreenshotLabel();
this.labelBlue = new GreenshotPlugin.Controls.GreenshotLabel();
this.textBoxRed = new System.Windows.Forms.TextBox();
this.textBoxGreen = new System.Windows.Forms.TextBox();
this.textBoxBlue = new System.Windows.Forms.TextBox();
this.labelRecentColors = new GreenshotPlugin.Controls.GreenshotLabel();
this.textBoxAlpha = new System.Windows.Forms.TextBox();
this.labelAlpha = new GreenshotPlugin.Controls.GreenshotLabel();
this.btnApply = new GreenshotPlugin.Controls.GreenshotButton();
this.pipette = new Greenshot.Controls.Pipette();
this.SuspendLayout();
//
// btnTransparent
//
this.btnTransparent.BackColor = System.Drawing.Color.Transparent;
this.btnTransparent.LanguageKey = "colorpicker_transparent";
this.btnTransparent.Location = new System.Drawing.Point(210, 4);
this.btnTransparent.Name = "btnTransparent";
this.btnTransparent.Size = new System.Drawing.Size(78, 23);
this.btnTransparent.TabIndex = 0;
this.btnTransparent.TabStop = false;
this.btnTransparent.Text = "Transparent";
this.btnTransparent.UseVisualStyleBackColor = false;
this.btnTransparent.Click += new System.EventHandler(this.BtnTransparentClick);
//
// colorPanel
//
this.colorPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.colorPanel.Location = new System.Drawing.Point(213, 30);
this.colorPanel.Name = "colorPanel";
this.colorPanel.Size = new System.Drawing.Size(33, 23);
this.colorPanel.TabIndex = 1;
//
// labelHtmlColor
//
this.labelHtmlColor.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelHtmlColor.LanguageKey = "colorpicker_htmlcolor";
this.labelHtmlColor.Location = new System.Drawing.Point(210, 57);
this.labelHtmlColor.Name = "labelHtmlColor";
this.labelHtmlColor.Size = new System.Drawing.Size(78, 17);
this.labelHtmlColor.TabIndex = 2;
this.labelHtmlColor.Text = "HTML color";
//
// textBoxHtmlColor
//
this.textBoxHtmlColor.Location = new System.Drawing.Point(210, 71);
this.textBoxHtmlColor.Name = "textBoxHtmlColor";
this.textBoxHtmlColor.Size = new System.Drawing.Size(78, 20);
this.textBoxHtmlColor.TabIndex = 1;
this.textBoxHtmlColor.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxHtmlColor.TextChanged += new System.EventHandler(this.TextBoxHexadecimalTextChanged);
this.textBoxHtmlColor.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxHtmlColor.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// labelRed
//
this.labelRed.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelRed.LanguageKey = "colorpicker_red";
this.labelRed.Location = new System.Drawing.Point(210, 98);
this.labelRed.Name = "labelRed";
this.labelRed.Size = new System.Drawing.Size(78, 18);
this.labelRed.TabIndex = 4;
this.labelRed.Text = "Red";
//
// labelGreen
//
this.labelGreen.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelGreen.LanguageKey = "colorpicker_green";
this.labelGreen.Location = new System.Drawing.Point(210, 122);
this.labelGreen.Name = "labelGreen";
this.labelGreen.Size = new System.Drawing.Size(78, 18);
this.labelGreen.TabIndex = 5;
this.labelGreen.Text = "Green";
//
// labelBlue
//
this.labelBlue.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelBlue.LanguageKey = "colorpicker_blue";
this.labelBlue.Location = new System.Drawing.Point(210, 146);
this.labelBlue.Name = "labelBlue";
this.labelBlue.Size = new System.Drawing.Size(78, 18);
this.labelBlue.TabIndex = 6;
this.labelBlue.Text = "Blue";
//
// textBoxRed
//
this.textBoxRed.Location = new System.Drawing.Point(258, 95);
this.textBoxRed.Name = "textBoxRed";
this.textBoxRed.Size = new System.Drawing.Size(30, 20);
this.textBoxRed.TabIndex = 2;
this.textBoxRed.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.textBoxRed.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxRed.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
this.textBoxRed.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxRed.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// textBoxGreen
//
this.textBoxGreen.Location = new System.Drawing.Point(258, 119);
this.textBoxGreen.Name = "textBoxGreen";
this.textBoxGreen.Size = new System.Drawing.Size(30, 20);
this.textBoxGreen.TabIndex = 3;
this.textBoxGreen.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.textBoxGreen.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxGreen.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
this.textBoxGreen.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxGreen.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// textBoxBlue
//
this.textBoxBlue.Location = new System.Drawing.Point(258, 143);
this.textBoxBlue.Name = "textBoxBlue";
this.textBoxBlue.Size = new System.Drawing.Size(30, 20);
this.textBoxBlue.TabIndex = 4;
this.textBoxBlue.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.textBoxBlue.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxBlue.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
this.textBoxBlue.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxBlue.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// labelRecentColors
//
this.labelRecentColors.LanguageKey = "colorpicker_recentcolors";
this.labelRecentColors.Location = new System.Drawing.Point(3, 175);
this.labelRecentColors.Name = "labelRecentColors";
this.labelRecentColors.Size = new System.Drawing.Size(148, 13);
this.labelRecentColors.TabIndex = 10;
this.labelRecentColors.Text = "Recently used colors";
//
// textBoxAlpha
//
this.textBoxAlpha.Location = new System.Drawing.Point(258, 167);
this.textBoxAlpha.Name = "textBoxAlpha";
this.textBoxAlpha.Size = new System.Drawing.Size(30, 20);
this.textBoxAlpha.TabIndex = 5;
this.textBoxAlpha.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
this.textBoxAlpha.Click += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxAlpha.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
this.textBoxAlpha.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
this.textBoxAlpha.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
//
// labelAlpha
//
this.labelAlpha.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World);
this.labelAlpha.LanguageKey = "colorpicker_alpha";
this.labelAlpha.Location = new System.Drawing.Point(210, 170);
this.labelAlpha.Name = "labelAlpha";
this.labelAlpha.Size = new System.Drawing.Size(78, 18);
this.labelAlpha.TabIndex = 11;
this.labelAlpha.Text = "Alpha";
//
// btnApply
//
this.btnApply.BackColor = System.Drawing.Color.Transparent;
this.btnApply.LanguageKey = "colorpicker_apply";
this.btnApply.Location = new System.Drawing.Point(210, 191);
this.btnApply.Name = "btnApply";
this.btnApply.Size = new System.Drawing.Size(78, 23);
this.btnApply.TabIndex = 12;
this.btnApply.TabStop = false;
this.btnApply.Text = "Apply";
this.btnApply.UseVisualStyleBackColor = false;
this.btnApply.Click += new System.EventHandler(this.BtnApplyClick);
//
// pipette
//
this.pipette.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pipette.Cursor = System.Windows.Forms.Cursors.Arrow;
this.pipette.Image = ((System.Drawing.Image)(resources.GetObject("pipette.Image")));
this.pipette.Location = new System.Drawing.Point(255, 30);
this.pipette.Name = "pipette";
this.pipette.Size = new System.Drawing.Size(33, 23);
this.pipette.TabIndex = 13;
this.pipette.PipetteUsed += new System.EventHandler<Greenshot.Controls.PipetteUsedArgs>(this.PipetteUsed);
//
// ColorDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(292, 218);
this.Controls.Add(this.pipette);
this.Controls.Add(this.btnApply);
this.Controls.Add(this.textBoxAlpha);
this.Controls.Add(this.labelAlpha);
this.Controls.Add(this.labelRecentColors);
this.Controls.Add(this.textBoxBlue);
this.Controls.Add(this.textBoxGreen);
this.Controls.Add(this.textBoxRed);
this.Controls.Add(this.labelBlue);
this.Controls.Add(this.labelGreen);
this.Controls.Add(this.labelRed);
this.Controls.Add(this.textBoxHtmlColor);
this.Controls.Add(this.labelHtmlColor);
this.Controls.Add(this.colorPanel);
this.Controls.Add(this.btnTransparent);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.LanguageKey = "colorpicker_title";
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ColorDialog";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Color picker";
this.ResumeLayout(false);
this.PerformLayout();
}
private GreenshotPlugin.Controls.GreenshotLabel labelRed;
private GreenshotPlugin.Controls.GreenshotLabel labelGreen;
private GreenshotPlugin.Controls.GreenshotLabel labelBlue;
private System.Windows.Forms.TextBox textBoxHtmlColor;
private GreenshotPlugin.Controls.GreenshotLabel labelRecentColors;
private GreenshotPlugin.Controls.GreenshotLabel labelAlpha;
private GreenshotPlugin.Controls.GreenshotLabel labelHtmlColor;
private GreenshotPlugin.Controls.GreenshotButton btnApply;
private System.Windows.Forms.TextBox textBoxAlpha;
private System.Windows.Forms.TextBox textBoxRed;
private System.Windows.Forms.TextBox textBoxGreen;
private System.Windows.Forms.TextBox textBoxBlue;
private System.Windows.Forms.Panel colorPanel;
private GreenshotPlugin.Controls.GreenshotButton btnTransparent;
private Greenshot.Controls.Pipette pipette;
}
}

View file

@ -0,0 +1,234 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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.Configuration;
using Greenshot.Controls;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Threading;
using System.Windows.Forms;
using GreenshotPlugin.IniFile;
namespace Greenshot {
/// <summary>
/// Description of ColorDialog.
/// </summary>
public partial class ColorDialog : BaseForm {
private static readonly EditorConfiguration EditorConfig = IniConfig.GetIniSection<EditorConfiguration>();
private static ColorDialog _instance;
public ColorDialog() {
SuspendLayout();
InitializeComponent();
SuspendLayout();
CreateColorPalette(5, 5, 15, 15);
CreateLastUsedColorButtonRow(5, 190, 15, 15);
ResumeLayout();
UpdateRecentColorsButtonRow();
_instance = this;
}
public static ColorDialog GetInstance() => _instance;
private readonly List<Button> _colorButtons = new List<Button>();
private readonly List<Button> _recentColorButtons = new List<Button>();
private readonly ToolTip _toolTip = new ToolTip();
private bool _updateInProgress;
public Color Color {
get { return colorPanel.BackColor; }
set { PreviewColor(value, this); }
}
public IList<Color> RecentColors => EditorConfig.RecentColors;
private void CreateColorPalette(int x, int y, int w, int h) {
CreateColorButtonColumn(255, 0, 0, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(255, 255 / 2, 0, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(255, 255, 0, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(255 / 2, 255, 0, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(0, 255, 0, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(0, 255, 255 / 2, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(0, 255, 255, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(0, 255 / 2, 255, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(0, 0, 255, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(255 / 2, 0, 255, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(255, 0, 255, x, y, w, h, 11);
x += w;
CreateColorButtonColumn(255, 0, 255 / 2, x, y, w, h, 11);
x += w + 5;
CreateColorButtonColumn(255 / 2, 255 / 2, 255 / 2, x, y, w, h, 11);
Controls.AddRange(_colorButtons.ToArray());
}
private void CreateColorButtonColumn(int red, int green, int blue, int x, int y, int w, int h, int shades) {
int shadedColorsNum = (shades - 1) / 2;
for (int i = 0; i <= shadedColorsNum; i++) {
_colorButtons.Add(CreateColorButton(red * i / shadedColorsNum, green * i / shadedColorsNum, blue * i / shadedColorsNum, x, y + i * h, w, h));
if (i > 0) _colorButtons.Add(CreateColorButton(red + (255 - red) * i / shadedColorsNum, green + (255 - green) * i / shadedColorsNum, blue + (255 - blue) * i / shadedColorsNum, x, y + (i + shadedColorsNum) * h, w, h));
}
}
private Button CreateColorButton(int red, int green, int blue, int x, int y, int w, int h) {
return CreateColorButton(Color.FromArgb(255, red, green, blue), x, y, w, h);
}
private Button CreateColorButton(Color color, int x, int y, int w, int h) {
Button b = new Button
{
BackColor = color,
FlatStyle = FlatStyle.Flat,
Location = new Point(x, y),
Size = new Size(w, h),
TabStop = false
};
b.FlatAppearance.BorderSize = 0;
b.Click += ColorButtonClick;
_toolTip.SetToolTip(b, ColorTranslator.ToHtml(color) + " | R:" + color.R + ", G:" + color.G + ", B:" + color.B);
return b;
}
private void CreateLastUsedColorButtonRow(int x, int y, int w, int h) {
for (int i = 0; i < 12; i++) {
Button b = CreateColorButton(Color.Transparent, x, y, w, h);
b.Enabled = false;
_recentColorButtons.Add(b);
x += w;
}
Controls.AddRange(_recentColorButtons.ToArray());
}
private void UpdateRecentColorsButtonRow() {
for (int i = 0; i < EditorConfig.RecentColors.Count && i < 12; i++) {
_recentColorButtons[i].BackColor = EditorConfig.RecentColors[i];
_recentColorButtons[i].Enabled = true;
}
}
private void PreviewColor(Color colorToPreview, Control trigger) {
_updateInProgress = true;
colorPanel.BackColor = colorToPreview;
if (trigger != textBoxHtmlColor) {
textBoxHtmlColor.Text = ColorTranslator.ToHtml(colorToPreview);
}
if (trigger != textBoxRed && trigger != textBoxGreen && trigger != textBoxBlue && trigger != textBoxAlpha) {
textBoxRed.Text = colorToPreview.R.ToString();
textBoxGreen.Text = colorToPreview.G.ToString();
textBoxBlue.Text = colorToPreview.B.ToString();
textBoxAlpha.Text = colorToPreview.A.ToString();
}
_updateInProgress = false;
}
private void AddToRecentColors(Color c) {
EditorConfig.RecentColors.Remove(c);
EditorConfig.RecentColors.Insert(0, c);
if (EditorConfig.RecentColors.Count > 12) {
EditorConfig.RecentColors.RemoveRange(12, EditorConfig.RecentColors.Count - 12);
}
UpdateRecentColorsButtonRow();
}
private void TextBoxHexadecimalTextChanged(object sender, EventArgs e) {
if (_updateInProgress) {
return;
}
TextBox textBox = (TextBox)sender;
string text = textBox.Text.Replace("#", string.Empty);
Color c;
if (int.TryParse(text, NumberStyles.AllowHexSpecifier, Thread.CurrentThread.CurrentCulture, out var i)) {
c = Color.FromArgb(i);
} else {
try
{
var knownColor = (KnownColor)Enum.Parse(typeof(KnownColor), text, true);
c = Color.FromKnownColor(knownColor);
} catch (Exception) {
return;
}
}
Color opaqueColor = Color.FromArgb(255, c.R, c.G, c.B);
PreviewColor(opaqueColor, textBox);
}
private void TextBoxRgbTextChanged(object sender, EventArgs e) {
if (_updateInProgress) {
return;
}
TextBox textBox = (TextBox)sender;
PreviewColor(Color.FromArgb(GetColorPartIntFromString(textBoxAlpha.Text), GetColorPartIntFromString(textBoxRed.Text), GetColorPartIntFromString(textBoxGreen.Text), GetColorPartIntFromString(textBoxBlue.Text)), textBox);
}
private void TextBoxGotFocus(object sender, EventArgs e) {
textBoxHtmlColor.SelectAll();
}
private void TextBoxKeyDown(object sender, KeyEventArgs e) {
if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) {
AddToRecentColors(colorPanel.BackColor);
}
}
private void ColorButtonClick(object sender, EventArgs e) {
Button b = (Button)sender;
PreviewColor(b.BackColor, b);
}
private void BtnTransparentClick(object sender, EventArgs e) {
ColorButtonClick(sender, e);
}
private void BtnApplyClick(object sender, EventArgs e) {
DialogResult = DialogResult.OK;
Hide();
AddToRecentColors(colorPanel.BackColor);
}
private int GetColorPartIntFromString(string s) {
int.TryParse(s, out var ret);
if (ret < 0)
{
ret = 0;
}
else if (ret > 255)
{
ret = 255;
}
return ret;
}
private void PipetteUsed(object sender, PipetteUsedArgs e) {
Color = e.Color;
}
}
}

View file

@ -1,135 +1,135 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pipette.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABqklEQVQ4T6WTvUtCURiH34Mi
Koo6CKI45HUT/4CgDwz8oMVFXLyGIVpDjTYkuDsoF6RPmtJKkIgKipYsCIoQihYXKxSCICjaGoTTe6R7
uflBgcOPwz3wPL/3HM4FSikMkw6sVCphHPNCSE9auPf8kydCJuqEHNYIOakSMsXYjiClUPSFmVAUiHBb
EOh7KkWPAC4lQb9mcY8J5HAzGKSP4TDdBrj+SzCGkkqTkHk2NmuWw+sAfklQBYDunAPUaLlMG4Qc9INX
kZEERa8Xdvx+2A0EpJR8Pv4UJe1CoaeZwb8E2WwWcrkcCILQST6fd2YymeRS6SG9j5JGKEQ3AW7XAJZF
eKBAhN8+v+p7V61jJimi5AMvbgVXDIiRjiBO0A2f3b9uud3u5IzRyOMEDA4MFKCES6fTCbGZwS6XK2G3
250RvR42ZM09E/A8D/F4PCaHOY6LWSwWzmq1wp8Cj8fjiMzOLbAzs2YEeZPJ5DCbzfAvgc1mi7L20Unv
ok6ni2q12hGDwQCDBEV8nRWMdIkajWZapVLFMZxarQb8hn6CMkI3mDvMhVwwzO/8DbWQqn7YBXReAAAA
AElFTkSuQmCC
</value>
</data>
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="pipette.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAZdEVYdFNvZnR3YXJlAEFkb2JlIEltYWdlUmVhZHlxyWU8AAABqklEQVQ4T6WTvUtCURiH34Mi
Koo6CKI45HUT/4CgDwz8oMVFXLyGIVpDjTYkuDsoF6RPmtJKkIgKipYsCIoQihYXKxSCICjaGoTTe6R7
uflBgcOPwz3wPL/3HM4FSikMkw6sVCphHPNCSE9auPf8kydCJuqEHNYIOakSMsXYjiClUPSFmVAUiHBb
EOh7KkWPAC4lQb9mcY8J5HAzGKSP4TDdBrj+SzCGkkqTkHk2NmuWw+sAfklQBYDunAPUaLlMG4Qc9INX
kZEERa8Xdvx+2A0EpJR8Pv4UJe1CoaeZwb8E2WwWcrkcCILQST6fd2YymeRS6SG9j5JGKEQ3AW7XAJZF
eKBAhN8+v+p7V61jJimi5AMvbgVXDIiRjiBO0A2f3b9uud3u5IzRyOMEDA4MFKCES6fTCbGZwS6XK2G3
250RvR42ZM09E/A8D/F4PCaHOY6LWSwWzmq1wp8Cj8fjiMzOLbAzs2YEeZPJ5DCbzfAvgc1mi7L20Unv
ok6ni2q12hGDwQCDBEV8nRWMdIkajWZapVLFMZxarQb8hn6CMkI3mDvMhVwwzO/8DbWQqn7YBXReAAAA
AElFTkSuQmCC
</value>
</data>
</root>

View file

@ -0,0 +1,97 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Diagnostics;
namespace Greenshot
{
public delegate void ColorPickerEventHandler(object o, ColorPickerEventArgs e);
public class ColorPickerToolStripButton : ToolStripButton
{
private Color _color;
public Point Offset = new Point(0,0);
public event ColorPickerEventHandler ColorPicked;
private readonly Greenshot.ColorDialog _cd;
public ColorPickerToolStripButton()
{
_cd = Greenshot.ColorDialog.GetInstance();
Click += ToolStripButton1Click;
}
public Color Color {
set {_color = value;Invalidate();}
get {return _color;}
}
protected override void OnPaint (PaintEventArgs e) {
base.OnPaint(e);
if(_color != null) {
// replace transparent color with selected color
Graphics g = e.Graphics;
//Graphics g = Graphics.FromImage(Image);
ColorMap[] colorMap = new ColorMap[1];
colorMap[0] = new ColorMap
{
OldColor = Color.Magenta,//this.ImageTransparentColor;
NewColor = _color
};
ImageAttributes attr = new ImageAttributes();
attr.SetRemapTable(colorMap);
Rectangle rect = new Rectangle(0, 0, Image.Width, Image.Height);
// todo find a way to retrieve transparency offset automatically
// for now, we use the public variable Offset to define this manually
rect.Offset(Offset.X,Offset.Y);
//Image.
Debug.WriteLine("paint!"+Text+": "+_color);
//ssif(color.Equals(Color.Transparent)) ((Bitmap)Image).MakeTransparent(Color.Magenta);
g.DrawImage(Image, rect, 0, 0, rect.Width, rect.Height, GraphicsUnit.Pixel, attr);
//this.Image.In
}
}
void ToolStripButton1Click(object sender, EventArgs e)
{
_cd.ShowDialog(Owner);
Color = _cd.Color;
ColorPicked?.Invoke(this, new ColorPickerEventArgs(Color));
}
}
public class ColorPickerEventArgs : EventArgs {
public Color Color;
public ColorPickerEventArgs(Color color) {
Color = color;
}
}
}

View file

@ -1,239 +1,240 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
using Greenshot.Base.Controls;
namespace Greenshot.Editor.Forms {
partial class DropShadowSettingsForm {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.thickness = new System.Windows.Forms.NumericUpDown();
this.offsetX = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.offsetY = new System.Windows.Forms.NumericUpDown();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.buttonOK = new GreenshotButton();
this.buttonCancel = new GreenshotButton();
this.labelDarkness = new GreenshotLabel();
this.labelOffset = new GreenshotLabel();
this.labelThickness = new GreenshotLabel();
((System.ComponentModel.ISupportInitialize)(this.thickness)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.offsetX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.offsetY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// thickness
//
this.thickness.Location = new System.Drawing.Point(173, 7);
this.thickness.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.thickness.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.thickness.Name = "thickness";
this.thickness.Size = new System.Drawing.Size(45, 20);
this.thickness.TabIndex = 1;
this.thickness.Value = new decimal(new int[] {
9,
0,
0,
0});
//
// offsetX
//
this.offsetX.Location = new System.Drawing.Point(102, 33);
this.offsetX.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.offsetX.Minimum = new decimal(new int[] {
20,
0,
0,
-2147483648});
this.offsetX.Name = "offsetX";
this.offsetX.Size = new System.Drawing.Size(45, 20);
this.offsetX.TabIndex = 2;
this.offsetX.Value = new decimal(new int[] {
1,
0,
0,
-2147483648});
//
// label3
//
this.label3.Location = new System.Drawing.Point(153, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(14, 13);
this.label3.TabIndex = 5;
this.label3.Text = "X";
//
// offsetY
//
this.offsetY.Location = new System.Drawing.Point(173, 33);
this.offsetY.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.offsetY.Minimum = new decimal(new int[] {
20,
0,
0,
-2147483648});
this.offsetY.Name = "offsetY";
this.offsetY.Size = new System.Drawing.Size(45, 20);
this.offsetY.TabIndex = 3;
this.offsetY.Value = new decimal(new int[] {
1,
0,
0,
-2147483648});
//
// trackBar1
//
this.trackBar1.Location = new System.Drawing.Point(102, 59);
this.trackBar1.Maximum = 40;
this.trackBar1.Minimum = 1;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(116, 45);
this.trackBar1.TabIndex = 4;
this.trackBar1.Value = 40;
//
// buttonOK
//
this.buttonOK.LanguageKey = "OK";
this.buttonOK.Location = new System.Drawing.Point(62, 110);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 11;
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.ButtonOK_Click);
//
// buttonCancel
//
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.LanguageKey = "CANCEL";
this.buttonCancel.Location = new System.Drawing.Point(143, 110);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 12;
this.buttonCancel.UseVisualStyleBackColor = true;
//
// labelDarkness
//
this.labelDarkness.LanguageKey = "editor_dropshadow_darkness";
this.labelDarkness.Location = new System.Drawing.Point(12, 73);
this.labelDarkness.Name = "labelDarkness";
this.labelDarkness.Size = new System.Drawing.Size(92, 13);
this.labelDarkness.TabIndex = 13;
//
// labelOffset
//
this.labelOffset.LanguageKey = "editor_dropshadow_offset";
this.labelOffset.Location = new System.Drawing.Point(12, 35);
this.labelOffset.Name = "labelOffset";
this.labelOffset.Size = new System.Drawing.Size(75, 13);
this.labelOffset.TabIndex = 14;
//
// labelThickness
//
this.labelThickness.LanguageKey = "editor_dropshadow_thickness";
this.labelThickness.Location = new System.Drawing.Point(12, 9);
this.labelThickness.Name = "labelThickness";
this.labelThickness.Size = new System.Drawing.Size(94, 13);
this.labelThickness.TabIndex = 15;
//
// DropShadowSettingsForm
//
this.AcceptButton = this.buttonOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(230, 154);
this.ControlBox = false;
this.Controls.Add(this.labelThickness);
this.Controls.Add(this.labelOffset);
this.Controls.Add(this.labelDarkness);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.trackBar1);
this.Controls.Add(this.offsetY);
this.Controls.Add(this.label3);
this.Controls.Add(this.offsetX);
this.Controls.Add(this.thickness);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.LanguageKey = "editor_dropshadow_settings";
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "DropShadowSettingsForm";
this.ShowIcon = false;
((System.ComponentModel.ISupportInitialize)(this.thickness)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.offsetX)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.offsetY)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.NumericUpDown thickness;
private System.Windows.Forms.NumericUpDown offsetX;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown offsetY;
private System.Windows.Forms.TrackBar trackBar1;
private GreenshotButton buttonOK;
private GreenshotButton buttonCancel;
private GreenshotLabel labelDarkness;
private GreenshotLabel labelOffset;
private GreenshotLabel labelThickness;
}
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Forms {
partial class DropShadowSettingsForm {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
this.thickness = new System.Windows.Forms.NumericUpDown();
this.offsetX = new System.Windows.Forms.NumericUpDown();
this.label3 = new System.Windows.Forms.Label();
this.offsetY = new System.Windows.Forms.NumericUpDown();
this.trackBar1 = new System.Windows.Forms.TrackBar();
this.buttonOK = new GreenshotPlugin.Controls.GreenshotButton();
this.buttonCancel = new GreenshotPlugin.Controls.GreenshotButton();
this.labelDarkness = new GreenshotPlugin.Controls.GreenshotLabel();
this.labelOffset = new GreenshotPlugin.Controls.GreenshotLabel();
this.labelThickness = new GreenshotPlugin.Controls.GreenshotLabel();
((System.ComponentModel.ISupportInitialize)(this.thickness)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.offsetX)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.offsetY)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).BeginInit();
this.SuspendLayout();
//
// thickness
//
this.thickness.Location = new System.Drawing.Point(173, 7);
this.thickness.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.thickness.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.thickness.Name = "thickness";
this.thickness.Size = new System.Drawing.Size(45, 20);
this.thickness.TabIndex = 1;
this.thickness.Value = new decimal(new int[] {
9,
0,
0,
0});
//
// offsetX
//
this.offsetX.Location = new System.Drawing.Point(102, 33);
this.offsetX.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.offsetX.Minimum = new decimal(new int[] {
20,
0,
0,
-2147483648});
this.offsetX.Name = "offsetX";
this.offsetX.Size = new System.Drawing.Size(45, 20);
this.offsetX.TabIndex = 2;
this.offsetX.Value = new decimal(new int[] {
1,
0,
0,
-2147483648});
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(153, 35);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(14, 13);
this.label3.TabIndex = 5;
this.label3.Text = "X";
//
// offsetY
//
this.offsetY.Location = new System.Drawing.Point(173, 33);
this.offsetY.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.offsetY.Minimum = new decimal(new int[] {
20,
0,
0,
-2147483648});
this.offsetY.Name = "offsetY";
this.offsetY.Size = new System.Drawing.Size(45, 20);
this.offsetY.TabIndex = 3;
this.offsetY.Value = new decimal(new int[] {
1,
0,
0,
-2147483648});
//
// trackBar1
//
this.trackBar1.Location = new System.Drawing.Point(102, 59);
this.trackBar1.Maximum = 40;
this.trackBar1.Minimum = 1;
this.trackBar1.Name = "trackBar1";
this.trackBar1.Size = new System.Drawing.Size(116, 45);
this.trackBar1.TabIndex = 4;
this.trackBar1.Value = 40;
//
// buttonOK
//
this.buttonOK.LanguageKey = "OK";
this.buttonOK.Location = new System.Drawing.Point(62, 110);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 23);
this.buttonOK.TabIndex = 11;
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.ButtonOK_Click);
//
// buttonCancel
//
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.buttonCancel.LanguageKey = "CANCEL";
this.buttonCancel.Location = new System.Drawing.Point(143, 110);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 12;
this.buttonCancel.UseVisualStyleBackColor = true;
//
// labelDarkness
//
this.labelDarkness.AutoSize = true;
this.labelDarkness.LanguageKey = "editor_dropshadow_darkness";
this.labelDarkness.Location = new System.Drawing.Point(12, 73);
this.labelDarkness.Name = "labelDarkness";
this.labelDarkness.Size = new System.Drawing.Size(92, 13);
this.labelDarkness.TabIndex = 13;
//
// labelOffset
//
this.labelOffset.AutoSize = true;
this.labelOffset.LanguageKey = "editor_dropshadow_offset";
this.labelOffset.Location = new System.Drawing.Point(12, 35);
this.labelOffset.Name = "labelOffset";
this.labelOffset.Size = new System.Drawing.Size(75, 13);
this.labelOffset.TabIndex = 14;
//
// labelThickness
//
this.labelThickness.AutoSize = true;
this.labelThickness.LanguageKey = "editor_dropshadow_thickness";
this.labelThickness.Location = new System.Drawing.Point(12, 9);
this.labelThickness.Name = "labelThickness";
this.labelThickness.Size = new System.Drawing.Size(94, 13);
this.labelThickness.TabIndex = 15;
//
// DropShadowSettingsForm
//
this.AcceptButton = this.buttonOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.CancelButton = this.buttonCancel;
this.ClientSize = new System.Drawing.Size(230, 154);
this.ControlBox = false;
this.Controls.Add(this.labelThickness);
this.Controls.Add(this.labelOffset);
this.Controls.Add(this.labelDarkness);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.trackBar1);
this.Controls.Add(this.offsetY);
this.Controls.Add(this.label3);
this.Controls.Add(this.offsetX);
this.Controls.Add(this.thickness);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.LanguageKey = "editor_dropshadow_settings";
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "DropShadowSettingsForm";
this.ShowIcon = false;
((System.ComponentModel.ISupportInitialize)(this.thickness)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.offsetX)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.offsetY)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.trackBar1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.NumericUpDown thickness;
private System.Windows.Forms.NumericUpDown offsetX;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.NumericUpDown offsetY;
private System.Windows.Forms.TrackBar trackBar1;
private GreenshotPlugin.Controls.GreenshotButton buttonOK;
private GreenshotPlugin.Controls.GreenshotButton buttonCancel;
private GreenshotPlugin.Controls.GreenshotLabel labelDarkness;
private GreenshotPlugin.Controls.GreenshotLabel labelOffset;
private GreenshotPlugin.Controls.GreenshotLabel labelThickness;
}
}

View file

@ -0,0 +1,53 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Drawing;
using System.Windows.Forms;
using GreenshotPlugin.Effects;
namespace Greenshot.Forms {
public partial class DropShadowSettingsForm : BaseForm {
private readonly DropShadowEffect _effect;
public DropShadowSettingsForm(DropShadowEffect effect) {
_effect = effect;
InitializeComponent();
ShowSettings();
}
/// <summary>
/// Apply the settings from the effect to the view
/// </summary>
private void ShowSettings() {
trackBar1.Value = (int)(_effect.Darkness * 40);
offsetX.Value = _effect.ShadowOffset.X;
offsetY.Value = _effect.ShadowOffset.Y;
thickness.Value = _effect.ShadowSize;
}
private void ButtonOK_Click(object sender, EventArgs e) {
_effect.Darkness = trackBar1.Value / (float)40;
_effect.ShadowOffset = new Point((int)offsetX.Value, (int)offsetY.Value);
_effect.ShadowSize = (int)thickness.Value;
DialogResult = DialogResult.OK;
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,8 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2021 Thomas Braun, Jens Klingen, Robin Krom
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: https://getgreenshot.org/
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Forms {
partial class LanguageDialog {

View file

@ -0,0 +1,92 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* 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 System;
using System.Threading;
using System.Windows.Forms;
using GreenshotPlugin.Core;
using log4net;
namespace Greenshot.Forms {
/// <summary>
/// Description of LanguageDialog.
/// </summary>
public partial class LanguageDialog : Form {
private static readonly ILog LOG = LogManager.GetLogger(typeof(LanguageDialog));
private static LanguageDialog _uniqueInstance;
private bool _properOkPressed;
private LanguageDialog() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
Icon = GreenshotResources.getGreenshotIcon();
Load += FormLoad;
FormClosing += PreventFormClose;
}
private void PreventFormClose(object sender, FormClosingEventArgs e) {
if(!_properOkPressed) {
e.Cancel = true;
}
}
public string SelectedLanguage => comboBoxLanguage.SelectedValue.ToString();
protected void FormLoad(object sender, EventArgs e) {
// Initialize the Language ComboBox
comboBoxLanguage.DisplayMember = "Description";
comboBoxLanguage.ValueMember = "Ietf";
// Set datasource last to prevent problems
// See: http://www.codeproject.com/KB/database/scomlistcontrolbinding.aspx?fid=111644
comboBoxLanguage.DataSource = Language.SupportedLanguages;
if (Language.CurrentLanguage != null) {
LOG.DebugFormat("Selecting {0}", Language.CurrentLanguage);
comboBoxLanguage.SelectedValue = Language.CurrentLanguage;
} else {
comboBoxLanguage.SelectedValue = Thread.CurrentThread.CurrentUICulture.Name;
}
// Close again when there is only one language, this shows the form briefly!
// But the use-case is not so interesting, only happens once, to invest a lot of time here.
if (Language.SupportedLanguages.Count == 1) {
comboBoxLanguage.SelectedValue = Language.SupportedLanguages[0].Ietf;
Language.CurrentLanguage = SelectedLanguage;
_properOkPressed = true;
Close();
}
}
private void BtnOKClick(object sender, EventArgs e) {
_properOkPressed = true;
// Fix for Bug #3431100
Language.CurrentLanguage = SelectedLanguage;
Close();
}
public static LanguageDialog GetInstance()
{
return _uniqueInstance ??= new LanguageDialog();
}
}
}

Some files were not shown because too many files have changed in this diff Show more