mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
Merge branch 'release/1.2.9'
# Conflicts: # Greenshot/Languages/language-cs-CZ.xml # Greenshot/releases/additional_files/readme.txt.template # GreenshotImgurPlugin/Forms/ImgurHistory.cs # GreenshotImgurPlugin/Forms/SettingsForm.cs # GreenshotImgurPlugin/ImgurConfiguration.cs # GreenshotImgurPlugin/ImgurPlugin.cs # GreenshotImgurPlugin/ImgurUtils.cs # GreenshotPlugin/Core/CoreConfiguration.cs # GreenshotPlugin/Core/ImageHelper.cs # GreenshotPlugin/Core/SourceForgeHelper.cs # GreenshotPlugin/GreenshotPlugin.csproj # appveyor12.yml
This commit is contained in:
commit
5d56bfab66
635 changed files with 20621 additions and 30686 deletions
233
.gitignore
vendored
233
.gitignore
vendored
|
@ -1,24 +1,211 @@
|
|||
.svn/
|
||||
*.gsp
|
||||
*.bak
|
||||
Greenshot*INSTALLER*.exe
|
||||
Greenshot*INSTALLER*.zip
|
||||
*.paf.exe
|
||||
*-SVN.*
|
||||
/Greenshot*/bin/
|
||||
obj/
|
||||
fugue/
|
||||
*Credentials.private.cs
|
||||
*Credentials.orig.cs
|
||||
/Greenshot/UpgradeLog*.htm
|
||||
/Greenshot/UpgradeLog*.XML
|
||||
/Greenshot/_UpgradeReport_Files/*
|
||||
*.log
|
||||
/Greenshot/releases/additional_files/readme.txt
|
||||
/*.error
|
||||
/Greenshot/releases/innosetup/setup.iss
|
||||
/Greenshot/packages
|
||||
/Greenshot/releases/appinfo.ini
|
||||
/Greenshot/Backup*
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
/Greenshot/tools/PortableApps.comInstaller/Data/PortableApps.comInstallerLog.txt
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
x64/
|
||||
x86/
|
||||
build/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUNIT
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
artifacts/
|
||||
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_i.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# JustCode is a .NET coding add-in
|
||||
.JustCode
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
## TODO: Comment the next line if you want to checkin your
|
||||
## web deploy settings but do note that will include unencrypted
|
||||
## passwords
|
||||
#*.pubxml
|
||||
|
||||
*.publishproj
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/packages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/packages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/packages/repositories.config
|
||||
|
||||
# Windows Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
[Ss]tyle[Cc]op.*
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# LightSwitch generated files
|
||||
GeneratedArtifacts/
|
||||
_Pvt_Extensions/
|
||||
ModelManifest.xml
|
||||
|
|
|
@ -1,37 +1,40 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
# SharpDevelop 4.2.2.8818
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Greenshot", "Greenshot.csproj", "{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}"
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 14
|
||||
VisualStudioVersion = 14.0.25420.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Greenshot", "Greenshot\Greenshot.csproj", "{CD642BF4-D815-4D67-A0B5-C69F0B8231AF}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotPlugin", "..\GreenshotPlugin\GreenshotPlugin.csproj", "{5B924697-4DCD-4F98-85F1-105CB84B7341}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotPlugin", "GreenshotPlugin\GreenshotPlugin.csproj", "{5B924697-4DCD-4F98-85F1-105CB84B7341}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotExternalCommandPlugin", "..\GreenshotExternalCommandPlugin\GreenshotExternalCommandPlugin.csproj", "{47F23C86-604E-4CC3-8767-B3D4088F30BB}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotExternalCommandPlugin", "GreenshotExternalCommandPlugin\GreenshotExternalCommandPlugin.csproj", "{47F23C86-604E-4CC3-8767-B3D4088F30BB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotConfluencePlugin", "..\GreenshotConfluencePlugin\GreenshotConfluencePlugin.csproj", "{C3052651-598A-44E2-AAB3-2E41311D50F9}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotConfluencePlugin", "GreenshotConfluencePlugin\GreenshotConfluencePlugin.csproj", "{C3052651-598A-44E2-AAB3-2E41311D50F9}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotImgurPlugin", "..\GreenshotImgurPlugin\GreenshotImgurPlugin.csproj", "{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotImgurPlugin", "GreenshotImgurPlugin\GreenshotImgurPlugin.csproj", "{80D8DEB9-94E3-4876-8CCA-2DF1ED5F2C50}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotJiraPlugin", "..\GreenshotJiraPlugin\GreenshotJiraPlugin.csproj", "{19FEEF09-313F-43C7-819D-F1BCA782B08B}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotJiraPlugin", "GreenshotJiraPlugin\GreenshotJiraPlugin.csproj", "{19FEEF09-313F-43C7-819D-F1BCA782B08B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotOCRPlugin", "..\GreenshotOCRPlugin\GreenshotOCRPlugin.csproj", "{C6988EE8-2FEE-4349-9F09-F9628A0D8965}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotOCRPlugin", "GreenshotOCRPlugin\GreenshotOCRPlugin.csproj", "{C6988EE8-2FEE-4349-9F09-F9628A0D8965}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotOCRCommand", "..\GreenshotOCRCommand\GreenshotOCRCommand.csproj", "{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "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("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotBoxPlugin", "..\GreenshotBoxPlugin\GreenshotBoxPlugin.csproj", "{697CF066-9077-4F22-99D9-D989CCE7282B}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotBoxPlugin", "GreenshotBoxPlugin\GreenshotBoxPlugin.csproj", "{697CF066-9077-4F22-99D9-D989CCE7282B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotDropboxPlugin", "..\GreenshotDropboxPlugin\GreenshotDropboxPlugin.csproj", "{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotDropboxPlugin", "GreenshotDropboxPlugin\GreenshotDropboxPlugin.csproj", "{AD7CFFE2-40E7-46CF-A172-D48CF7AE9A12}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotFlickrPlugin", "..\GreenshotFlickrPlugin\GreenshotFlickrPlugin.csproj", "{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotFlickrPlugin", "GreenshotFlickrPlugin\GreenshotFlickrPlugin.csproj", "{7EC72A5A-D73A-4B4B-9CA1-2216C7D92D5E}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotPicasaPlugin", "..\GreenshotPicasaPlugin\GreenshotPicasaPlugin.csproj", "{1893A2E4-A78A-4713-A8E7-E70058DABEE0}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotPicasaPlugin", "GreenshotPicasaPlugin\GreenshotPicasaPlugin.csproj", "{1893A2E4-A78A-4713-A8E7-E70058DABEE0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotOfficePlugin", "..\GreenshotOfficePlugin\GreenshotOfficePlugin.csproj", "{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotOfficePlugin", "GreenshotOfficePlugin\GreenshotOfficePlugin.csproj", "{92599C09-FF29-4ABD-B6E6-C48ECD781BAB}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotPhotobucketPlugin", "..\GreenshotPhotobucketPlugin\GreenshotPhotobucketPlugin.csproj", "{9C0ECC4C-7807-4111-916A-4F57BB29788A}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotPhotobucketPlugin", "GreenshotPhotobucketPlugin\GreenshotPhotobucketPlugin.csproj", "{9C0ECC4C-7807-4111-916A-4F57BB29788A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GreenshotWin10Plugin", "GreenshotWin10Plugin\GreenshotWin10Plugin.csproj", "{9801F62C-540F-4BFE-9211-6405DEDE563B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
|
@ -107,6 +110,7 @@ Global
|
|||
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
|
||||
{C6988EE8-2FEE-4349-9F09-F9628A0D8965}.Release|x86.ActiveCfg = Release|x86
|
||||
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|Any CPU.ActiveCfg = Debug|x86
|
||||
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|Any CPU.Build.0 = Debug|x86
|
||||
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
|
||||
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{D61E6ECE-E0B6-4467-B492-F08A06BA8F02}.Debug|x86.Build.0 = Debug|x86
|
||||
|
@ -175,6 +179,16 @@ Global
|
|||
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|Mixed Platforms.Build.0 = Release|Any CPU
|
||||
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|x86.ActiveCfg = Release|x86
|
||||
{9C0ECC4C-7807-4111-916A-4F57BB29788A}.Release|x86.Build.0 = Release|x86
|
||||
{9801F62C-540F-4BFE-9211-6405DEDE563B}.Debug|Any CPU.ActiveCfg = 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|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
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -21,7 +21,6 @@
|
|||
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Security;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -25,7 +25,8 @@ using System.Drawing;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using GreenshotPlugin.UnmanagedHelpers;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Core;
|
||||
using GreenshotPlugin.Effects;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
|
||||
namespace Greenshot.Configuration {
|
||||
/// <summary>
|
||||
|
@ -34,35 +35,35 @@ namespace Greenshot.Configuration {
|
|||
[IniSection("Editor", Description="Greenshot editor configuration")]
|
||||
public class EditorConfiguration : IniSection {
|
||||
[IniProperty("RecentColors", Separator="|", Description="Last used colors")]
|
||||
public List<Color> RecentColors;
|
||||
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;
|
||||
public Dictionary<string, object> LastUsedFieldValues { get; set; }
|
||||
|
||||
[IniProperty("MatchSizeToCapture", Description="Match the editor window size to the capture", DefaultValue="True")]
|
||||
public bool MatchSizeToCapture;
|
||||
public bool MatchSizeToCapture { get; set; }
|
||||
[IniProperty("WindowPlacementFlags", Description="Placement flags", DefaultValue="0")]
|
||||
public WindowPlacementFlags WindowPlacementFlags;
|
||||
public WindowPlacementFlags WindowPlacementFlags { get; set; }
|
||||
[IniProperty("WindowShowCommand", Description="Show command", DefaultValue="Normal")]
|
||||
public ShowWindowCommand ShowWindowCommand;
|
||||
public ShowWindowCommand ShowWindowCommand { get; set; }
|
||||
[IniProperty("WindowMinPosition", Description="Position of minimized window", DefaultValue="-1,-1")]
|
||||
public Point WindowMinPosition;
|
||||
public Point WindowMinPosition { get; set; }
|
||||
[IniProperty("WindowMaxPosition", Description="Position of maximized window", DefaultValue="-1,-1")]
|
||||
public Point WindowMaxPosition;
|
||||
public Point WindowMaxPosition { get; set; }
|
||||
[IniProperty("WindowNormalPosition", Description="Position of normal window", DefaultValue="100,100,400,400")]
|
||||
public Rectangle WindowNormalPosition;
|
||||
public Rectangle WindowNormalPosition { get; set; }
|
||||
[IniProperty("ReuseEditor", Description = "Reuse already open editor", DefaultValue = "false")]
|
||||
public bool ReuseEditor;
|
||||
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;
|
||||
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;
|
||||
public bool SuppressSaveDialogAtClose { get; set; }
|
||||
|
||||
[IniProperty("DropShadowEffectSettings", Description = "Settings for the drop shadow effect.")]
|
||||
public DropShadowEffect DropShadowEffectSettings;
|
||||
public DropShadowEffect DropShadowEffectSettings { get; set; }
|
||||
|
||||
[IniProperty("TornEdgeEffectSettings", Description = "Settings for the torn edge effect.")]
|
||||
public TornEdgeEffect TornEdgeEffectSettings;
|
||||
public TornEdgeEffect TornEdgeEffectSettings { get; set; }
|
||||
|
||||
public override void AfterLoad() {
|
||||
base.AfterLoad();
|
||||
|
@ -73,9 +74,10 @@ namespace Greenshot.Configuration {
|
|||
|
||||
/// <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="scope">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 Field CreateField(Type requestingType, FieldType fieldType, object preferredDefaultValue) {
|
||||
public IField CreateField(Type requestingType, IFieldType fieldType, object preferredDefaultValue)
|
||||
{
|
||||
string requestingTypeName = requestingType.Name;
|
||||
string requestedField = requestingTypeName + "." + fieldType.Name;
|
||||
object fieldValue = preferredDefaultValue;
|
||||
|
@ -97,12 +99,14 @@ namespace Greenshot.Configuration {
|
|||
} else {
|
||||
LastUsedFieldValues.Add(requestedField, fieldValue);
|
||||
}
|
||||
Field returnField = new Field(fieldType, requestingType);
|
||||
returnField.Value = fieldValue;
|
||||
return returnField;
|
||||
return new Field(fieldType, requestingType)
|
||||
{
|
||||
Value = fieldValue
|
||||
};
|
||||
}
|
||||
|
||||
public void UpdateLastFieldValue(Field field) {
|
||||
|
||||
public void UpdateLastFieldValue(IField field)
|
||||
{
|
||||
string requestedField = field.Scope + "." + field.FieldType.Name;
|
||||
// Check if the configuration exists
|
||||
if (LastUsedFieldValues == null) {
|
||||
|
@ -110,12 +114,21 @@ namespace Greenshot.Configuration {
|
|||
}
|
||||
// check if settings for the requesting type exist, if not create!
|
||||
if (LastUsedFieldValues.ContainsKey(requestedField)) {
|
||||
LastUsedFieldValues[requestedField] = field.myValue;
|
||||
LastUsedFieldValues[requestedField] = field.Value;
|
||||
} else {
|
||||
LastUsedFieldValues.Add(requestedField, field.myValue);
|
||||
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);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -19,7 +19,10 @@
|
|||
* 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,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -36,12 +36,14 @@ namespace Greenshot.Controls {
|
|||
set;
|
||||
}
|
||||
|
||||
public BindableToolStripButton() :base() {
|
||||
public BindableToolStripButton()
|
||||
{
|
||||
CheckedChanged += BindableToolStripButton_CheckedChanged;
|
||||
}
|
||||
|
||||
void BindableToolStripButton_CheckedChanged(object sender, EventArgs e) {
|
||||
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Checked"));
|
||||
private void BindableToolStripButton_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Checked"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -36,15 +36,14 @@ namespace Greenshot.Controls {
|
|||
set;
|
||||
}
|
||||
|
||||
public BindableToolStripComboBox() :base() {
|
||||
public BindableToolStripComboBox()
|
||||
{
|
||||
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
if(PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem"));
|
||||
|
||||
}
|
||||
private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedItem"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -38,9 +38,6 @@ namespace Greenshot.Controls {
|
|||
set;
|
||||
}
|
||||
|
||||
public BindableToolStripDropDownButton() {
|
||||
}
|
||||
|
||||
public object SelectedTag {
|
||||
get { if(Tag==null && DropDownItems.Count>0) Tag=DropDownItems[0].Tag; return Tag; }
|
||||
set { AdoptFromTag(value); }
|
||||
|
@ -51,7 +48,7 @@ namespace Greenshot.Controls {
|
|||
if(Tag == null || !Tag.Equals(clickedItem.Tag)) {
|
||||
Tag = clickedItem.Tag;
|
||||
Image = clickedItem.Image;
|
||||
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SelectedTag"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedTag"));
|
||||
}
|
||||
base.OnDropDownItemClicked(e);
|
||||
}
|
||||
|
@ -66,7 +63,7 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
Tag = tag;
|
||||
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SelectedTag"));
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedTag"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -31,7 +31,7 @@ namespace Greenshot.Controls {
|
|||
/// </summary>
|
||||
public class ColorButton : Button, IGreenshotLanguageBindable {
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
private Color selectedColor = Color.White;
|
||||
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 {
|
||||
|
@ -44,9 +44,9 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
|
||||
public Color SelectedColor {
|
||||
get {return selectedColor;}
|
||||
get {return _selectedColor;}
|
||||
set {
|
||||
selectedColor = value;
|
||||
_selectedColor = value;
|
||||
|
||||
Brush brush;
|
||||
if(value != Color.Transparent) {
|
||||
|
@ -67,19 +67,21 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
|
||||
void ColorButtonClick(object sender, EventArgs e) {
|
||||
private void ColorButtonClick(object sender, EventArgs e) {
|
||||
ColorDialog colorDialog = ColorDialog.GetInstance();
|
||||
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) {
|
||||
if (!colorDialog.Color.Equals(SelectedColor)) {
|
||||
SelectedColor = colorDialog.Color;
|
||||
if(PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
}
|
||||
}
|
||||
if (colorDialog.DialogResult == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (colorDialog.Color.Equals(SelectedColor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectedColor = colorDialog.Color;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -22,7 +22,6 @@
|
|||
using Greenshot.IniFile;
|
||||
using GreenshotPlugin.Core;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Greenshot.Controls {
|
||||
|
@ -30,18 +29,16 @@ namespace Greenshot.Controls {
|
|||
/// ToolStripProfessionalRenderer which draws the Check correctly when the icons are larger
|
||||
/// </summary>
|
||||
public class ContextMenuToolStripProfessionalRenderer : ToolStripProfessionalRenderer {
|
||||
private static CoreConfiguration coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static Image scaledCheckbox;
|
||||
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static Image _scaledCheckbox;
|
||||
|
||||
protected override void OnRenderItemCheck(ToolStripItemImageRenderEventArgs e) {
|
||||
if (scaledCheckbox == null || scaledCheckbox.Size != coreConfiguration.IconSize) {
|
||||
if (scaledCheckbox != null) {
|
||||
scaledCheckbox.Dispose();
|
||||
}
|
||||
scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, coreConfiguration.IconSize.Width, coreConfiguration.IconSize.Height, null);
|
||||
if (_scaledCheckbox == null || _scaledCheckbox.Size != CoreConfig.IconSize) {
|
||||
_scaledCheckbox?.Dispose();
|
||||
_scaledCheckbox = ImageHelper.ResizeImage(e.Image, true, CoreConfig.IconSize.Width, CoreConfig.IconSize.Height, null);
|
||||
}
|
||||
Rectangle old = e.ImageRectangle;
|
||||
ToolStripItemImageRenderEventArgs clone = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, scaledCheckbox, new Rectangle(old.X, 0, old.Width, old.Height));
|
||||
ToolStripItemImageRenderEventArgs clone = new ToolStripItemImageRenderEventArgs(e.Graphics, e.Item, _scaledCheckbox, new Rectangle(old.X, 0, old.Width, old.Height));
|
||||
base.OnRenderItemCheck(clone);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -41,15 +41,19 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
|
||||
public FontFamilyComboBox() : base() {
|
||||
ComboBox.DataSource = FontFamily.Families;
|
||||
ComboBox.DisplayMember = "Name";
|
||||
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
|
||||
ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
|
||||
ComboBox.DrawItem += ComboBox_DrawItem;
|
||||
public FontFamilyComboBox()
|
||||
{
|
||||
if (ComboBox != null)
|
||||
{
|
||||
ComboBox.DataSource = FontFamily.Families;
|
||||
ComboBox.DisplayMember = "Name";
|
||||
SelectedIndexChanged += BindableToolStripComboBox_SelectedIndexChanged;
|
||||
ComboBox.DrawMode = DrawMode.OwnerDrawFixed;
|
||||
ComboBox.DrawItem += ComboBox_DrawItem;
|
||||
}
|
||||
}
|
||||
|
||||
void ComboBox_DrawItem(object sender, DrawItemEventArgs e) {
|
||||
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 );
|
||||
|
@ -58,7 +62,7 @@ namespace Greenshot.Controls {
|
|||
if (e.Index > -1) {
|
||||
FontFamily fontFamily = Items[e.Index] as FontFamily;
|
||||
FontStyle fontStyle = FontStyle.Regular;
|
||||
if (!fontFamily.IsStyleAvailable(FontStyle.Regular)) {
|
||||
if (fontFamily != null && !fontFamily.IsStyleAvailable(FontStyle.Regular)) {
|
||||
if (fontFamily.IsStyleAvailable(FontStyle.Bold)) {
|
||||
fontStyle = FontStyle.Bold;
|
||||
} else if (fontFamily.IsStyleAvailable(FontStyle.Italic)) {
|
||||
|
@ -70,10 +74,16 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
try {
|
||||
DrawText(e.Graphics, fontFamily, fontStyle, e.Bounds, fontFamily.Name);
|
||||
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'
|
||||
DrawText(e.Graphics, FontFamily.GenericSansSerif, FontStyle.Regular, e.Bounds, fontFamily.Name);
|
||||
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
|
||||
|
@ -89,7 +99,7 @@ namespace Greenshot.Controls {
|
|||
/// <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, this.Font.Size + 5, fontStyle, GraphicsUnit.Pixel)) {
|
||||
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()) {
|
||||
stringFormat.LineAlignment = StringAlignment.Center;
|
||||
|
@ -98,7 +108,7 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
|
||||
void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
private void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
if (PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("Text"));
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("FontFamily"));
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -29,14 +29,12 @@ namespace Greenshot.Controls {
|
|||
public class MenuStripEx : MenuStrip {
|
||||
private const int WM_MOUSEACTIVATE = 0x21;
|
||||
|
||||
enum NativeConstants : uint {
|
||||
private enum NativeConstants : uint {
|
||||
MA_ACTIVATE = 1,
|
||||
MA_ACTIVATEANDEAT = 2,
|
||||
MA_NOACTIVATE = 3,
|
||||
MA_NOACTIVATEANDEAT = 4,
|
||||
}
|
||||
|
||||
private bool clickThrough = false;
|
||||
private bool _clickThrough;
|
||||
/// <summary>
|
||||
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does not have input focus.
|
||||
/// </summary>
|
||||
|
@ -45,17 +43,17 @@ namespace Greenshot.Controls {
|
|||
/// </remarks>
|
||||
public bool ClickThrough {
|
||||
get {
|
||||
return clickThrough;
|
||||
return _clickThrough;
|
||||
}
|
||||
|
||||
set {
|
||||
clickThrough = value;
|
||||
_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) {
|
||||
if (_clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) {
|
||||
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -19,19 +19,36 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// See: http://nickstips.wordpress.com/2010/03/03/c-panel-resets-scroll-position-after-focus-is-lost-and-regained/
|
||||
/// </summary>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -30,22 +30,22 @@ namespace Greenshot.Controls {
|
|||
/// This code was supplied by Hi-Coder as a patch for Greenshot
|
||||
/// Needed some modifications to be stable.
|
||||
/// </summary>
|
||||
public class Pipette : Label, IMessageFilter, IDisposable {
|
||||
private MovableShowColorForm movableShowColorForm;
|
||||
private bool dragging;
|
||||
public sealed class Pipette : Label, IMessageFilter, IDisposable {
|
||||
private MovableShowColorForm _movableShowColorForm;
|
||||
private bool _dragging;
|
||||
private Cursor _cursor;
|
||||
private Bitmap _image;
|
||||
private const int VK_ESC = 27;
|
||||
private readonly Bitmap _image;
|
||||
private const int VkEsc = 27;
|
||||
|
||||
public event EventHandler<PipetteUsedArgs> PipetteUsed;
|
||||
|
||||
public Pipette() {
|
||||
BorderStyle = BorderStyle.FixedSingle;
|
||||
dragging = false;
|
||||
_dragging = false;
|
||||
_image = (Bitmap)new ComponentResourceManager(typeof(ColorDialog)).GetObject("pipette.Image");
|
||||
Image = _image;
|
||||
_cursor = CreateCursor((Bitmap)_image, 1, 14);
|
||||
movableShowColorForm = new MovableShowColorForm();
|
||||
_cursor = CreateCursor(_image, 1, 14);
|
||||
_movableShowColorForm = new MovableShowColorForm();
|
||||
Application.AddMessageFilter(this);
|
||||
}
|
||||
|
||||
|
@ -58,13 +58,12 @@ namespace Greenshot.Controls {
|
|||
/// <returns>Cursor</returns>
|
||||
private static Cursor CreateCursor(Bitmap bitmap, int hotspotX, int hotspotY) {
|
||||
using (SafeIconHandle iconHandle = new SafeIconHandle( bitmap.GetHicon())) {
|
||||
IntPtr icon;
|
||||
IconInfo iconInfo = new IconInfo();
|
||||
IconInfo iconInfo;
|
||||
User32.GetIconInfo(iconHandle, out iconInfo);
|
||||
iconInfo.xHotspot = hotspotX;
|
||||
iconInfo.yHotspot = hotspotY;
|
||||
iconInfo.fIcon = false;
|
||||
icon = User32.CreateIconIndirect(ref iconInfo);
|
||||
var icon = User32.CreateIconIndirect(ref iconInfo);
|
||||
return new Cursor(icon);
|
||||
}
|
||||
}
|
||||
|
@ -85,11 +84,9 @@ namespace Greenshot.Controls {
|
|||
if (_cursor != null) {
|
||||
_cursor.Dispose();
|
||||
}
|
||||
if (movableShowColorForm != null) {
|
||||
movableShowColorForm.Dispose();
|
||||
}
|
||||
_movableShowColorForm?.Dispose();
|
||||
}
|
||||
movableShowColorForm = null;
|
||||
_movableShowColorForm = null;
|
||||
_cursor = null;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
@ -101,7 +98,7 @@ namespace Greenshot.Controls {
|
|||
protected override void OnMouseDown(MouseEventArgs e) {
|
||||
if (e.Button == MouseButtons.Left) {
|
||||
User32.SetCapture(Handle);
|
||||
movableShowColorForm.MoveTo(PointToScreen(new Point(e.X, e.Y)));
|
||||
_movableShowColorForm.MoveTo(PointToScreen(new Point(e.X, e.Y)));
|
||||
}
|
||||
base.OnMouseDown(e);
|
||||
}
|
||||
|
@ -111,10 +108,11 @@ namespace Greenshot.Controls {
|
|||
/// </summary>
|
||||
/// <param name="e">MouseEventArgs</param>
|
||||
protected override void OnMouseUp(MouseEventArgs e) {
|
||||
if (e.Button == MouseButtons.Left) {
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
//Release Capture should consume MouseUp when canceled with the escape key
|
||||
User32.ReleaseCapture();
|
||||
PipetteUsed(this, new PipetteUsedArgs(movableShowColorForm.color));
|
||||
PipetteUsed?.Invoke(this, new PipetteUsedArgs(_movableShowColorForm.color));
|
||||
}
|
||||
base.OnMouseUp(e);
|
||||
}
|
||||
|
@ -124,10 +122,10 @@ namespace Greenshot.Controls {
|
|||
/// </summary>
|
||||
/// <param name="e">MouseEventArgs</param>
|
||||
protected override void OnMouseMove(MouseEventArgs e) {
|
||||
if (dragging) {
|
||||
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);
|
||||
_movableShowColorForm.MoveTo(zp);
|
||||
}
|
||||
base.OnMouseMove(e);
|
||||
}
|
||||
|
@ -138,16 +136,16 @@ namespace Greenshot.Controls {
|
|||
/// <param name="e"></param>
|
||||
protected override void OnMouseCaptureChanged(EventArgs e) {
|
||||
if (Capture) {
|
||||
dragging = true;
|
||||
_dragging = true;
|
||||
Image = null;
|
||||
Cursor c = _cursor;
|
||||
Cursor = c;
|
||||
movableShowColorForm.Visible = true;
|
||||
_movableShowColorForm.Visible = true;
|
||||
} else {
|
||||
dragging = false;
|
||||
_dragging = false;
|
||||
Image = _image;
|
||||
Cursor = Cursors.Arrow;
|
||||
movableShowColorForm.Visible = false;
|
||||
_movableShowColorForm.Visible = false;
|
||||
}
|
||||
Update();
|
||||
base.OnMouseCaptureChanged(e);
|
||||
|
@ -156,9 +154,9 @@ namespace Greenshot.Controls {
|
|||
#region IMessageFilter Members
|
||||
|
||||
public bool PreFilterMessage(ref Message m) {
|
||||
if (dragging) {
|
||||
if (_dragging) {
|
||||
if (m.Msg == (int)WindowsMessages.WM_CHAR) {
|
||||
if ((int)m.WParam == VK_ESC) {
|
||||
if ((int)m.WParam == VkEsc) {
|
||||
User32.ReleaseCapture();
|
||||
}
|
||||
}
|
||||
|
@ -170,10 +168,10 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
|
||||
public class PipetteUsedArgs : EventArgs {
|
||||
public Color color;
|
||||
public Color Color;
|
||||
|
||||
public PipetteUsedArgs(Color c) {
|
||||
color = c;
|
||||
Color = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -35,16 +35,16 @@ namespace Greenshot.Controls {
|
|||
set;
|
||||
}
|
||||
|
||||
private Color selectedColor = Color.Transparent;
|
||||
private Color _selectedColor = Color.Transparent;
|
||||
|
||||
public ToolStripColorButton() {
|
||||
Click+= ColorButtonClick;
|
||||
}
|
||||
|
||||
public Color SelectedColor {
|
||||
get {return selectedColor;}
|
||||
get {return _selectedColor;}
|
||||
set {
|
||||
selectedColor = value;
|
||||
_selectedColor = value;
|
||||
|
||||
Brush brush;
|
||||
if(value != Color.Transparent) {
|
||||
|
@ -65,19 +65,21 @@ namespace Greenshot.Controls {
|
|||
}
|
||||
}
|
||||
|
||||
void ColorButtonClick(object sender, EventArgs e) {
|
||||
private void ColorButtonClick(object sender, EventArgs e) {
|
||||
ColorDialog colorDialog = ColorDialog.GetInstance();
|
||||
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) {
|
||||
if (!colorDialog.Color.Equals(SelectedColor)) {
|
||||
SelectedColor = colorDialog.Color;
|
||||
if (PropertyChanged != null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
}
|
||||
}
|
||||
if (colorDialog.DialogResult == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (colorDialog.Color.Equals(SelectedColor))
|
||||
{
|
||||
return;
|
||||
}
|
||||
SelectedColor = colorDialog.Color;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("SelectedColor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -26,17 +26,15 @@ namespace Greenshot.Controls {
|
|||
/// 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>
|
||||
class ToolStripEx : ToolStrip {
|
||||
internal class ToolStripEx : ToolStrip {
|
||||
private const int WM_MOUSEACTIVATE = 0x21;
|
||||
|
||||
enum NativeConstants : uint {
|
||||
private enum NativeConstants : uint {
|
||||
MA_ACTIVATE = 1,
|
||||
MA_ACTIVATEANDEAT = 2,
|
||||
MA_NOACTIVATE = 3,
|
||||
MA_NOACTIVATEANDEAT = 4,
|
||||
}
|
||||
|
||||
private bool clickThrough = false;
|
||||
private bool _clickThrough;
|
||||
/// <summary>
|
||||
/// Gets or sets whether the ToolStripEx honors item clicks when its containing form does not have input focus.
|
||||
/// </summary>
|
||||
|
@ -46,17 +44,17 @@ namespace Greenshot.Controls {
|
|||
|
||||
public bool ClickThrough {
|
||||
get {
|
||||
return clickThrough;
|
||||
return _clickThrough;
|
||||
}
|
||||
|
||||
set {
|
||||
clickThrough = value;
|
||||
_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) {
|
||||
if (_clickThrough && m.Msg == WM_MOUSEACTIVATE && m.Result == (IntPtr)NativeConstants.MA_ACTIVATEANDEAT) {
|
||||
m.Result = (IntPtr)NativeConstants.MA_ACTIVATE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -34,16 +34,13 @@ namespace Greenshot.Controls {
|
|||
{
|
||||
}
|
||||
|
||||
public NumericUpDown NumericUpDown
|
||||
{
|
||||
get {return Control as NumericUpDown;}
|
||||
}
|
||||
|
||||
public NumericUpDown NumericUpDown => Control as NumericUpDown;
|
||||
|
||||
public decimal Value
|
||||
{
|
||||
get { return NumericUpDown.Value; }
|
||||
set { NumericUpDown.Value = value;}
|
||||
}
|
||||
{
|
||||
get { return NumericUpDown.Value; }
|
||||
set { NumericUpDown.Value = value;}
|
||||
}
|
||||
public decimal Minimum {
|
||||
get { return NumericUpDown.Minimum; }
|
||||
set { NumericUpDown.Minimum = value; }
|
||||
|
@ -74,8 +71,9 @@ namespace Greenshot.Controls {
|
|||
NumericUpDown.ValueChanged -= _valueChanged;
|
||||
}
|
||||
|
||||
private void _valueChanged(object sender, EventArgs e) {
|
||||
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Value"));
|
||||
private void _valueChanged(object sender, EventArgs e)
|
||||
{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -25,16 +25,12 @@ using System.Windows.Forms;
|
|||
using Greenshot.Configuration;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.IniFile;
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Destinations {
|
||||
/// <summary>
|
||||
/// Description of ClipboardDestination.
|
||||
/// </summary>
|
||||
public class ClipboardDestination : AbstractDestination {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(ClipboardDestination));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
public const string DESIGNATION = "Clipboard";
|
||||
|
||||
public override string Designation {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -32,11 +32,11 @@ namespace Greenshot.Destinations {
|
|||
/// Description of EditorDestination.
|
||||
/// </summary>
|
||||
public class EditorDestination : AbstractDestination {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(EditorDestination));
|
||||
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(EditorDestination));
|
||||
private static readonly EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
public const string DESIGNATION = "Editor";
|
||||
private IImageEditor editor = null;
|
||||
private static Image greenshotIcon = GreenshotResources.getGreenshotIcon().ToBitmap();
|
||||
private readonly IImageEditor editor;
|
||||
private static readonly Image greenshotIcon = GreenshotResources.getGreenshotIcon().ToBitmap();
|
||||
|
||||
public EditorDestination() {
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ namespace Greenshot.Destinations {
|
|||
}
|
||||
}
|
||||
|
||||
public override bool isDynamic {
|
||||
public override bool IsDynamic {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
|
@ -79,8 +79,8 @@ namespace Greenshot.Destinations {
|
|||
}
|
||||
|
||||
public override IEnumerable<IDestination> DynamicDestinations() {
|
||||
foreach (IImageEditor editor in ImageEditorForm.Editors) {
|
||||
yield return new EditorDestination(editor);
|
||||
foreach (IImageEditor someEditor in ImageEditorForm.Editors) {
|
||||
yield return new EditorDestination(someEditor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -26,87 +26,63 @@ using Greenshot.Configuration;
|
|||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Destinations {
|
||||
/// <summary>
|
||||
/// Description of EmailDestination.
|
||||
/// </summary>
|
||||
public class EmailDestination : AbstractDestination {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(EmailDestination));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static Image mailIcon = GreenshotResources.getImage("Email.Image");
|
||||
private static bool isActiveFlag = false;
|
||||
private static string mapiClient = null;
|
||||
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()) {
|
||||
isActiveFlag = true;
|
||||
mapiClient = EmailConfigHelper.GetMapiClient();
|
||||
if (!string.IsNullOrEmpty(mapiClient)) {
|
||||
if (EmailConfigHelper.HasMapi()) {
|
||||
_isActiveFlag = true;
|
||||
_mapiClient = EmailConfigHelper.GetMapiClient();
|
||||
if (!string.IsNullOrEmpty(_mapiClient)) {
|
||||
// Active as we have a mapi client, can be disabled later
|
||||
isActiveFlag = true;
|
||||
_isActiveFlag = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public EmailDestination() {
|
||||
|
||||
}
|
||||
|
||||
public override string Designation {
|
||||
get {
|
||||
return DESIGNATION;
|
||||
}
|
||||
}
|
||||
public override string Designation => DESIGNATION;
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
// Make sure there is some kind of "mail" name
|
||||
if (mapiClient == null) {
|
||||
mapiClient = Language.GetString(LangKey.editor_email);
|
||||
if (_mapiClient == null) {
|
||||
_mapiClient = Language.GetString(LangKey.editor_email);
|
||||
}
|
||||
return mapiClient;
|
||||
return _mapiClient;
|
||||
}
|
||||
}
|
||||
|
||||
public override int Priority {
|
||||
get {
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
public override int Priority => 3;
|
||||
|
||||
public override bool isActive {
|
||||
public override bool IsActive {
|
||||
get {
|
||||
if (isActiveFlag) {
|
||||
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;
|
||||
if (_mapiClient.ToLower().Contains("microsoft outlook")) {
|
||||
_isActiveFlag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return base.isActive && isActiveFlag;
|
||||
return base.IsActive && _isActiveFlag;
|
||||
}
|
||||
}
|
||||
|
||||
public override Keys EditorShortcutKeys {
|
||||
get {
|
||||
return Keys.Control | Keys.E;
|
||||
}
|
||||
}
|
||||
public override Keys EditorShortcutKeys => Keys.Control | Keys.E;
|
||||
|
||||
public override Image DisplayIcon => MailIcon;
|
||||
|
||||
public override Image DisplayIcon {
|
||||
get {
|
||||
return mailIcon;
|
||||
}
|
||||
}
|
||||
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
MapiMailMessage.SendImage(surface, captureDetails);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -35,60 +35,40 @@ namespace Greenshot.Destinations {
|
|||
/// Description of FileSaveAsDestination.
|
||||
/// </summary>
|
||||
public class FileDestination : AbstractDestination {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(FileDestination));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
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 {
|
||||
get {
|
||||
return DESIGNATION;
|
||||
}
|
||||
}
|
||||
public override string Designation => DESIGNATION;
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
return Language.GetString(LangKey.quicksettings_destination_file);
|
||||
}
|
||||
}
|
||||
public override string Description => Language.GetString(LangKey.quicksettings_destination_file);
|
||||
|
||||
public override int Priority {
|
||||
get {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
public override int Priority => 0;
|
||||
|
||||
public override Keys EditorShortcutKeys {
|
||||
get {
|
||||
return Keys.Control | Keys.S;
|
||||
}
|
||||
}
|
||||
|
||||
public override Image DisplayIcon {
|
||||
get {
|
||||
return GreenshotResources.getImage("Save.Image");
|
||||
}
|
||||
}
|
||||
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;
|
||||
bool overwrite;
|
||||
string fullPath;
|
||||
// Get output settings from the configuration
|
||||
SurfaceOutputSettings outputSettings = new SurfaceOutputSettings();
|
||||
|
||||
if (captureDetails != null && captureDetails.Filename != null) {
|
||||
// As we save a pre-selected file, allow to overwrite.
|
||||
overwrite = true;
|
||||
LOG.InfoFormat("Using previous filename");
|
||||
fullPath = captureDetails.Filename;
|
||||
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 = conf.OutputFileAllowOverwrite;
|
||||
}
|
||||
if (conf.OutputFilePromptQuality) {
|
||||
} 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();
|
||||
}
|
||||
|
@ -96,28 +76,31 @@ namespace Greenshot.Destinations {
|
|||
// 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, conf.OutputFileCopyPathToClipboard);
|
||||
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);
|
||||
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);
|
||||
outputMade = fullPath != null;
|
||||
} catch (Exception ex2) {
|
||||
LOG.Error("Error saving screenshot!", 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);
|
||||
outputMade = fullPath != null;
|
||||
}
|
||||
// Don't overwrite filename if no output is made
|
||||
if (outputMade) {
|
||||
exportInformation.ExportMade = outputMade;
|
||||
exportInformation.ExportMade = true;
|
||||
exportInformation.Filepath = fullPath;
|
||||
captureDetails.Filename = fullPath;
|
||||
conf.OutputFileAsFullpath = fullPath;
|
||||
if (captureDetails != null)
|
||||
{
|
||||
captureDetails.Filename = fullPath;
|
||||
}
|
||||
CoreConfig.OutputFileAsFullpath = fullPath;
|
||||
}
|
||||
|
||||
ProcessExport(exportInformation, surface);
|
||||
|
@ -126,18 +109,18 @@ namespace Greenshot.Destinations {
|
|||
|
||||
private static string CreateNewFilename(ICaptureDetails captureDetails) {
|
||||
string fullPath;
|
||||
LOG.InfoFormat("Creating new filename");
|
||||
string pattern = conf.OutputFileFilenamePattern;
|
||||
Log.InfoFormat("Creating new filename");
|
||||
string pattern = CoreConfig.OutputFileFilenamePattern;
|
||||
if (string.IsNullOrEmpty(pattern)) {
|
||||
pattern = "greenshot ${capturetime}";
|
||||
}
|
||||
string filename = FilenameHelper.GetFilenameFromPattern(pattern, conf.OutputFileFormat, captureDetails);
|
||||
string filepath = FilenameHelper.FillVariables(conf.OutputFilePath, false);
|
||||
string filename = FilenameHelper.GetFilenameFromPattern(pattern, CoreConfig.OutputFileFormat, captureDetails);
|
||||
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);
|
||||
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....
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -26,15 +26,13 @@ using Greenshot.Configuration;
|
|||
using GreenshotPlugin.Core;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.IniFile;
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Destinations {
|
||||
/// <summary>
|
||||
/// Description of FileWithDialog.
|
||||
/// </summary>
|
||||
public class FileWithDialogDestination : AbstractDestination {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(FileWithDialogDestination));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
public const string DESIGNATION = "FileDialog";
|
||||
|
||||
public override string Designation {
|
||||
|
@ -69,9 +67,8 @@ namespace Greenshot.Destinations {
|
|||
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
string savedTo = null;
|
||||
// Bug #2918756 don't overwrite path if SaveWithDialog returns null!
|
||||
savedTo = ImageOutput.SaveWithDialog(surface, captureDetails);
|
||||
var savedTo = ImageOutput.SaveWithDialog(surface, captureDetails);
|
||||
if (savedTo != null) {
|
||||
exportInformation.ExportMade = true;
|
||||
exportInformation.Filepath = savedTo;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -24,36 +24,20 @@ using Greenshot.Configuration;
|
|||
using GreenshotPlugin.Core;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.IniFile;
|
||||
using log4net;
|
||||
|
||||
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 {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(PickerDestination));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
public const string DESIGNATION = "Picker";
|
||||
|
||||
public override string Designation {
|
||||
get {
|
||||
return DESIGNATION;
|
||||
}
|
||||
}
|
||||
public override string Designation => DESIGNATION;
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
return Language.GetString(LangKey.settings_destination_picker);
|
||||
}
|
||||
}
|
||||
public override string Description => Language.GetString(LangKey.settings_destination_picker);
|
||||
|
||||
public override int Priority => 1;
|
||||
|
||||
public override int Priority {
|
||||
get {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Export the capture with the destination picker
|
||||
|
@ -68,7 +52,7 @@ namespace Greenshot.Destinations {
|
|||
if ("Picker".Equals(destination.Designation)) {
|
||||
continue;
|
||||
}
|
||||
if (!destination.isActive) {
|
||||
if (!destination.IsActive) {
|
||||
continue;
|
||||
}
|
||||
destinations.Add(destination);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -28,18 +28,14 @@ using Greenshot.Configuration;
|
|||
using GreenshotPlugin.Core;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.IniFile;
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Destinations {
|
||||
/// <summary>
|
||||
/// Description of PrinterDestination.
|
||||
/// </summary>
|
||||
public class PrinterDestination : AbstractDestination {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(PrinterDestination));
|
||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
public const string DESIGNATION = "Printer";
|
||||
public string printerName = null;
|
||||
public readonly string printerName;
|
||||
|
||||
public PrinterDestination() {
|
||||
}
|
||||
|
@ -80,7 +76,7 @@ namespace Greenshot.Destinations {
|
|||
}
|
||||
}
|
||||
|
||||
public override bool isDynamic {
|
||||
public override bool IsDynamic {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
|
@ -89,7 +85,7 @@ namespace Greenshot.Destinations {
|
|||
/// <summary>
|
||||
/// Create destinations for all the installed printers
|
||||
/// </summary>
|
||||
/// <returns>IEnumerable<IDestination></returns>
|
||||
/// <returns>IEnumerable of IDestination</returns>
|
||||
public override IEnumerable<IDestination> DynamicDestinations() {
|
||||
PrinterSettings settings = new PrinterSettings();
|
||||
string defaultPrinter = settings.PrinterName;
|
||||
|
@ -121,7 +117,7 @@ namespace Greenshot.Destinations {
|
|||
/// <returns>ExportInformation</returns>
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(Designation, Description);
|
||||
PrinterSettings printerSettings = null;
|
||||
PrinterSettings printerSettings;
|
||||
if (!string.IsNullOrEmpty(printerName)) {
|
||||
using (PrintHelper printHelper = new PrintHelper(surface, captureDetails)) {
|
||||
printerSettings = printHelper.PrintTo(printerName);
|
||||
|
|
146
Greenshot/Drawing/Adorners/AbstractAdorner.cs
Normal file
146
Greenshot/Drawing/Adorners/AbstractAdorner.cs
Normal file
|
@ -0,0 +1,146 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 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.Plugin.Drawing;
|
||||
using Greenshot.Plugin.Drawing.Adorners;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
164
Greenshot/Drawing/Adorners/MoveAdorner.cs
Normal file
164
Greenshot/Drawing/Adorners/MoveAdorner.cs
Normal file
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 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 Greenshot.Plugin.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
184
Greenshot/Drawing/Adorners/ResizeAdorner.cs
Normal file
184
Greenshot/Drawing/Adorners/ResizeAdorner.cs
Normal file
|
@ -0,0 +1,184 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 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 Greenshot.Plugin.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
118
Greenshot/Drawing/Adorners/TargetAdorner.cs
Normal file
118
Greenshot/Drawing/Adorners/TargetAdorner.cs
Normal file
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 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.Plugin.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
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];
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -79,7 +79,7 @@ namespace Greenshot.Drawing {
|
|||
Top + currentStep + Height);
|
||||
|
||||
currentStep++;
|
||||
alpha = alpha - (basealpha / steps);
|
||||
alpha = alpha - basealpha / steps;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -20,9 +20,11 @@
|
|||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -30,27 +32,38 @@ namespace Greenshot.Drawing {
|
|||
/// </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, FieldType.Flag.CONFIRMABLE);
|
||||
AddField(GetType(), FieldType.FLAGS, FieldFlag.CONFIRMABLE);
|
||||
}
|
||||
|
||||
public override void Invalidate() {
|
||||
_parent.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 {
|
||||
get {
|
||||
return new Rectangle(0,0,_parent.Width, _parent.Height);
|
||||
}
|
||||
}
|
||||
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);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -26,6 +26,7 @@ using System.Windows.Forms;
|
|||
using Greenshot.Plugin.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using log4net;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -33,14 +34,26 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
[Serializable]
|
||||
public class CursorContainer : DrawableContainer, ICursorContainer {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(CursorContainer));
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(CursorContainer));
|
||||
|
||||
protected Cursor cursor;
|
||||
|
||||
public CursorContainer(Surface parent) : base(parent) {
|
||||
Init();
|
||||
}
|
||||
|
||||
public CursorContainer(Surface parent, string filename) : base(parent) {
|
||||
protected override void OnDeserialized(StreamingContext streamingContext)
|
||||
{
|
||||
base.OnDeserialized(streamingContext);
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
public CursorContainer(Surface parent, string filename) : this(parent) {
|
||||
Load(filename);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Drawing.Adorners;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Drawing.Filters;
|
||||
using Greenshot.Helpers;
|
||||
|
@ -27,15 +28,19 @@ using Greenshot.IniFile;
|
|||
using Greenshot.Memento;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using Greenshot.Plugin.Drawing.Adorners;
|
||||
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;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
namespace Greenshot.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// represents a rectangle, ellipse, label or whatever. Can contain filters, too.
|
||||
/// serializable for clipboard support
|
||||
|
@ -46,12 +51,23 @@ namespace Greenshot.Drawing {
|
|||
public abstract class DrawableContainer : AbstractFieldHolderWithChildren, IDrawableContainer {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(DrawableContainer));
|
||||
protected static readonly EditorConfiguration EditorConfig = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
private bool isMadeUndoable;
|
||||
private const int M11 = 0;
|
||||
private const int M12 = 1;
|
||||
private const int M21 = 2;
|
||||
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 {
|
||||
|
@ -73,19 +89,7 @@ namespace Greenshot.Drawing {
|
|||
if (!disposing) {
|
||||
return;
|
||||
}
|
||||
if (_grippers != null) {
|
||||
for (int i = 0; i < _grippers.Length; i++) {
|
||||
if (_grippers[i] == null) {
|
||||
continue;
|
||||
}
|
||||
_grippers[i].Dispose();
|
||||
_grippers[i] = null;
|
||||
}
|
||||
_grippers = null;
|
||||
}
|
||||
|
||||
FieldAggregator aggProps = _parent.FieldAggregator;
|
||||
aggProps.UnbindElement(this);
|
||||
_parent?.FieldAggregator?.UnbindElement(this);
|
||||
}
|
||||
|
||||
~DrawableContainer() {
|
||||
|
@ -99,7 +103,7 @@ namespace Greenshot.Drawing {
|
|||
remove{ _propertyChanged -= value; }
|
||||
}
|
||||
|
||||
public List<IFilter> Filters {
|
||||
public IList<IFilter> Filters {
|
||||
get {
|
||||
List<IFilter> ret = new List<IFilter>();
|
||||
foreach(IFieldHolder c in Children) {
|
||||
|
@ -117,16 +121,12 @@ namespace Greenshot.Drawing {
|
|||
get { return _parent; }
|
||||
set { SwitchParent((Surface)value); }
|
||||
}
|
||||
[NonSerialized]
|
||||
protected Gripper[] _grippers;
|
||||
private bool layoutSuspended;
|
||||
|
||||
[NonSerialized]
|
||||
private Gripper _targetGripper;
|
||||
|
||||
public Gripper TargetGripper {
|
||||
private TargetAdorner _targetAdorner;
|
||||
public TargetAdorner TargetAdorner {
|
||||
get {
|
||||
return _targetGripper;
|
||||
return _targetAdorner;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,6 @@ namespace Greenshot.Drawing {
|
|||
return;
|
||||
}
|
||||
left = value;
|
||||
DoLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -172,7 +171,6 @@ namespace Greenshot.Drawing {
|
|||
return;
|
||||
}
|
||||
top = value;
|
||||
DoLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -184,7 +182,6 @@ namespace Greenshot.Drawing {
|
|||
return;
|
||||
}
|
||||
width = value;
|
||||
DoLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -196,7 +193,6 @@ namespace Greenshot.Drawing {
|
|||
return;
|
||||
}
|
||||
height = value;
|
||||
DoLayout();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,6 +216,19 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
|
@ -248,7 +257,6 @@ namespace Greenshot.Drawing {
|
|||
public DrawableContainer(Surface parent) {
|
||||
InitializeFields();
|
||||
_parent = parent;
|
||||
InitControls();
|
||||
}
|
||||
|
||||
public void Add(IFilter filter) {
|
||||
|
@ -291,12 +299,15 @@ namespace Greenshot.Drawing {
|
|||
|
||||
public virtual void Invalidate() {
|
||||
if (Status != EditStatus.UNDRAWN) {
|
||||
_parent.Invalidate(DrawingBounds);
|
||||
_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;
|
||||
|
@ -322,188 +333,35 @@ namespace Greenshot.Drawing {
|
|||
public virtual bool InitContent() { return true; }
|
||||
|
||||
public virtual void OnDoubleClick() {}
|
||||
|
||||
private void InitControls() {
|
||||
InitGrippers();
|
||||
|
||||
DoLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Move the TargetGripper around, confined to the surface to solve BUG-1682
|
||||
/// </summary>
|
||||
/// <param name="newX"></param>
|
||||
/// <param name="newY"></param>
|
||||
protected virtual void TargetGripperMove(int newX, int newY) {
|
||||
Point newGripperLocation = new Point(newX, newY);
|
||||
Rectangle surfaceBounds = new Rectangle(0, 0, _parent.Width, _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;
|
||||
}
|
||||
}
|
||||
|
||||
_targetGripper.Left = newGripperLocation.X;
|
||||
_targetGripper.Top = newGripperLocation.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialize a target gripper
|
||||
/// </summary>
|
||||
protected void InitTargetGripper(Color gripperColor, Point location) {
|
||||
_targetGripper = new Gripper {
|
||||
Cursor = Cursors.SizeAll,
|
||||
BackColor = gripperColor,
|
||||
Visible = false,
|
||||
Parent = _parent,
|
||||
Location = location
|
||||
};
|
||||
_targetGripper.MouseDown += GripperMouseDown;
|
||||
_targetGripper.MouseUp += GripperMouseUp;
|
||||
_targetGripper.MouseMove += GripperMouseMove;
|
||||
if (_parent != null) {
|
||||
_parent.Controls.Add(_targetGripper); // otherwise we'll attach them in switchParent
|
||||
}
|
||||
protected void InitAdorner(Color gripperColor, Point location) {
|
||||
_targetAdorner = new TargetAdorner(this, location);
|
||||
Adorners.Add(_targetAdorner);
|
||||
}
|
||||
|
||||
protected void InitGrippers() {
|
||||
|
||||
_grippers = new Gripper[8];
|
||||
for(int i=0; i<_grippers.Length; i++) {
|
||||
_grippers[i] = new Gripper();
|
||||
_grippers[i].Position = i;
|
||||
_grippers[i].MouseDown += GripperMouseDown;
|
||||
_grippers[i].MouseUp += GripperMouseUp;
|
||||
_grippers[i].MouseMove += GripperMouseMove;
|
||||
_grippers[i].Visible = false;
|
||||
_grippers[i].Parent = _parent;
|
||||
}
|
||||
_grippers[Gripper.POSITION_TOP_CENTER].Cursor = Cursors.SizeNS;
|
||||
_grippers[Gripper.POSITION_MIDDLE_RIGHT].Cursor = Cursors.SizeWE;
|
||||
_grippers[Gripper.POSITION_BOTTOM_CENTER].Cursor = Cursors.SizeNS;
|
||||
_grippers[Gripper.POSITION_MIDDLE_LEFT].Cursor = Cursors.SizeWE;
|
||||
if (_parent != null) {
|
||||
_parent.Controls.AddRange(_grippers); // otherwise we'll attach them in switchParent
|
||||
}
|
||||
}
|
||||
|
||||
public void SuspendLayout() {
|
||||
layoutSuspended = true;
|
||||
}
|
||||
|
||||
public void ResumeLayout() {
|
||||
layoutSuspended = false;
|
||||
DoLayout();
|
||||
}
|
||||
|
||||
protected virtual void DoLayout() {
|
||||
if (_grippers == null) {
|
||||
return;
|
||||
}
|
||||
if (!layoutSuspended) {
|
||||
int[] xChoords = {Left-2,Left+Width/2-2,Left+Width-2};
|
||||
int[] yChoords = {Top-2,Top+Height/2-2,Top+Height-2};
|
||||
/// <summary>
|
||||
/// Create the default adorners for a rectangle based container
|
||||
/// </summary>
|
||||
|
||||
_grippers[Gripper.POSITION_TOP_LEFT].Left = xChoords[0]; _grippers[Gripper.POSITION_TOP_LEFT].Top = yChoords[0];
|
||||
_grippers[Gripper.POSITION_TOP_CENTER].Left = xChoords[1]; _grippers[Gripper.POSITION_TOP_CENTER].Top = yChoords[0];
|
||||
_grippers[Gripper.POSITION_TOP_RIGHT].Left = xChoords[2]; _grippers[Gripper.POSITION_TOP_RIGHT].Top = yChoords[0];
|
||||
_grippers[Gripper.POSITION_MIDDLE_RIGHT].Left = xChoords[2]; _grippers[Gripper.POSITION_MIDDLE_RIGHT].Top = yChoords[1];
|
||||
_grippers[Gripper.POSITION_BOTTOM_RIGHT].Left = xChoords[2]; _grippers[Gripper.POSITION_BOTTOM_RIGHT].Top = yChoords[2];
|
||||
_grippers[Gripper.POSITION_BOTTOM_CENTER].Left = xChoords[1]; _grippers[Gripper.POSITION_BOTTOM_CENTER].Top = yChoords[2];
|
||||
_grippers[Gripper.POSITION_BOTTOM_LEFT].Left = xChoords[0]; _grippers[Gripper.POSITION_BOTTOM_LEFT].Top = yChoords[2];
|
||||
_grippers[Gripper.POSITION_MIDDLE_LEFT].Left = xChoords[0]; _grippers[Gripper.POSITION_MIDDLE_LEFT].Top = yChoords[1];
|
||||
|
||||
if((_grippers[Gripper.POSITION_TOP_LEFT].Left < _grippers[Gripper.POSITION_BOTTOM_RIGHT].Left && _grippers[Gripper.POSITION_TOP_LEFT].Top < _grippers[Gripper.POSITION_BOTTOM_RIGHT].Top) ||
|
||||
_grippers[Gripper.POSITION_TOP_LEFT].Left > _grippers[Gripper.POSITION_BOTTOM_RIGHT].Left && _grippers[Gripper.POSITION_TOP_LEFT].Top > _grippers[Gripper.POSITION_BOTTOM_RIGHT].Top) {
|
||||
_grippers[Gripper.POSITION_TOP_LEFT].Cursor = Cursors.SizeNWSE;
|
||||
_grippers[Gripper.POSITION_TOP_RIGHT].Cursor = Cursors.SizeNESW;
|
||||
_grippers[Gripper.POSITION_BOTTOM_RIGHT].Cursor = Cursors.SizeNWSE;
|
||||
_grippers[Gripper.POSITION_BOTTOM_LEFT].Cursor = Cursors.SizeNESW;
|
||||
} else if((_grippers[Gripper.POSITION_TOP_LEFT].Left > _grippers[Gripper.POSITION_BOTTOM_RIGHT].Left && _grippers[Gripper.POSITION_TOP_LEFT].Top < _grippers[Gripper.POSITION_BOTTOM_RIGHT].Top) ||
|
||||
_grippers[Gripper.POSITION_TOP_LEFT].Left < _grippers[Gripper.POSITION_BOTTOM_RIGHT].Left && _grippers[Gripper.POSITION_TOP_LEFT].Top > _grippers[Gripper.POSITION_BOTTOM_RIGHT].Top) {
|
||||
_grippers[Gripper.POSITION_TOP_LEFT].Cursor = Cursors.SizeNESW;
|
||||
_grippers[Gripper.POSITION_TOP_RIGHT].Cursor = Cursors.SizeNWSE;
|
||||
_grippers[Gripper.POSITION_BOTTOM_RIGHT].Cursor = Cursors.SizeNESW;
|
||||
_grippers[Gripper.POSITION_BOTTOM_LEFT].Cursor = Cursors.SizeNWSE;
|
||||
} else if (_grippers[Gripper.POSITION_TOP_LEFT].Left == _grippers[Gripper.POSITION_BOTTOM_RIGHT].Left) {
|
||||
_grippers[Gripper.POSITION_TOP_LEFT].Cursor = Cursors.SizeNS;
|
||||
_grippers[Gripper.POSITION_BOTTOM_RIGHT].Cursor = Cursors.SizeNS;
|
||||
} else if (_grippers[Gripper.POSITION_TOP_LEFT].Top == _grippers[Gripper.POSITION_BOTTOM_RIGHT].Top) {
|
||||
_grippers[Gripper.POSITION_TOP_LEFT].Cursor = Cursors.SizeWE;
|
||||
_grippers[Gripper.POSITION_BOTTOM_RIGHT].Cursor = Cursors.SizeWE;
|
||||
}
|
||||
protected void CreateDefaultAdorners() {
|
||||
if (Adorners.Count > 0)
|
||||
{
|
||||
LOG.Warn("Adorners are already defined!");
|
||||
}
|
||||
}
|
||||
|
||||
private void GripperMouseDown(object sender, MouseEventArgs e) {
|
||||
Gripper originatingGripper = (Gripper)sender;
|
||||
if (originatingGripper != _targetGripper) {
|
||||
Status = EditStatus.RESIZING;
|
||||
_boundsBeforeResize = new Rectangle(left, top, width, height);
|
||||
_boundsAfterResize = new RectangleF(_boundsBeforeResize.Left, _boundsBeforeResize.Top, _boundsBeforeResize.Width, _boundsBeforeResize.Height);
|
||||
} else {
|
||||
Status = EditStatus.MOVING;
|
||||
}
|
||||
isMadeUndoable = false;
|
||||
// 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));
|
||||
}
|
||||
|
||||
private void GripperMouseUp(object sender, MouseEventArgs e) {
|
||||
Gripper originatingGripper = (Gripper)sender;
|
||||
if (originatingGripper != _targetGripper) {
|
||||
_boundsBeforeResize = Rectangle.Empty;
|
||||
_boundsAfterResize = RectangleF.Empty;
|
||||
isMadeUndoable = false;
|
||||
}
|
||||
Status = EditStatus.IDLE;
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void GripperMouseMove(object sender, MouseEventArgs e) {
|
||||
Invalidate();
|
||||
Gripper originatingGripper = (Gripper)sender;
|
||||
int absX = originatingGripper.Left + e.X;
|
||||
int absY = originatingGripper.Top + e.Y;
|
||||
if (originatingGripper == _targetGripper && Status.Equals(EditStatus.MOVING)) {
|
||||
TargetGripperMove(absX, absY);
|
||||
} else if (Status.Equals(EditStatus.RESIZING)) {
|
||||
// check if we already made this undoable
|
||||
if (!isMadeUndoable) {
|
||||
// don't allow another undo until we are finished with this move
|
||||
isMadeUndoable = true;
|
||||
// Make undo-able
|
||||
MakeBoundsChangeUndoable(false);
|
||||
}
|
||||
|
||||
SuspendLayout();
|
||||
|
||||
// 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, originatingGripper.Position, new PointF(absX, absY), ScaleHelper.GetScaleOptions());
|
||||
|
||||
// apply scaled bounds to this DrawableContainer
|
||||
ApplyBounds(_boundsAfterResize);
|
||||
|
||||
ResumeLayout();
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public bool hasFilters {
|
||||
get {
|
||||
return Filters.Count > 0;
|
||||
|
@ -525,12 +383,12 @@ namespace Greenshot.Drawing {
|
|||
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);
|
||||
}
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -558,43 +416,10 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
}
|
||||
|
||||
public virtual void ShowGrippers() {
|
||||
if (_grippers != null) {
|
||||
for (int i = 0; i < _grippers.Length; i++) {
|
||||
if (_grippers[i].Enabled) {
|
||||
_grippers[i].Show();
|
||||
} else {
|
||||
_grippers[i].Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (_targetGripper != null) {
|
||||
if (_targetGripper.Enabled) {
|
||||
_targetGripper.Show();
|
||||
} else {
|
||||
_targetGripper.Hide();
|
||||
}
|
||||
}
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
public virtual void HideGrippers() {
|
||||
SuspendLayout();
|
||||
if (_grippers != null) {
|
||||
for (int i = 0; i < _grippers.Length; i++) {
|
||||
_grippers[i].Hide();
|
||||
}
|
||||
}
|
||||
if (_targetGripper != null) {
|
||||
_targetGripper.Hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ResizeTo(int width, int height, int anchorPosition) {
|
||||
SuspendLayout();
|
||||
Width = width;
|
||||
Height = height;
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -606,10 +431,8 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
|
||||
public void MoveBy(int dx, int dy) {
|
||||
SuspendLayout();
|
||||
Left += dx;
|
||||
Top += dy;
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -632,7 +455,6 @@ namespace Greenshot.Drawing {
|
|||
/// <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();
|
||||
SuspendLayout();
|
||||
|
||||
// reset "workrbench" rectangle to current bounds
|
||||
_boundsAfterResize.X = _boundsBeforeResize.Left;
|
||||
|
@ -645,7 +467,6 @@ namespace Greenshot.Drawing {
|
|||
// apply scaled bounds to this DrawableContainer
|
||||
ApplyBounds(_boundsAfterResize);
|
||||
|
||||
ResumeLayout();
|
||||
Invalidate();
|
||||
return true;
|
||||
}
|
||||
|
@ -659,49 +480,18 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
|
||||
protected virtual void SwitchParent(Surface newParent) {
|
||||
// Target gripper
|
||||
if (_parent != null && _targetGripper != null) {
|
||||
_parent.Controls.Remove(_targetGripper);
|
||||
}
|
||||
// Normal grippers
|
||||
if (_parent != null && _grippers != null) {
|
||||
for (int i=0; i<_grippers.Length; i++) {
|
||||
_parent.Controls.Remove(_grippers[i]);
|
||||
}
|
||||
} else if (_grippers == null) {
|
||||
InitControls();
|
||||
}
|
||||
_parent = newParent;
|
||||
// Target gripper
|
||||
if (_parent != null && _targetGripper != null) {
|
||||
_parent.Controls.Add(_targetGripper);
|
||||
}
|
||||
// Normal grippers
|
||||
if (_grippers != null) {
|
||||
_parent.Controls.AddRange(_grippers);
|
||||
if (newParent == Parent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_parent?.FieldAggregator?.UnbindElement(this);
|
||||
|
||||
_parent = newParent;
|
||||
foreach(IFilter filter in Filters) {
|
||||
filter.Parent = this;
|
||||
}
|
||||
}
|
||||
|
||||
// drawablecontainers are regarded equal if they are of the same type and their bounds are equal. this should be sufficient.
|
||||
public override bool Equals(object obj) {
|
||||
bool ret = false;
|
||||
if (obj != null && GetType() == obj.GetType()) {
|
||||
DrawableContainer other = obj as DrawableContainer;
|
||||
if (other != null && left==other.left && top==other.top && width==other.width && height==other.height) {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
return left.GetHashCode() ^ top.GetHashCode() ^ width.GetHashCode() ^ height.GetHashCode() ^ GetFields().GetHashCode();
|
||||
}
|
||||
|
||||
protected void OnPropertyChanged(string propertyName) {
|
||||
if (_propertyChanged != null) {
|
||||
_propertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
|
@ -715,8 +505,8 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
/// <param name="fieldToBeChanged">The field to be changed</param>
|
||||
/// <param name="newValue">The new value</param>
|
||||
public virtual void BeforeFieldChange(Field fieldToBeChanged, object newValue) {
|
||||
_parent.MakeUndoable(new ChangeFieldHolderMemento(this, fieldToBeChanged), true);
|
||||
public virtual void BeforeFieldChange(IField fieldToBeChanged, object newValue) {
|
||||
_parent?.MakeUndoable(new ChangeFieldHolderMemento(this, fieldToBeChanged), true);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
@ -727,10 +517,9 @@ namespace Greenshot.Drawing {
|
|||
/// <param name="e"></param>
|
||||
public void HandleFieldChanged(object sender, FieldChangedEventArgs e) {
|
||||
LOG.DebugFormat("Field {0} changed", e.Field.FieldType);
|
||||
if (e.Field.FieldType == FieldType.SHADOW) {
|
||||
if (Equals(e.Field.FieldType, FieldType.SHADOW)) {
|
||||
accountForShadowChange = true;
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -775,26 +564,16 @@ namespace Greenshot.Drawing {
|
|||
if (matrix == null) {
|
||||
return;
|
||||
}
|
||||
SuspendLayout();
|
||||
Point topLeft = new Point(Left, Top);
|
||||
Point bottomRight = new Point(Left + Width, Top + Height);
|
||||
Point[] points;
|
||||
if (TargetGripper != null) {
|
||||
points = new[] {topLeft, bottomRight, TargetGripper.Location};
|
||||
|
||||
} else {
|
||||
points = new[] { topLeft, bottomRight };
|
||||
}
|
||||
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;
|
||||
if (TargetGripper != null) {
|
||||
TargetGripper.Location = points[points.Length-1];
|
||||
}
|
||||
ResumeLayout();
|
||||
|
||||
}
|
||||
|
||||
protected virtual ScaleHelper.IDoubleProcessor GetAngleRoundProcessor() {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -20,11 +20,11 @@
|
|||
*/
|
||||
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Memento;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
@ -38,8 +38,9 @@ namespace Greenshot.Drawing {
|
|||
/// Dispatches most of a DrawableContainer's public properties and methods to a list of DrawableContainers.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DrawableContainerList : List<IDrawableContainer> {
|
||||
private static readonly ComponentResourceManager editorFormResources = new ComponentResourceManager(typeof(ImageEditorForm));
|
||||
public class DrawableContainerList : List<IDrawableContainer>, IDrawableContainerList
|
||||
{
|
||||
private static readonly ComponentResourceManager EditorFormResources = new ComponentResourceManager(typeof(ImageEditorForm));
|
||||
|
||||
public Guid ParentID {
|
||||
get;
|
||||
|
@ -49,8 +50,8 @@ namespace Greenshot.Drawing {
|
|||
public DrawableContainerList() {
|
||||
}
|
||||
|
||||
public DrawableContainerList(Guid parentID) {
|
||||
ParentID = parentID;
|
||||
public DrawableContainerList(Guid parentId) {
|
||||
ParentID = parentId;
|
||||
}
|
||||
|
||||
public EditStatus Status {
|
||||
|
@ -116,14 +117,11 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
/// <param name="allowMerge">true means allow the moves to be merged</param>
|
||||
public void MakeBoundsChangeUndoable(bool allowMerge) {
|
||||
List<IDrawableContainer> movingList = new List<IDrawableContainer>();
|
||||
Surface surface = null;
|
||||
foreach(DrawableContainer dc in this) {
|
||||
movingList.Add(dc);
|
||||
surface = dc._parent;
|
||||
}
|
||||
if (movingList.Count > 0 && surface != null) {
|
||||
surface.MakeUndoable(new DrawableContainerBoundsChangeMemento(movingList), allowMerge);
|
||||
if (Count > 0 && Parent != null)
|
||||
{
|
||||
var clone = new DrawableContainerList();
|
||||
clone.AddRange(this);
|
||||
Parent.MakeUndoable(new DrawableContainerBoundsChangeMemento(clone), allowMerge);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,26 +169,6 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Hides the grippers of all elements in the list.
|
||||
/// </summary>
|
||||
public void HideGrippers() {
|
||||
foreach(var dc in this) {
|
||||
dc.HideGrippers();
|
||||
dc.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the grippers of all elements in the list.
|
||||
/// </summary>
|
||||
public void ShowGrippers() {
|
||||
foreach(var dc in this) {
|
||||
dc.ShowGrippers();
|
||||
dc.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether on of the elements is clickable at the given location
|
||||
/// </summary>
|
||||
|
@ -266,9 +244,19 @@ namespace Greenshot.Drawing {
|
|||
/// <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) {
|
||||
foreach(var drawableContainer in this) {
|
||||
var dc = (DrawableContainer) drawableContainer;
|
||||
if (dc.DrawingBounds.IntersectsWith(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);
|
||||
}
|
||||
}
|
||||
|
@ -290,9 +278,16 @@ namespace Greenshot.Drawing {
|
|||
/// Invalidate the bounds of all the DC's in this list
|
||||
/// </summary>
|
||||
public void Invalidate() {
|
||||
foreach(var dc in this) {
|
||||
dc.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,
|
||||
|
@ -300,7 +295,7 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
/// <param name="elements">list of elements to pull up</param>
|
||||
/// <returns>true if the elements could be pulled up</returns>
|
||||
public bool CanPullUp(DrawableContainerList elements) {
|
||||
public bool CanPullUp(IDrawableContainerList elements) {
|
||||
if (elements.Count == 0 || elements.Count == Count) {
|
||||
return false;
|
||||
}
|
||||
|
@ -316,13 +311,13 @@ namespace Greenshot.Drawing {
|
|||
/// 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(DrawableContainerList elements) {
|
||||
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])) {
|
||||
if (Count > i+1 && !elements.Contains(this[i+1])) {
|
||||
SwapElements(i,i+1);
|
||||
}
|
||||
}
|
||||
|
@ -332,10 +327,11 @@ namespace Greenshot.Drawing {
|
|||
/// 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(DrawableContainerList elements) {
|
||||
public void PullElementsToTop(IDrawableContainerList elements)
|
||||
{
|
||||
var dcs = ToArray();
|
||||
for(int i=0; i<dcs.Length; i++) {
|
||||
var dc = dcs[i];
|
||||
foreach (var dc in dcs)
|
||||
{
|
||||
if (!elements.Contains(dc)) {
|
||||
continue;
|
||||
}
|
||||
|
@ -344,14 +340,14 @@ namespace Greenshot.Drawing {
|
|||
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(DrawableContainerList elements) {
|
||||
public bool CanPushDown(IDrawableContainerList elements) {
|
||||
if (elements.Count == 0 || elements.Count == Count) {
|
||||
return false;
|
||||
}
|
||||
|
@ -367,7 +363,7 @@ namespace Greenshot.Drawing {
|
|||
/// 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(DrawableContainerList elements) {
|
||||
public void PushElementsDown(IDrawableContainerList elements) {
|
||||
for(int i=0; i<Count; i++) {
|
||||
var dc = this[i];
|
||||
if (!elements.Contains(dc)) {
|
||||
|
@ -383,7 +379,7 @@ namespace Greenshot.Drawing {
|
|||
/// 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(DrawableContainerList elements) {
|
||||
public void PushElementsToBottom(IDrawableContainerList elements) {
|
||||
var dcs = ToArray();
|
||||
for(int i=dcs.Length-1; i>=0; i--) {
|
||||
var dc = dcs[i];
|
||||
|
@ -417,7 +413,7 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <param name="surface"></param>
|
||||
public virtual void AddContextMenuItems(ContextMenuStrip menu, Surface surface) {
|
||||
public virtual void AddContextMenuItems(ContextMenuStrip menu, ISurface surface) {
|
||||
bool push = surface.Elements.CanPushDown(this);
|
||||
bool pull = surface.Elements.CanPullUp(this);
|
||||
|
||||
|
@ -457,7 +453,7 @@ namespace Greenshot.Drawing {
|
|||
// Duplicate
|
||||
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_duplicate));
|
||||
item.Click += delegate {
|
||||
DrawableContainerList dcs = this.Clone();
|
||||
IDrawableContainerList dcs = this.Clone();
|
||||
dcs.Parent = surface;
|
||||
dcs.MoveBy(10, 10);
|
||||
surface.AddElements(dcs);
|
||||
|
@ -467,49 +463,41 @@ namespace Greenshot.Drawing {
|
|||
menu.Items.Add(item);
|
||||
|
||||
// Copy
|
||||
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_copytoclipboard));
|
||||
item.Image = ((Image)(editorFormResources.GetObject("copyToolStripMenuItem.Image")));
|
||||
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_copytoclipboard))
|
||||
{
|
||||
Image = (Image) EditorFormResources.GetObject("copyToolStripMenuItem.Image")
|
||||
};
|
||||
item.Click += delegate {
|
||||
ClipboardHelper.SetClipboardData(typeof(DrawableContainerList), this);
|
||||
ClipboardHelper.SetClipboardData(typeof(IDrawableContainerList), this);
|
||||
};
|
||||
menu.Items.Add(item);
|
||||
|
||||
// Cut
|
||||
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_cuttoclipboard));
|
||||
item.Image = ((Image)(editorFormResources.GetObject("btnCut.Image")));
|
||||
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_cuttoclipboard))
|
||||
{
|
||||
Image = (Image) EditorFormResources.GetObject("btnCut.Image")
|
||||
};
|
||||
item.Click += delegate {
|
||||
ClipboardHelper.SetClipboardData(typeof(DrawableContainerList), this);
|
||||
List<DrawableContainer> containersToDelete = new List<DrawableContainer>();
|
||||
foreach (var drawableContainer in this) {
|
||||
var container = (DrawableContainer) drawableContainer;
|
||||
containersToDelete.Add(container);
|
||||
}
|
||||
foreach (var container in containersToDelete) {
|
||||
surface.RemoveElement(container, true);
|
||||
}
|
||||
ClipboardHelper.SetClipboardData(typeof(IDrawableContainerList), this);
|
||||
surface.RemoveElements(this);
|
||||
};
|
||||
menu.Items.Add(item);
|
||||
|
||||
// Delete
|
||||
item = new ToolStripMenuItem(Language.GetString(LangKey.editor_deleteelement));
|
||||
item.Image = ((Image)(editorFormResources.GetObject("removeObjectToolStripMenuItem.Image")));
|
||||
item.Image = (Image)EditorFormResources.GetObject("removeObjectToolStripMenuItem.Image");
|
||||
item.Click += delegate {
|
||||
List<DrawableContainer> containersToDelete = new List<DrawableContainer>();
|
||||
foreach(var drawableContainer in this) {
|
||||
var container = (DrawableContainer) drawableContainer;
|
||||
containersToDelete.Add(container);
|
||||
}
|
||||
foreach (DrawableContainer container in containersToDelete) {
|
||||
surface.RemoveElement(container, true);
|
||||
}
|
||||
surface.RemoveElements(this);
|
||||
};
|
||||
menu.Items.Add(item);
|
||||
|
||||
// Reset
|
||||
bool canReset = false;
|
||||
foreach (var drawableContainer in this) {
|
||||
var container = (DrawableContainer) drawableContainer;
|
||||
if (container.HasDefaultSize) {
|
||||
foreach (var drawableContainer in this)
|
||||
{
|
||||
var container = (DrawableContainer)drawableContainer;
|
||||
if (container.HasDefaultSize)
|
||||
{
|
||||
canReset = true;
|
||||
}
|
||||
}
|
||||
|
@ -517,24 +505,29 @@ namespace Greenshot.Drawing {
|
|||
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.Invalidate();
|
||||
container.MakeBoundsChangeUndoable(false);
|
||||
container.Width = defaultSize.Width;
|
||||
container.Height = defaultSize.Height;
|
||||
container.Invalidate();
|
||||
}
|
||||
surface.Invalidate();
|
||||
};
|
||||
menu.Items.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ShowContextMenu(MouseEventArgs e, Surface surface) {
|
||||
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;
|
||||
|
@ -548,7 +541,8 @@ namespace Greenshot.Drawing {
|
|||
ContextMenuStrip menu = new ContextMenuStrip();
|
||||
AddContextMenuItems(menu, surface);
|
||||
if (menu.Items.Count > 0) {
|
||||
menu.Show(surface, e.Location);
|
||||
// TODO: cast should be somehow avoided
|
||||
menu.Show((Surface)surface, e.Location);
|
||||
while (true) {
|
||||
if (menu.Visible) {
|
||||
Application.DoEvents();
|
||||
|
@ -561,5 +555,32 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Support
|
||||
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);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -33,6 +33,7 @@ namespace Greenshot.Drawing {
|
|||
[Serializable()]
|
||||
public class EllipseContainer : DrawableContainer {
|
||||
public EllipseContainer(Surface parent) : base(parent) {
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
protected override void InitializeFields() {
|
||||
|
@ -59,12 +60,15 @@ namespace Greenshot.Drawing {
|
|||
/// <summary>
|
||||
/// This allows another container to draw an ellipse
|
||||
/// </summary>
|
||||
/// <param name="caller"></param>
|
||||
/// <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));
|
||||
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
|
||||
// draw shadow before anything else
|
||||
if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
|
||||
int basealpha = 100;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -20,147 +20,183 @@
|
|||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.IniFile;
|
||||
using log4net;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
|
||||
namespace Greenshot.Drawing.Fields {
|
||||
namespace Greenshot.Drawing.Fields
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic IFieldHolder implementation, providing access to a set of fields
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public abstract class AbstractFieldHolder : IFieldHolder {
|
||||
public abstract class AbstractFieldHolder : IFieldHolder
|
||||
{
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(AbstractFieldHolder));
|
||||
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
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; }
|
||||
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 Dictionary<FieldType, Field> fieldsByType = new Dictionary<FieldType, Field>();
|
||||
private List<Field> fields = new List<Field>();
|
||||
|
||||
public AbstractFieldHolder() {}
|
||||
|
||||
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<FieldType, Field>();
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
_fieldsByType = new Dictionary<IFieldType, IField>();
|
||||
// listen to changing properties
|
||||
foreach(Field field in fields) {
|
||||
foreach (var field in fields)
|
||||
{
|
||||
field.PropertyChanged += delegate {
|
||||
if (fieldChanged != null) {
|
||||
fieldChanged(this, new FieldChangedEventArgs(field));
|
||||
}
|
||||
_fieldChanged?.Invoke(this, new FieldChangedEventArgs(field));
|
||||
};
|
||||
fieldsByType[field.FieldType] = field;
|
||||
_fieldsByType[field.FieldType] = field;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddField(Type requestingType, FieldType fieldType, object fieldValue) {
|
||||
AddField(editorConfiguration.CreateField(requestingType, fieldType, fieldValue));
|
||||
public void AddField(Type requestingType, IFieldType fieldType, object fieldValue)
|
||||
{
|
||||
AddField(EditorConfig.CreateField(requestingType, fieldType, fieldValue));
|
||||
}
|
||||
|
||||
public virtual void AddField(Field field) {
|
||||
if (fieldsByType != null && fieldsByType.ContainsKey(field.FieldType)) {
|
||||
if (LOG.IsDebugEnabled) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
fields.Add(field);
|
||||
fieldsByType[field.FieldType] = field;
|
||||
field.PropertyChanged += delegate { if(fieldChanged != null) fieldChanged(this, new FieldChangedEventArgs(field)); };
|
||||
}
|
||||
|
||||
public void RemoveField(Field field) {
|
||||
fields.Remove(field);
|
||||
fieldsByType.Remove(field.FieldType);
|
||||
field.PropertyChanged -= delegate {
|
||||
if (fieldChanged != null) {
|
||||
fieldChanged(this, new FieldChangedEventArgs(field));
|
||||
}
|
||||
}
|
||||
|
||||
_fieldsByType[field.FieldType] = field;
|
||||
|
||||
_handlers[field] = (sender, args) =>
|
||||
{
|
||||
_fieldChanged?.Invoke(this, new FieldChangedEventArgs(field));
|
||||
};
|
||||
field.PropertyChanged += _handlers[field];
|
||||
}
|
||||
|
||||
public List<Field> GetFields() {
|
||||
|
||||
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 Field GetField(FieldType fieldType) {
|
||||
try {
|
||||
return fieldsByType[fieldType];
|
||||
} catch(KeyNotFoundException e) {
|
||||
|
||||
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(FieldType fieldType) {
|
||||
|
||||
public object GetFieldValue(IFieldType fieldType)
|
||||
{
|
||||
return GetField(fieldType).Value;
|
||||
}
|
||||
|
||||
|
||||
#region convenience methods to save us some casts outside
|
||||
public string GetFieldValueAsString(FieldType fieldType) {
|
||||
public string GetFieldValueAsString(IFieldType fieldType)
|
||||
{
|
||||
return Convert.ToString(GetFieldValue(fieldType));
|
||||
}
|
||||
|
||||
public int GetFieldValueAsInt(FieldType fieldType) {
|
||||
|
||||
public int GetFieldValueAsInt(IFieldType fieldType)
|
||||
{
|
||||
return Convert.ToInt32(GetFieldValue(fieldType));
|
||||
}
|
||||
|
||||
public decimal GetFieldValueAsDecimal(FieldType fieldType) {
|
||||
|
||||
public decimal GetFieldValueAsDecimal(IFieldType fieldType)
|
||||
{
|
||||
return Convert.ToDecimal(GetFieldValue(fieldType));
|
||||
}
|
||||
|
||||
public double GetFieldValueAsDouble(FieldType fieldType) {
|
||||
|
||||
public double GetFieldValueAsDouble(IFieldType fieldType)
|
||||
{
|
||||
return Convert.ToDouble(GetFieldValue(fieldType));
|
||||
}
|
||||
|
||||
public float GetFieldValueAsFloat(FieldType fieldType) {
|
||||
|
||||
public float GetFieldValueAsFloat(IFieldType fieldType)
|
||||
{
|
||||
return Convert.ToSingle(GetFieldValue(fieldType));
|
||||
}
|
||||
|
||||
public bool GetFieldValueAsBool(FieldType fieldType) {
|
||||
|
||||
public bool GetFieldValueAsBool(IFieldType fieldType)
|
||||
{
|
||||
return Convert.ToBoolean(GetFieldValue(fieldType));
|
||||
}
|
||||
|
||||
public Color GetFieldValueAsColor(FieldType fieldType) {
|
||||
|
||||
public Color GetFieldValueAsColor(IFieldType fieldType)
|
||||
{
|
||||
return (Color)GetFieldValue(fieldType);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public bool HasField(FieldType fieldType) {
|
||||
return fieldsByType.ContainsKey(fieldType);
|
||||
|
||||
public bool HasField(IFieldType fieldType)
|
||||
{
|
||||
return _fieldsByType.ContainsKey(fieldType);
|
||||
}
|
||||
|
||||
public bool HasFieldValue(FieldType fieldType) {
|
||||
return HasField(fieldType) && fieldsByType[fieldType].HasValue;
|
||||
|
||||
public bool HasFieldValue(IFieldType fieldType)
|
||||
{
|
||||
return HasField(fieldType) && _fieldsByType[fieldType].HasValue;
|
||||
}
|
||||
|
||||
public void SetFieldValue(FieldType fieldType, object value) {
|
||||
try {
|
||||
fieldsByType[fieldType].Value = value;
|
||||
} catch(KeyNotFoundException e) {
|
||||
throw new ArgumentException("Field '"+fieldType+"' does not exist in " + GetType(), e);
|
||||
|
||||
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){
|
||||
if (fieldChanged != null) {
|
||||
fieldChanged(sender, e);
|
||||
}
|
||||
|
||||
protected void OnFieldChanged(object sender, FieldChangedEventArgs e)
|
||||
{
|
||||
_fieldChanged?.Invoke(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -18,87 +18,110 @@
|
|||
* 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 {
|
||||
namespace Greenshot.Drawing.Fields
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic IFieldHolderWithChildren implementation. Similar to IFieldHolder,
|
||||
/// but has a List<IFieldHolder> of children.
|
||||
/// 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 {
|
||||
|
||||
FieldChangedEventHandler fieldChangedEventHandler;
|
||||
|
||||
[Serializable]
|
||||
public abstract class AbstractFieldHolderWithChildren : AbstractFieldHolder
|
||||
{
|
||||
[NonSerialized]
|
||||
private readonly FieldChangedEventHandler _fieldChangedEventHandler;
|
||||
|
||||
[NonSerialized]
|
||||
private EventHandler childrenChanged;
|
||||
public event EventHandler ChildrenChanged {
|
||||
public event EventHandler ChildrenChanged
|
||||
{
|
||||
add { childrenChanged += value; }
|
||||
remove { childrenChanged -= value; }
|
||||
}
|
||||
|
||||
|
||||
public List<IFieldHolder> Children = new List<IFieldHolder>();
|
||||
|
||||
public AbstractFieldHolderWithChildren() {
|
||||
fieldChangedEventHandler = OnFieldChanged;
|
||||
|
||||
public AbstractFieldHolderWithChildren()
|
||||
{
|
||||
_fieldChangedEventHandler = OnFieldChanged;
|
||||
}
|
||||
|
||||
|
||||
[OnDeserialized()]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
private void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
// listen to changing properties
|
||||
foreach(IFieldHolder fieldHolder in Children) {
|
||||
fieldHolder.FieldChanged += fieldChangedEventHandler;
|
||||
foreach (IFieldHolder fieldHolder in Children)
|
||||
{
|
||||
fieldHolder.FieldChanged += _fieldChangedEventHandler;
|
||||
}
|
||||
if(childrenChanged != null) childrenChanged(this, EventArgs.Empty);
|
||||
childrenChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void AddChild(IFieldHolder fieldHolder) {
|
||||
|
||||
public void AddChild(IFieldHolder fieldHolder)
|
||||
{
|
||||
Children.Add(fieldHolder);
|
||||
fieldHolder.FieldChanged += fieldChangedEventHandler;
|
||||
if(childrenChanged != null) childrenChanged(this, EventArgs.Empty);
|
||||
fieldHolder.FieldChanged += _fieldChangedEventHandler;
|
||||
childrenChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public void RemoveChild(IFieldHolder fieldHolder) {
|
||||
|
||||
public void RemoveChild(IFieldHolder fieldHolder)
|
||||
{
|
||||
Children.Remove(fieldHolder);
|
||||
fieldHolder.FieldChanged -= fieldChangedEventHandler;
|
||||
if(childrenChanged != null) childrenChanged(this, EventArgs.Empty);
|
||||
fieldHolder.FieldChanged -= _fieldChangedEventHandler;
|
||||
childrenChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
public new List<Field> GetFields() {
|
||||
List<Field> ret = new List<Field>();
|
||||
|
||||
public new IList<IField> GetFields()
|
||||
{
|
||||
var ret = new List<IField>();
|
||||
ret.AddRange(base.GetFields());
|
||||
foreach(IFieldHolder fh in Children) {
|
||||
foreach (IFieldHolder fh in Children)
|
||||
{
|
||||
ret.AddRange(fh.GetFields());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public new Field GetField(FieldType fieldType) {
|
||||
Field ret = null;
|
||||
if(base.HasField(fieldType)) {
|
||||
|
||||
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)) {
|
||||
}
|
||||
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());
|
||||
if (ret == null)
|
||||
{
|
||||
throw new ArgumentException("Field '" + fieldType + "' does not exist in " + GetType());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public new bool HasField(FieldType fieldType) {
|
||||
|
||||
public new bool HasField(IFieldType fieldType)
|
||||
{
|
||||
bool ret = base.HasField(fieldType);
|
||||
if(!ret) {
|
||||
foreach(IFieldHolder fh in Children) {
|
||||
if(fh.HasField(fieldType)) {
|
||||
if (!ret)
|
||||
{
|
||||
foreach (IFieldHolder fh in Children)
|
||||
{
|
||||
if (fh.HasField(fieldType))
|
||||
{
|
||||
ret = true;
|
||||
break;
|
||||
}
|
||||
|
@ -106,16 +129,18 @@ namespace Greenshot.Drawing.Fields {
|
|||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public new bool HasFieldValue(FieldType fieldType) {
|
||||
Field f = GetField(fieldType);
|
||||
|
||||
public new bool HasFieldValue(IFieldType fieldType)
|
||||
{
|
||||
IField f = GetField(fieldType);
|
||||
return f != null && f.HasValue;
|
||||
}
|
||||
|
||||
public new void SetFieldValue(FieldType fieldType, object value) {
|
||||
Field f = GetField(fieldType);
|
||||
if(f != null) f.Value = value;
|
||||
|
||||
public new void SetFieldValue(IFieldType fieldType, object value)
|
||||
{
|
||||
IField f = GetField(fieldType);
|
||||
if (f != null) f.Value = value;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -26,8 +26,6 @@ namespace Greenshot.Drawing.Fields.Binding {
|
|||
/// </summary>
|
||||
public abstract class AbstractBindingConverter<T1,T2> : IBindingConverter
|
||||
{
|
||||
public AbstractBindingConverter() {}
|
||||
|
||||
public object convert(object o) {
|
||||
if(o == null) {
|
||||
return null;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -29,35 +29,35 @@ namespace Greenshot.Drawing.Fields.Binding {
|
|||
/// behavior (e.g. when binding to a
|
||||
/// </summary>
|
||||
public class BidirectionalBinding {
|
||||
private INotifyPropertyChanged controlObject;
|
||||
private INotifyPropertyChanged fieldObject;
|
||||
private string controlPropertyName;
|
||||
private string fieldPropertyName;
|
||||
private bool updatingControl = false;
|
||||
private bool updatingField = false;
|
||||
private IBindingConverter converter;
|
||||
private IBindingValidator validator;
|
||||
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="object1">Object containing 1st property to bind</param>
|
||||
/// <param name="property1">Property of 1st object to bind</param>
|
||||
/// <param name="object2">Object containing 2nd property to bind</param>
|
||||
/// <param name="property2">Property of 2nd object to bind</param>
|
||||
/// <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) {
|
||||
this.controlObject = controlObject;
|
||||
this.fieldObject = fieldObject;
|
||||
this.controlPropertyName = controlPropertyName;
|
||||
this.fieldPropertyName = fieldPropertyName;
|
||||
_controlObject = controlObject;
|
||||
_fieldObject = fieldObject;
|
||||
_controlPropertyName = controlPropertyName;
|
||||
_fieldPropertyName = fieldPropertyName;
|
||||
|
||||
this.controlObject.PropertyChanged += ControlPropertyChanged;
|
||||
this.fieldObject.PropertyChanged += FieldPropertyChanged;
|
||||
_controlObject.PropertyChanged += ControlPropertyChanged;
|
||||
_fieldObject.PropertyChanged += FieldPropertyChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -69,7 +69,7 @@ namespace Greenshot.Drawing.Fields.Binding {
|
|||
/// <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) {
|
||||
this.converter = converter;
|
||||
_converter = converter;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -82,7 +82,7 @@ namespace Greenshot.Drawing.Fields.Binding {
|
|||
/// <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) {
|
||||
this.validator = validator;
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -96,46 +96,46 @@ namespace Greenshot.Drawing.Fields.Binding {
|
|||
/// <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) {
|
||||
this.validator = validator;
|
||||
_validator = validator;
|
||||
}
|
||||
|
||||
public void ControlPropertyChanged(object sender, PropertyChangedEventArgs e) {
|
||||
if (!updatingControl && e.PropertyName.Equals(controlPropertyName)) {
|
||||
updatingField = true;
|
||||
synchronize(controlObject, controlPropertyName, fieldObject, fieldPropertyName);
|
||||
updatingField = false;
|
||||
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;
|
||||
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);
|
||||
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);
|
||||
if (_converter != null && bValue != null) {
|
||||
bValue = _converter.convert(bValue);
|
||||
}
|
||||
try {
|
||||
if (validator == null || validator.validate(bValue)) {
|
||||
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!=null)?bValue.GetType().Name:"")+"] on "+targetObject+". Probably other type than expected, IBindingCoverter to the rescue.", e);
|
||||
throw new MemberAccessException("Could not set property '"+targetProperty+"' to '"+bValue+"' ["+(bValue?.GetType().Name ?? "")+"] on "+targetObject+". Probably other type than expected, IBindingCoverter to the rescue.", e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private PropertyInfo resolvePropertyInfo(object obj, string property) {
|
||||
private static PropertyInfo ResolvePropertyInfo(object obj, string property) {
|
||||
PropertyInfo ret = null;
|
||||
string[] properties = property.Split(".".ToCharArray());
|
||||
for(int i=0; i<properties.Length; i++) {
|
||||
|
@ -149,8 +149,8 @@ namespace Greenshot.Drawing.Fields.Binding {
|
|||
}
|
||||
|
||||
public IBindingConverter Converter {
|
||||
get { return converter; }
|
||||
set { converter = value; }
|
||||
get { return _converter; }
|
||||
set { _converter = value; }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -22,7 +22,7 @@ using System;
|
|||
|
||||
namespace Greenshot.Drawing.Fields.Binding {
|
||||
/// <summary>
|
||||
/// Converts decimal to double (%) and vice versa, e.g. 95f <---> 0.95d
|
||||
/// Converts decimal to double (%) and vice versa, e.g. 95f to 0.95d
|
||||
/// </summary>
|
||||
public class DecimalDoublePercentageConverter : AbstractBindingConverter<double, decimal>
|
||||
{
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -18,36 +18,50 @@
|
|||
* 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 {
|
||||
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 : INotifyPropertyChanged {
|
||||
[field:NonSerialized]
|
||||
public class Field : IField
|
||||
{
|
||||
[field: NonSerialized]
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public object myValue;
|
||||
public object Value {
|
||||
get {
|
||||
return myValue;
|
||||
|
||||
private object _myValue;
|
||||
public object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _myValue;
|
||||
}
|
||||
set {
|
||||
if (!Equals(myValue,value)) {
|
||||
myValue = value;
|
||||
if (PropertyChanged!=null) {
|
||||
PropertyChanged(this, new PropertyChangedEventArgs("Value"));
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!Equals(_myValue, value))
|
||||
{
|
||||
_myValue = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Value"));
|
||||
}
|
||||
}
|
||||
}
|
||||
public FieldType FieldType;
|
||||
public string Scope;
|
||||
|
||||
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.
|
||||
|
@ -59,70 +73,59 @@ namespace Greenshot.Drawing.Fields {
|
|||
/// 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(FieldType fieldType, Type scope) {
|
||||
public Field(IFieldType fieldType, Type scope)
|
||||
{
|
||||
FieldType = fieldType;
|
||||
Scope = scope.Name;
|
||||
}
|
||||
public Field(FieldType fieldType, string scope) {
|
||||
public Field(IFieldType fieldType, string scope)
|
||||
{
|
||||
FieldType = fieldType;
|
||||
Scope = scope;
|
||||
}
|
||||
public Field(FieldType fieldType) {
|
||||
public Field(IFieldType fieldType)
|
||||
{
|
||||
FieldType = fieldType;
|
||||
}
|
||||
/// <summary>
|
||||
/// Returns true if this field holds a value other than null.
|
||||
/// </summary>
|
||||
public bool HasValue {
|
||||
get{ return Value != null; }
|
||||
}
|
||||
|
||||
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() {
|
||||
Field ret = new Field(FieldType, Scope);
|
||||
ret.Value = Value;
|
||||
return ret;
|
||||
public Field Clone()
|
||||
{
|
||||
return new Field(FieldType, Scope) {Value = Value};
|
||||
}
|
||||
|
||||
public override int GetHashCode() {
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = 0;
|
||||
unchecked {
|
||||
unchecked
|
||||
{
|
||||
hashCode += 1000000009 * FieldType.GetHashCode();
|
||||
if (Scope != null)
|
||||
hashCode += 1000000021 * Scope.GetHashCode();
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) {
|
||||
Field other = obj as Field;
|
||||
if (other == null) {
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
var other = obj as Field;
|
||||
if (other == null)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// EventHandler to be used when a field value changes
|
||||
/// </summary>
|
||||
public delegate void FieldChangedEventHandler(object sender, FieldChangedEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// EventArgs to be used with FieldChangedEventHandler
|
||||
/// </summary>
|
||||
public class FieldChangedEventArgs : EventArgs {
|
||||
public readonly Field Field;
|
||||
public FieldChangedEventArgs(Field field) {
|
||||
Field = field;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return string.Format("[Field FieldType={1} Value={0} Scope={2}]", _myValue, FieldType, Scope);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -19,15 +19,17 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
||||
using Greenshot.Configuration;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Drawing.Fields {
|
||||
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
|
||||
|
@ -39,150 +41,184 @@ namespace Greenshot.Drawing.Fields {
|
|||
/// 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>
|
||||
public class FieldAggregator : AbstractFieldHolder {
|
||||
|
||||
private List<IDrawableContainer> boundContainers;
|
||||
private bool internalUpdateRunning = false;
|
||||
|
||||
enum Status {IDLE, BINDING, UPDATING};
|
||||
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(FieldAggregator));
|
||||
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
[Serializable]
|
||||
public sealed class FieldAggregator : AbstractFieldHolder
|
||||
{
|
||||
|
||||
public FieldAggregator() {
|
||||
foreach(FieldType fieldType in FieldType.Values) {
|
||||
Field field = new Field(fieldType, GetType());
|
||||
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 List<IDrawableContainer>();
|
||||
_boundContainers = new DrawableContainerList
|
||||
{
|
||||
Parent = parent
|
||||
};
|
||||
}
|
||||
|
||||
public override void AddField(Field field) {
|
||||
|
||||
public override void AddField(IField field)
|
||||
{
|
||||
base.AddField(field);
|
||||
field.PropertyChanged += OwnPropertyChanged;
|
||||
}
|
||||
|
||||
public void BindElements(DrawableContainerList dcs) {
|
||||
foreach(DrawableContainer dc in dcs) {
|
||||
|
||||
public void BindElements(IDrawableContainerList dcs)
|
||||
{
|
||||
foreach (var dc in dcs)
|
||||
{
|
||||
BindElement(dc);
|
||||
}
|
||||
}
|
||||
|
||||
public void BindElement(IDrawableContainer dc) {
|
||||
public void BindElement(IDrawableContainer dc)
|
||||
{
|
||||
DrawableContainer container = dc as DrawableContainer;
|
||||
if (container != null && !boundContainers.Contains(container)) {
|
||||
boundContainers.Add(container);
|
||||
container.ChildrenChanged += delegate {
|
||||
UpdateFromBoundElements();
|
||||
};
|
||||
UpdateFromBoundElements();
|
||||
if (container == null || _boundContainers.Contains(container))
|
||||
{
|
||||
return;
|
||||
}
|
||||
_boundContainers.Add(container);
|
||||
container.ChildrenChanged += delegate {
|
||||
UpdateFromBoundElements();
|
||||
};
|
||||
UpdateFromBoundElements();
|
||||
}
|
||||
|
||||
public void BindAndUpdateElement(IDrawableContainer dc) {
|
||||
|
||||
public void BindAndUpdateElement(IDrawableContainer dc)
|
||||
{
|
||||
UpdateElement(dc);
|
||||
BindElement(dc);
|
||||
}
|
||||
|
||||
public void UpdateElement(IDrawableContainer dc) {
|
||||
|
||||
public void UpdateElement(IDrawableContainer dc)
|
||||
{
|
||||
DrawableContainer container = dc as DrawableContainer;
|
||||
if (container == null) {
|
||||
if (container == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
internalUpdateRunning = true;
|
||||
foreach(Field field in GetFields()) {
|
||||
if (container.HasField(field.FieldType) && field.HasValue) {
|
||||
_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;
|
||||
_internalUpdateRunning = false;
|
||||
}
|
||||
|
||||
public void UnbindElement(IDrawableContainer dc) {
|
||||
if (boundContainers.Contains(dc)) {
|
||||
boundContainers.Remove(dc);
|
||||
|
||||
public void UnbindElement(IDrawableContainer dc)
|
||||
{
|
||||
if (_boundContainers.Contains(dc))
|
||||
{
|
||||
_boundContainers.Remove(dc);
|
||||
UpdateFromBoundElements();
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
ClearFields();
|
||||
boundContainers.Clear();
|
||||
_boundContainers.Clear();
|
||||
UpdateFromBoundElements();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// sets all field values to null, however does not remove fields
|
||||
/// </summary>
|
||||
private void ClearFields() {
|
||||
internalUpdateRunning = true;
|
||||
foreach(Field field in GetFields()) {
|
||||
private void ClearFields()
|
||||
{
|
||||
_internalUpdateRunning = true;
|
||||
foreach (var field in GetFields())
|
||||
{
|
||||
field.Value = null;
|
||||
}
|
||||
internalUpdateRunning = false;
|
||||
_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() {
|
||||
private void UpdateFromBoundElements()
|
||||
{
|
||||
ClearFields();
|
||||
internalUpdateRunning = true;
|
||||
foreach(Field field in FindCommonFields()) {
|
||||
_internalUpdateRunning = true;
|
||||
foreach (var field in FindCommonFields())
|
||||
{
|
||||
SetFieldValue(field.FieldType, field.Value);
|
||||
}
|
||||
internalUpdateRunning = false;
|
||||
_internalUpdateRunning = false;
|
||||
}
|
||||
|
||||
private List<Field> FindCommonFields() {
|
||||
List<Field> returnFields = null;
|
||||
if (boundContainers.Count > 0) {
|
||||
|
||||
private IList<IField> FindCommonFields()
|
||||
{
|
||||
IList<IField> returnFields = null;
|
||||
if (_boundContainers.Count > 0)
|
||||
{
|
||||
// take all fields from the least selected container...
|
||||
DrawableContainer leastSelectedContainer = boundContainers[boundContainers.Count - 1] as DrawableContainer;
|
||||
if (leastSelectedContainer != null) {
|
||||
DrawableContainer leastSelectedContainer = _boundContainers[_boundContainers.Count - 1] as DrawableContainer;
|
||||
if (leastSelectedContainer != null)
|
||||
{
|
||||
returnFields = leastSelectedContainer.GetFields();
|
||||
for (int i = 0; i < boundContainers.Count - 1; i++) {
|
||||
DrawableContainer dc = boundContainers[i] as DrawableContainer;
|
||||
if (dc != null) {
|
||||
List<Field> fieldsToRemove = new List<Field>();
|
||||
foreach (Field f in returnFields) {
|
||||
for (int i = 0; i < _boundContainers.Count - 1; i++)
|
||||
{
|
||||
DrawableContainer dc = _boundContainers[i] as DrawableContainer;
|
||||
if (dc != null)
|
||||
{
|
||||
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(f.FieldType)) {
|
||||
fieldsToRemove.Add(f);
|
||||
if (!dc.HasField(field.FieldType))
|
||||
{
|
||||
fieldsToRemove.Add(field);
|
||||
}
|
||||
}
|
||||
foreach (Field f in fieldsToRemove) {
|
||||
returnFields.Remove(f);
|
||||
foreach (var field in fieldsToRemove)
|
||||
{
|
||||
returnFields.Remove(field);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (returnFields == null) {
|
||||
returnFields = new List<Field>();
|
||||
}
|
||||
return returnFields;
|
||||
return returnFields ?? new List<IField>();
|
||||
}
|
||||
|
||||
public void OwnPropertyChanged(object sender, PropertyChangedEventArgs ea) {
|
||||
Field field = (Field) sender;
|
||||
if (!internalUpdateRunning && field.Value != null) {
|
||||
foreach(DrawableContainer drawableContainer in boundContainers) {
|
||||
if (drawableContainer.HasField(field.FieldType)) {
|
||||
Field 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
|
||||
editorConfiguration.UpdateLastFieldValue(drawableContainerField);
|
||||
}
|
||||
public void OwnPropertyChanged(object sender, PropertyChangedEventArgs ea)
|
||||
{
|
||||
IField field = (IField)sender;
|
||||
if (_internalUpdateRunning || field.Value == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
foreach (var drawableContainer1 in _boundContainers)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -18,38 +18,41 @@
|
|||
* 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 {
|
||||
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 {
|
||||
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 readonly FieldType ARROWHEADS = new FieldType("ARROWHEADS");
|
||||
public static readonly FieldType BLUR_RADIUS = new FieldType("BLUR_RADIUS");
|
||||
public static readonly FieldType BRIGHTNESS = new FieldType("BRIGHTNESS");
|
||||
public static readonly FieldType FILL_COLOR = new FieldType("FILL_COLOR");
|
||||
public static readonly FieldType FONT_BOLD = new FieldType("FONT_BOLD");
|
||||
public static readonly FieldType FONT_FAMILY = new FieldType("FONT_FAMILY");
|
||||
public static readonly FieldType FONT_ITALIC = new FieldType("FONT_ITALIC");
|
||||
public static readonly FieldType FONT_SIZE = new FieldType("FONT_SIZE");
|
||||
public static readonly FieldType TEXT_HORIZONTAL_ALIGNMENT = new FieldType("TEXT_HORIZONTAL_ALIGNMENT");
|
||||
public static readonly FieldType TEXT_VERTICAL_ALIGNMENT = new FieldType("TEXT_VERTICAL_ALIGNMENT");
|
||||
public static readonly FieldType HIGHLIGHT_COLOR = new FieldType("HIGHLIGHT_COLOR");
|
||||
public static readonly FieldType LINE_COLOR = new FieldType("LINE_COLOR");
|
||||
public static readonly FieldType LINE_THICKNESS = new FieldType("LINE_THICKNESS");
|
||||
public static readonly FieldType MAGNIFICATION_FACTOR = new FieldType("MAGNIFICATION_FACTOR");
|
||||
public static readonly FieldType PIXEL_SIZE = new FieldType("PIXEL_SIZE");
|
||||
public static readonly FieldType PREVIEW_QUALITY = new FieldType("PREVIEW_QUALITY");
|
||||
public static readonly FieldType SHADOW = new FieldType("SHADOW");
|
||||
public static readonly FieldType PREPARED_FILTER_OBFUSCATE = new FieldType("PREPARED_FILTER_OBFUSCATE");
|
||||
public static readonly FieldType PREPARED_FILTER_HIGHLIGHT = new FieldType("PREPARED_FILTER_HIGHLIGHT");
|
||||
public static readonly FieldType FLAGS = new FieldType("FLAGS");
|
||||
|
||||
public static FieldType[] Values = new FieldType[]{
|
||||
public static IFieldType[] Values = {
|
||||
ARROWHEADS,
|
||||
BLUR_RADIUS,
|
||||
BRIGHTNESS,
|
||||
|
@ -66,53 +69,55 @@ namespace Greenshot.Drawing.Fields {
|
|||
MAGNIFICATION_FACTOR,
|
||||
PIXEL_SIZE,
|
||||
PREVIEW_QUALITY,
|
||||
SHADOW,
|
||||
SHADOW,
|
||||
PREPARED_FILTER_OBFUSCATE,
|
||||
PREPARED_FILTER_HIGHLIGHT,
|
||||
PREPARED_FILTER_HIGHLIGHT,
|
||||
FLAGS
|
||||
};
|
||||
|
||||
[Flags]
|
||||
public enum Flag {
|
||||
NONE = 0,
|
||||
CONFIRMABLE = 1
|
||||
|
||||
public string Name
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
|
||||
public string Name;
|
||||
private FieldType(string name) {
|
||||
|
||||
private FieldType(string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
public override string ToString() {
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = 0;
|
||||
unchecked {
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
public static bool operator !=(FieldType a, FieldType b) {
|
||||
return !Equals(a,b);
|
||||
|
||||
public static bool operator !=(FieldType a, FieldType b)
|
||||
{
|
||||
return !Equals(a, b);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2007-2015 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -24,6 +24,7 @@ using Greenshot.Drawing.Fields;
|
|||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -40,6 +41,18 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
|
||||
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() {
|
||||
|
@ -52,7 +65,7 @@ namespace Greenshot.Drawing {
|
|||
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
|
||||
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
|
||||
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
|
||||
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
|
||||
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
|
||||
if (lineVisible) {
|
||||
graphics.SmoothingMode = SmoothingMode.HighSpeed;
|
||||
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
|
@ -69,7 +82,7 @@ namespace Greenshot.Drawing {
|
|||
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + currentStep, Top + currentStep, Width, Height);
|
||||
graphics.DrawRectangle(shadowPen, shadowRect);
|
||||
currentStep++;
|
||||
alpha = alpha - (basealpha / steps);
|
||||
alpha = alpha - basealpha / steps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -25,13 +25,13 @@ using System.Drawing;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
|
||||
/// <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>
|
||||
namespace Greenshot.Drawing.Filters {
|
||||
[Serializable()]
|
||||
/// <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]
|
||||
|
@ -41,7 +41,7 @@ namespace Greenshot.Drawing.Filters {
|
|||
remove{ propertyChanged -= value; }
|
||||
}
|
||||
|
||||
private bool invert = false;
|
||||
private bool invert;
|
||||
public bool Invert {
|
||||
get {
|
||||
return invert;
|
||||
|
@ -72,10 +72,9 @@ namespace Greenshot.Drawing.Filters {
|
|||
|
||||
public abstract void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode);
|
||||
|
||||
protected void OnPropertyChanged(string propertyName) {
|
||||
if (propertyChanged != null) {
|
||||
propertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
protected void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
propertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -18,6 +18,7 @@
|
|||
* 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;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -21,11 +21,11 @@
|
|||
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
|
||||
namespace Greenshot.Drawing.Filters {
|
||||
namespace Greenshot.Drawing.Filters
|
||||
{
|
||||
public interface IFilter : INotifyPropertyChanged, IFieldHolder {
|
||||
DrawableContainer Parent {get; set; }
|
||||
void Apply(Graphics graphics, Bitmap bmp, Rectangle rect, RenderMode renderMode);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -53,7 +53,7 @@ namespace Greenshot.Drawing.Filters {
|
|||
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);
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -37,7 +37,7 @@ namespace Greenshot.Drawing.Filters {
|
|||
|
||||
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
|
||||
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
|
||||
Rectangle applyRect = ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||
ImageHelper.CreateIntersectRectangle(applyBitmap.Size, rect, Invert);
|
||||
if (pixelSize <= 1 || rect.Width == 0 || rect.Height == 0) {
|
||||
// Nothing to do
|
||||
return;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -22,7 +22,6 @@
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
@ -35,21 +34,19 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
[Serializable]
|
||||
public class FreehandContainer : DrawableContainer {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(FreehandContainer));
|
||||
private static readonly float [] POINT_OFFSET = new float[]{0.5f, 0.25f, 0.75f};
|
||||
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 List<Point> capturePoints = new List<Point>();
|
||||
private bool isRecalculated = false;
|
||||
private readonly List<Point> capturePoints = new List<Point>();
|
||||
private bool isRecalculated;
|
||||
|
||||
/// <summary>
|
||||
/// Constructor
|
||||
/// </summary>
|
||||
public FreehandContainer(Surface parent) : base(parent) {
|
||||
Init();
|
||||
Width = parent.Width;
|
||||
Height = parent.Height;
|
||||
Top = 0;
|
||||
|
@ -61,16 +58,6 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
|
||||
}
|
||||
|
||||
|
||||
protected void Init() {
|
||||
if (_grippers != null) {
|
||||
for (int i = 0; i < _grippers.Length; i++) {
|
||||
_grippers[i].Enabled = false;
|
||||
_grippers[i].Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void Transform(Matrix matrix) {
|
||||
Point[] points = capturePoints.ToArray();
|
||||
|
||||
|
@ -80,11 +67,7 @@ namespace Greenshot.Drawing {
|
|||
RecalculatePath();
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
InitGrippers();
|
||||
DoLayout();
|
||||
Init();
|
||||
protected override void OnDeserialized(StreamingContext context) {
|
||||
RecalculatePath();
|
||||
}
|
||||
|
||||
|
@ -94,10 +77,9 @@ namespace Greenshot.Drawing {
|
|||
/// <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) {
|
||||
if (freehandPath != null) {
|
||||
freehandPath.Dispose();
|
||||
}
|
||||
if (disposing)
|
||||
{
|
||||
freehandPath?.Dispose();
|
||||
}
|
||||
freehandPath = null;
|
||||
}
|
||||
|
@ -119,7 +101,7 @@ namespace Greenshot.Drawing {
|
|||
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)) {
|
||||
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) {
|
||||
|
@ -150,9 +132,7 @@ namespace Greenshot.Drawing {
|
|||
private void RecalculatePath() {
|
||||
isRecalculated = true;
|
||||
// Dispose the previous path, if we have one
|
||||
if (freehandPath != null) {
|
||||
freehandPath.Dispose();
|
||||
}
|
||||
freehandPath?.Dispose();
|
||||
freehandPath = new GraphicsPath();
|
||||
|
||||
// Here we can put some cleanup... like losing all the uninteresting points.
|
||||
|
@ -160,7 +140,7 @@ namespace Greenshot.Drawing {
|
|||
int index = 0;
|
||||
while ((capturePoints.Count - 1) % 3 != 0) {
|
||||
// duplicate points, first at 50% than 25% than 75%
|
||||
capturePoints.Insert((int)(capturePoints.Count*POINT_OFFSET[index]), capturePoints[(int)(capturePoints.Count*POINT_OFFSET[index++])]);
|
||||
capturePoints.Insert((int)(capturePoints.Count*PointOffset[index]), capturePoints[(int)(capturePoints.Count*PointOffset[index++])]);
|
||||
}
|
||||
freehandPath.AddBeziers(capturePoints.ToArray());
|
||||
} else if (capturePoints.Count == 2) {
|
||||
|
@ -232,9 +212,9 @@ namespace Greenshot.Drawing {
|
|||
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(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, _parent.Height);
|
||||
return new Rectangle(0, 0, _parent?.Width??0, _parent?.Height?? 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -245,9 +225,9 @@ namespace Greenshot.Drawing {
|
|||
/// <returns></returns>
|
||||
public override bool Equals(object obj) {
|
||||
bool ret = false;
|
||||
if(obj != null && GetType().Equals(obj.GetType())) {
|
||||
if(obj != null && GetType() == obj.GetType()) {
|
||||
FreehandContainer other = obj as FreehandContainer;
|
||||
if(freehandPath.Equals(other.freehandPath)) {
|
||||
if(other != null && freehandPath.Equals(other.freehandPath)) {
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
@ -258,17 +238,6 @@ namespace Greenshot.Drawing {
|
|||
return freehandPath.GetHashCode();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is overriden to prevent the grippers to be modified.
|
||||
/// Might not be the best way...
|
||||
/// </summary>
|
||||
protected override void DoLayout() {
|
||||
}
|
||||
|
||||
public override void ShowGrippers() {
|
||||
ResumeLayout();
|
||||
}
|
||||
|
||||
public override bool ClickableAt(int x, int y) {
|
||||
bool returnValue = base.ClickableAt(x, y);
|
||||
if (returnValue) {
|
||||
|
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 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.Windows.Forms;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
/// Grippers are the dragable edges of our containers
|
||||
/// </summary>
|
||||
public class Gripper : Label {
|
||||
/// <summary>
|
||||
/// Constants for anchor/gripper position:
|
||||
/// 0 1 2
|
||||
/// 7 3
|
||||
/// 6 5 4
|
||||
/// </summary>
|
||||
public const int POSITION_TOP_LEFT = 0;
|
||||
public const int POSITION_TOP_CENTER = 1;
|
||||
public const int POSITION_TOP_RIGHT = 2;
|
||||
public const int POSITION_MIDDLE_RIGHT = 3;
|
||||
public const int POSITION_BOTTOM_RIGHT = 4;
|
||||
public const int POSITION_BOTTOM_CENTER = 5;
|
||||
public const int POSITION_BOTTOM_LEFT = 6;
|
||||
public const int POSITION_MIDDLE_LEFT = 7;
|
||||
|
||||
public int Position {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Gripper() {
|
||||
Width = 5;
|
||||
Height = 5;
|
||||
BackColor = Color.Black;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -19,11 +19,11 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Drawing.Filters;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -43,8 +43,8 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.PREPARED_FILTER_HIGHLIGHT, PreparedFilter.TEXT_HIGHTLIGHT);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
|
@ -57,7 +57,7 @@ namespace Greenshot.Drawing {
|
|||
if (!sender.Equals(this)) {
|
||||
return;
|
||||
}
|
||||
if (e.Field.FieldType == FieldType.PREPARED_FILTER_HIGHLIGHT) {
|
||||
if (Equals(e.Field.FieldType, FieldType.PREPARED_FILTER_HIGHLIGHT)) {
|
||||
ConfigurePreparedFilters();
|
||||
}
|
||||
}
|
||||
|
@ -72,12 +72,16 @@ namespace Greenshot.Drawing {
|
|||
Add(new HighlightFilter(this));
|
||||
break;
|
||||
case PreparedFilter.AREA_HIGHLIGHT:
|
||||
AbstractFilter bf = new BrightnessFilter(this);
|
||||
bf.Invert = true;
|
||||
Add(bf);
|
||||
bf = new BlurFilter(this);
|
||||
bf.Invert = true;
|
||||
Add(bf);
|
||||
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);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -24,6 +24,7 @@ using System.IO;
|
|||
using Greenshot.Plugin.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using log4net;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -31,11 +32,23 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
[Serializable]
|
||||
public class IconContainer : DrawableContainer, IIconContainer {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(IconContainer));
|
||||
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) {
|
||||
|
@ -44,9 +57,7 @@ namespace Greenshot.Drawing {
|
|||
|
||||
public Icon Icon {
|
||||
set {
|
||||
if (icon != null) {
|
||||
icon.Dispose();
|
||||
}
|
||||
icon?.Dispose();
|
||||
icon = (Icon)value.Clone();
|
||||
Width = value.Width;
|
||||
Height = value.Height;
|
||||
|
@ -59,10 +70,9 @@ namespace Greenshot.Drawing {
|
|||
* When disposing==true all non-managed resources should be freed too!
|
||||
*/
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
if (icon != null) {
|
||||
icon.Dispose();
|
||||
}
|
||||
if (disposing)
|
||||
{
|
||||
icon?.Dispose();
|
||||
}
|
||||
icon = null;
|
||||
base.Dispose(disposing);
|
||||
|
@ -72,7 +82,7 @@ namespace Greenshot.Drawing {
|
|||
if (File.Exists(filename)) {
|
||||
using (Icon fileIcon = new Icon(filename)) {
|
||||
Icon = fileIcon;
|
||||
LOG.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
|
||||
Log.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,16 +97,8 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
}
|
||||
|
||||
public override bool HasDefaultSize {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public override bool HasDefaultSize => true;
|
||||
|
||||
public override Size DefaultSize {
|
||||
get {
|
||||
return icon.Size;
|
||||
}
|
||||
}
|
||||
public override Size DefaultSize => icon.Size;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -25,8 +25,10 @@ using Greenshot.Drawing.Fields;
|
|||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Core;
|
||||
using System.Drawing.Drawing2D;
|
||||
using Greenshot.Core;
|
||||
using log4net;
|
||||
using System.Runtime.Serialization;
|
||||
using GreenshotPlugin.Effects;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -34,7 +36,7 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
[Serializable]
|
||||
public class ImageContainer : DrawableContainer, IImageContainer {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(ImageContainer));
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(ImageContainer));
|
||||
|
||||
private Image image;
|
||||
|
||||
|
@ -58,6 +60,18 @@ namespace Greenshot.Drawing {
|
|||
|
||||
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() {
|
||||
|
@ -66,7 +80,7 @@ namespace Greenshot.Drawing {
|
|||
|
||||
protected void BitmapContainer_OnFieldChanged(object sender, FieldChangedEventArgs e) {
|
||||
if (sender.Equals(this)) {
|
||||
if (e.Field.FieldType == FieldType.SHADOW) {
|
||||
if (FieldType.SHADOW.Equals(e.Field.FieldType)) {
|
||||
ChangeShadowField();
|
||||
}
|
||||
}
|
||||
|
@ -126,15 +140,11 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
|
||||
private void DisposeImage() {
|
||||
if (image != null) {
|
||||
image.Dispose();
|
||||
}
|
||||
image?.Dispose();
|
||||
image = null;
|
||||
}
|
||||
private void DisposeShadow() {
|
||||
if (_shadowBitmap != null) {
|
||||
_shadowBitmap.Dispose();
|
||||
}
|
||||
_shadowBitmap?.Dispose();
|
||||
_shadowBitmap = null;
|
||||
}
|
||||
|
||||
|
@ -148,10 +158,11 @@ namespace Greenshot.Drawing {
|
|||
int rotateAngle = CalculateAngle(matrix);
|
||||
// we currently assume only one transformation has been made.
|
||||
if (rotateAngle != 0) {
|
||||
LOG.DebugFormat("Rotating element with {0} degrees.", rotateAngle);
|
||||
Log.DebugFormat("Rotating element with {0} degrees.", rotateAngle);
|
||||
DisposeShadow();
|
||||
using (var tmpMatrix = new Matrix()) {
|
||||
using (Image tmpImage = image) {
|
||||
using (image)
|
||||
{
|
||||
image = ImageHelper.ApplyEffect(image, new RotateEffect(rotateAngle), tmpMatrix);
|
||||
}
|
||||
}
|
||||
|
@ -164,14 +175,16 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
/// <param name="filename"></param>
|
||||
public void Load(string filename) {
|
||||
if (File.Exists(filename)) {
|
||||
// Always make sure ImageHelper.LoadBitmap results are disposed some time,
|
||||
// as we close the bitmap internally, we need to do it afterwards
|
||||
using (Image tmpImage = ImageHelper.LoadImage(filename)) {
|
||||
Image = tmpImage;
|
||||
}
|
||||
LOG.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
|
||||
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>
|
||||
|
@ -208,16 +221,8 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
}
|
||||
|
||||
public override bool HasDefaultSize {
|
||||
get {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public override bool HasDefaultSize => true;
|
||||
|
||||
public override Size DefaultSize {
|
||||
get {
|
||||
return image.Size;
|
||||
}
|
||||
}
|
||||
public override Size DefaultSize => image.Size;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -26,6 +26,7 @@ using System.Runtime.Serialization;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using Greenshot.Drawing.Adorners;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -45,19 +46,14 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.SHADOW, true);
|
||||
}
|
||||
|
||||
[OnDeserialized()]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
InitGrippers();
|
||||
DoLayout();
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
protected void Init() {
|
||||
if (_grippers != null) {
|
||||
foreach (int index in new[] { 1, 2, 3, 5, 6, 7 }) {
|
||||
_grippers[index].Enabled = false;
|
||||
}
|
||||
}
|
||||
Adorners.Add(new MoveAdorner(this, Positions.TopLeft));
|
||||
Adorners.Add(new MoveAdorner(this, Positions.BottomRight));
|
||||
}
|
||||
|
||||
public override void Draw(Graphics graphics, RenderMode rm) {
|
||||
|
@ -86,7 +82,7 @@ namespace Greenshot.Drawing {
|
|||
Top + currentStep + Height);
|
||||
|
||||
currentStep++;
|
||||
alpha = alpha - (basealpha / steps);
|
||||
alpha = alpha - basealpha / steps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,8 +109,6 @@ namespace Greenshot.Drawing {
|
|||
|
||||
protected override ScaleHelper.IDoubleProcessor GetAngleRoundProcessor() {
|
||||
return ScaleHelper.LineAngleRoundBehavior.Instance;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -22,6 +22,7 @@ using System;
|
|||
using System.Runtime.Serialization;
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Drawing.Filters;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -37,20 +38,21 @@ namespace Greenshot.Drawing {
|
|||
base.InitializeFields();
|
||||
AddField(GetType(), FieldType.PREPARED_FILTER_OBFUSCATE, PreparedFilter.PIXELIZE);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
|
||||
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(e.Field.FieldType == FieldType.PREPARED_FILTER_OBFUSCATE) {
|
||||
if(Equals(e.Field.FieldType, FieldType.PREPARED_FILTER_OBFUSCATE)) {
|
||||
ConfigurePreparedFilters();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2014 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
|
@ -18,12 +18,21 @@
|
|||
* 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.Text;
|
||||
using GreenshotPlugin.Controls;
|
||||
|
||||
namespace PluginExample {
|
||||
public class ExampleForm : GreenshotForm{
|
||||
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
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -25,6 +25,7 @@ using System.Drawing.Drawing2D;
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -34,6 +35,22 @@ namespace Greenshot.Drawing {
|
|||
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() {
|
||||
|
@ -69,7 +86,7 @@ namespace Greenshot.Drawing {
|
|||
graphics.CompositingQuality = CompositingQuality.HighQuality;
|
||||
graphics.PixelOffsetMode = PixelOffsetMode.None;
|
||||
|
||||
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
|
||||
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
|
||||
if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
|
||||
//draw shadow first
|
||||
int basealpha = 100;
|
||||
|
@ -86,7 +103,7 @@ namespace Greenshot.Drawing {
|
|||
rect.Height);
|
||||
graphics.DrawRectangle(shadowPen, shadowRect);
|
||||
currentStep++;
|
||||
alpha = alpha - (basealpha / steps);
|
||||
alpha = alpha - basealpha / steps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -19,6 +19,7 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
|
@ -27,6 +28,7 @@ namespace Greenshot.Drawing {
|
|||
/// 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,
|
||||
|
@ -35,13 +37,13 @@ namespace Greenshot.Drawing {
|
|||
|
||||
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.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();
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2007-2012 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/
|
||||
* 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
|
||||
|
@ -21,17 +21,15 @@
|
|||
|
||||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows.Forms;
|
||||
using log4net;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
namespace Greenshot.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Description of SpeechbubbleContainer.
|
||||
/// </summary>
|
||||
|
@ -50,8 +48,8 @@ namespace Greenshot.Drawing {
|
|||
/// <param name="context"></param>
|
||||
[OnSerializing]
|
||||
private void SetValuesOnSerializing(StreamingContext context) {
|
||||
if (TargetGripper != null) {
|
||||
_storedTargetGripperLocation = TargetGripper.Location;
|
||||
if (TargetAdorner != null) {
|
||||
_storedTargetGripperLocation = TargetAdorner.Location;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,9 +57,9 @@ namespace Greenshot.Drawing {
|
|||
/// Restore the target gripper
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[OnDeserialized]
|
||||
private void SetValuesOnDeserialized(StreamingContext context) {
|
||||
InitTargetGripper(Color.Green, _storedTargetGripperLocation);
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
InitAdorner(Color.Green, _storedTargetGripperLocation);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -90,9 +88,9 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
/// <returns>true if the surface doesn't need to handle the event</returns>
|
||||
public override bool HandleMouseDown(int mouseX, int mouseY) {
|
||||
if (TargetGripper == null) {
|
||||
if (TargetAdorner == null) {
|
||||
_initialGripperPoint = new Point(mouseX, mouseY);
|
||||
InitTargetGripper(Color.Green, new Point(mouseX, mouseY));
|
||||
InitAdorner(Color.Green, new Point(mouseX, mouseY));
|
||||
}
|
||||
return base.HandleMouseDown(mouseX, mouseY);
|
||||
}
|
||||
|
@ -116,9 +114,9 @@ namespace Greenshot.Drawing {
|
|||
Point newGripperLocation = _initialGripperPoint;
|
||||
newGripperLocation.Offset(xOffset, yOffset);
|
||||
|
||||
if (TargetGripper.Location != newGripperLocation) {
|
||||
if (TargetAdorner.Location != newGripperLocation) {
|
||||
Invalidate();
|
||||
TargetGripperMove(newGripperLocation.X, newGripperLocation.Y);
|
||||
TargetAdorner.Location = newGripperLocation;
|
||||
Invalidate();
|
||||
}
|
||||
return returnValue;
|
||||
|
@ -180,7 +178,7 @@ namespace Greenshot.Drawing {
|
|||
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), TargetGripper.Left, TargetGripper.Top);
|
||||
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
|
||||
|
@ -192,10 +190,10 @@ namespace Greenshot.Drawing {
|
|||
tail.AddLine(tailWidth, 0, 0, -tailLength);
|
||||
tail.CloseFigure();
|
||||
|
||||
int tailAngle = 90 + (int)GeometryHelper.Angle2D(rect.Left + (rect.Width / 2), rect.Top + (rect.Height / 2), TargetGripper.Left, TargetGripper.Top);
|
||||
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.Translate(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);
|
||||
tailMatrix.Rotate(tailAngle);
|
||||
tail.Transform(tailMatrix);
|
||||
}
|
||||
|
@ -209,7 +207,7 @@ namespace Greenshot.Drawing {
|
|||
/// <param name="graphics"></param>
|
||||
/// <param name="renderMode"></param>
|
||||
public override void Draw(Graphics graphics, RenderMode renderMode) {
|
||||
if (TargetGripper == null) {
|
||||
if (TargetAdorner == null) {
|
||||
return;
|
||||
}
|
||||
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
@ -223,7 +221,7 @@ namespace Greenshot.Drawing {
|
|||
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
|
||||
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
|
||||
|
||||
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
|
||||
bool lineVisible = lineThickness > 0 && Colors.IsVisible(lineColor);
|
||||
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
||||
|
||||
if (Selected && renderMode == RenderMode.EDIT) {
|
||||
|
@ -253,7 +251,7 @@ namespace Greenshot.Drawing {
|
|||
graphics.DrawPath(shadowPen, bubbleClone);
|
||||
}
|
||||
currentStep++;
|
||||
alpha = alpha - (basealpha / steps);
|
||||
alpha = alpha - basealpha / steps;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Copyright (C) 2007-2012 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/
|
||||
* 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
|
||||
|
@ -27,6 +27,7 @@ using System.Drawing;
|
|||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.Runtime.Serialization;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
/// <summary>
|
||||
|
@ -34,7 +35,7 @@ namespace Greenshot.Drawing {
|
|||
/// To make sure that deleting recalculates, we check the location before every draw.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class StepLabelContainer : DrawableContainer {
|
||||
public sealed class StepLabelContainer : DrawableContainer {
|
||||
[NonSerialized]
|
||||
private StringFormat _stringFormat = new StringFormat();
|
||||
|
||||
|
@ -45,11 +46,19 @@ namespace Greenshot.Drawing {
|
|||
public StepLabelContainer(Surface parent) : base(parent) {
|
||||
parent.AddStepLabel(this);
|
||||
InitContent();
|
||||
Init();
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
CreateDefaultAdorners();
|
||||
}
|
||||
|
||||
#region Number serializing
|
||||
// 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;
|
||||
|
@ -67,6 +76,7 @@ namespace Greenshot.Drawing {
|
|||
private void SetValuesOnSerializing(StreamingContext context) {
|
||||
if (Parent != null) {
|
||||
Number = ((Surface)Parent).CountStepLabels(this);
|
||||
_counterStart = ((Surface) Parent).CounterStart;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -75,11 +85,15 @@ namespace Greenshot.Drawing {
|
|||
/// Restore values that don't serialize
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
[OnDeserialized]
|
||||
private void SetValuesOnDeserialized(StreamingContext context) {
|
||||
_stringFormat = new StringFormat();
|
||||
_stringFormat.Alignment = StringAlignment.Center;
|
||||
_stringFormat.LineAlignment = StringAlignment.Center;
|
||||
protected override void OnDeserialized(StreamingContext context)
|
||||
{
|
||||
Init();
|
||||
_stringFormat = new StringFormat
|
||||
{
|
||||
Alignment = StringAlignment.Center,
|
||||
LineAlignment = StringAlignment.Center
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -87,20 +101,22 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
/// <param name="newParent"></param>
|
||||
protected override void SwitchParent(Surface newParent) {
|
||||
if (Parent != null) {
|
||||
((Surface)Parent).RemoveStepLabel(this);
|
||||
if (newParent == Parent)
|
||||
{
|
||||
return;
|
||||
}
|
||||
((Surface) Parent)?.RemoveStepLabel(this);
|
||||
base.SwitchParent(newParent);
|
||||
if (newParent != null) {
|
||||
((Surface)Parent).AddStepLabel(this);
|
||||
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 {
|
||||
get {
|
||||
return new Size(30, 30);
|
||||
}
|
||||
}
|
||||
public override Size DefaultSize => new Size(30, 30);
|
||||
|
||||
public override bool InitContent() {
|
||||
_defaultEditMode = EditStatus.IDLE;
|
||||
|
@ -118,7 +134,7 @@ namespace Greenshot.Drawing {
|
|||
/// 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));
|
||||
return base.HandleMouseDown(mouseX - Width / 2, mouseY - Height / 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -127,6 +143,7 @@ namespace Greenshot.Drawing {
|
|||
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>
|
||||
|
@ -137,17 +154,19 @@ namespace Greenshot.Drawing {
|
|||
if (!disposing) {
|
||||
return;
|
||||
}
|
||||
((Surface)Parent).RemoveStepLabel(this);
|
||||
if (_stringFormat != null) {
|
||||
_stringFormat.Dispose();
|
||||
_stringFormat = null;
|
||||
((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);
|
||||
Left = x - Width / 2;
|
||||
Top = y - Height / 2;
|
||||
Invalidate();
|
||||
return true;
|
||||
}
|
||||
|
@ -167,7 +186,7 @@ namespace Greenshot.Drawing {
|
|||
|
||||
int widthAfter = rect.Width;
|
||||
int heightAfter = rect.Height;
|
||||
float factor = (((float)widthAfter / widthBefore) + ((float)heightAfter / heightBefore)) / 2;
|
||||
float factor = ((float)widthAfter / widthBefore + (float)heightAfter / heightBefore) / 2;
|
||||
|
||||
fontSize *= factor;
|
||||
}
|
||||
|
@ -193,8 +212,8 @@ namespace Greenshot.Drawing {
|
|||
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);
|
||||
using (Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel)) {
|
||||
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -22,32 +22,33 @@
|
|||
using Greenshot.Drawing.Fields;
|
||||
using Greenshot.Helpers;
|
||||
using Greenshot.Memento;
|
||||
using Greenshot.Plugin;
|
||||
using Greenshot.Plugin.Drawing;
|
||||
using GreenshotPlugin.Interfaces.Drawing;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Text;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Greenshot.Drawing {
|
||||
namespace Greenshot.Drawing
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a textbox (extends RectangleContainer for border/background support
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class TextContainer : RectangleContainer, ITextContainer {
|
||||
[Serializable]
|
||||
public class TextContainer : RectangleContainer, ITextContainer
|
||||
{
|
||||
// If makeUndoable is true the next text-change will make the change undoable.
|
||||
// This is set to true AFTER the first change is made, as there is already a "add element" on the undo stack
|
||||
// Although the name is wrong, we can't change it due to file serialization
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private bool makeUndoable;
|
||||
[NonSerialized]
|
||||
private Font _font;
|
||||
public Font Font {
|
||||
get {
|
||||
return _font;
|
||||
}
|
||||
}
|
||||
public Font Font => _font;
|
||||
|
||||
[NonSerialized]
|
||||
private TextBox _textBox;
|
||||
|
@ -56,37 +57,44 @@ namespace Greenshot.Drawing {
|
|||
/// The StringFormat object is not serializable!!
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
StringFormat _stringFormat = new StringFormat();
|
||||
public StringFormat StringFormat {
|
||||
get {
|
||||
return _stringFormat;
|
||||
}
|
||||
}
|
||||
private StringFormat _stringFormat = new StringFormat();
|
||||
|
||||
public StringFormat StringFormat => _stringFormat;
|
||||
|
||||
// Although the name is wrong, we can't change it due to file serialization
|
||||
// ReSharper disable once InconsistentNaming
|
||||
private string text;
|
||||
// there is a binding on the following property!
|
||||
public string Text {
|
||||
public string Text
|
||||
{
|
||||
get { return text; }
|
||||
set {
|
||||
set
|
||||
{
|
||||
ChangeText(value, true);
|
||||
}
|
||||
}
|
||||
|
||||
internal void ChangeText(string newText, bool allowUndoable) {
|
||||
if ((text == null && newText != null) || !text.Equals(newText)) {
|
||||
if (makeUndoable && allowUndoable) {
|
||||
|
||||
internal void ChangeText(string newText, bool allowUndoable)
|
||||
{
|
||||
if ((text == null && newText != null) || !string.Equals(text, newText))
|
||||
{
|
||||
if (makeUndoable && allowUndoable)
|
||||
{
|
||||
makeUndoable = false;
|
||||
_parent.MakeUndoable(new TextChangeMemento(this), false);
|
||||
}
|
||||
text = newText;
|
||||
OnPropertyChanged("Text");
|
||||
text = newText;
|
||||
OnPropertyChanged("Text");
|
||||
}
|
||||
}
|
||||
|
||||
public TextContainer(Surface parent) : base(parent) {
|
||||
|
||||
public TextContainer(Surface parent) : base(parent)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
protected override void InitializeFields() {
|
||||
protected override void InitializeFields()
|
||||
{
|
||||
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
|
||||
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
|
||||
AddField(GetType(), FieldType.SHADOW, true);
|
||||
|
@ -98,33 +106,46 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.TEXT_HORIZONTAL_ALIGNMENT, StringAlignment.Center);
|
||||
AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, StringAlignment.Center);
|
||||
}
|
||||
|
||||
[OnDeserialized]
|
||||
private void OnDeserialized(StreamingContext context) {
|
||||
|
||||
/// <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();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing) {
|
||||
if (_font != null) {
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_font != null)
|
||||
{
|
||||
_font.Dispose();
|
||||
_font = null;
|
||||
}
|
||||
if (_stringFormat != null) {
|
||||
if (_stringFormat != null)
|
||||
{
|
||||
_stringFormat.Dispose();
|
||||
_stringFormat = null;
|
||||
}
|
||||
if (_textBox != null) {
|
||||
if (_textBox != null)
|
||||
{
|
||||
_textBox.Dispose();
|
||||
_textBox = null;
|
||||
}
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void Init() {
|
||||
_stringFormat = new StringFormat();
|
||||
_stringFormat.Trimming = StringTrimming.EllipsisWord;
|
||||
|
||||
private void Init()
|
||||
{
|
||||
_stringFormat = new StringFormat
|
||||
{
|
||||
Trimming = StringTrimming.EllipsisWord
|
||||
};
|
||||
|
||||
CreateTextBox();
|
||||
|
||||
|
@ -136,82 +157,120 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
|
||||
|
||||
public override void Invalidate() {
|
||||
public override void Invalidate()
|
||||
{
|
||||
base.Invalidate();
|
||||
if (_textBox != null && _textBox.Visible) {
|
||||
if (_textBox != null && _textBox.Visible)
|
||||
{
|
||||
_textBox.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public void FitToText() {
|
||||
|
||||
public void FitToText()
|
||||
{
|
||||
Size textSize = TextRenderer.MeasureText(text, _font);
|
||||
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
|
||||
Width = textSize.Width + lineThickness;
|
||||
Height = textSize.Height + lineThickness;
|
||||
}
|
||||
|
||||
void TextContainer_PropertyChanged(object sender, PropertyChangedEventArgs e) {
|
||||
if (_textBox.Visible) {
|
||||
private void TextContainer_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (_textBox == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_textBox.Visible)
|
||||
{
|
||||
_textBox.Invalidate();
|
||||
}
|
||||
|
||||
UpdateTextBoxPosition();
|
||||
UpdateTextBoxFormat();
|
||||
if (e.PropertyName.Equals("Selected")) {
|
||||
if (!Selected && _textBox.Visible) {
|
||||
if (e.PropertyName.Equals("Selected"))
|
||||
{
|
||||
if (!Selected && _textBox.Visible)
|
||||
{
|
||||
HideTextBox();
|
||||
} else if (Selected && Status == EditStatus.DRAWING) {
|
||||
}
|
||||
else if (Selected && Status == EditStatus.DRAWING)
|
||||
{
|
||||
ShowTextBox();
|
||||
} else if (Selected && Status == EditStatus.IDLE && _textBox.Visible) {
|
||||
}
|
||||
else if (_parent != null && Selected && Status == EditStatus.IDLE && _textBox.Visible)
|
||||
{
|
||||
// Fix (workaround) for BUG-1698
|
||||
_parent.KeysLocked = true;
|
||||
}
|
||||
}
|
||||
if (_textBox.Visible) {
|
||||
if (_textBox.Visible)
|
||||
{
|
||||
_textBox.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
void TextContainer_FieldChanged(object sender, FieldChangedEventArgs e) {
|
||||
if (_textBox.Visible) {
|
||||
|
||||
private void TextContainer_FieldChanged(object sender, FieldChangedEventArgs e)
|
||||
{
|
||||
if (_textBox == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (_textBox.Visible)
|
||||
{
|
||||
_textBox.Invalidate();
|
||||
}
|
||||
// Only dispose the font, and re-create it, when a font field has changed.
|
||||
if (e.Field.FieldType.Name.StartsWith("FONT")) {
|
||||
_font.Dispose();
|
||||
_font = null;
|
||||
if (e.Field.FieldType.Name.StartsWith("FONT"))
|
||||
{
|
||||
if (_font != null)
|
||||
{
|
||||
_font.Dispose();
|
||||
_font = null;
|
||||
}
|
||||
UpdateFormat();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateAlignment();
|
||||
}
|
||||
UpdateTextBoxFormat();
|
||||
|
||||
if (_textBox.Visible) {
|
||||
|
||||
if (_textBox.Visible)
|
||||
{
|
||||
_textBox.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnDoubleClick() {
|
||||
|
||||
public override void OnDoubleClick()
|
||||
{
|
||||
ShowTextBox();
|
||||
}
|
||||
|
||||
private void CreateTextBox() {
|
||||
_textBox = new TextBox();
|
||||
|
||||
_textBox.ImeMode = ImeMode.On;
|
||||
_textBox.Multiline = true;
|
||||
_textBox.AcceptsTab = true;
|
||||
_textBox.AcceptsReturn = true;
|
||||
private void CreateTextBox()
|
||||
{
|
||||
_textBox = new TextBox
|
||||
{
|
||||
ImeMode = ImeMode.On,
|
||||
Multiline = true,
|
||||
AcceptsTab = true,
|
||||
AcceptsReturn = true,
|
||||
BorderStyle = BorderStyle.None,
|
||||
Visible = false
|
||||
};
|
||||
|
||||
_textBox.DataBindings.Add("Text", this, "Text", false, DataSourceUpdateMode.OnPropertyChanged);
|
||||
_textBox.LostFocus += textBox_LostFocus;
|
||||
_textBox.KeyDown += textBox_KeyDown;
|
||||
_textBox.BorderStyle = BorderStyle.None;
|
||||
_textBox.Visible = false;
|
||||
}
|
||||
|
||||
private void ShowTextBox() {
|
||||
_parent.KeysLocked = true;
|
||||
_parent.Controls.Add(_textBox);
|
||||
private void ShowTextBox()
|
||||
{
|
||||
if (_parent != null)
|
||||
{
|
||||
_parent.KeysLocked = true;
|
||||
_parent.Controls.Add(_textBox);
|
||||
}
|
||||
EnsureTextBoxContrast();
|
||||
_textBox.Show();
|
||||
_textBox.Focus();
|
||||
|
@ -220,16 +279,21 @@ namespace Greenshot.Drawing {
|
|||
/// <summary>
|
||||
/// Makes textbox background dark if text color is very bright
|
||||
/// </summary>
|
||||
private void EnsureTextBoxContrast() {
|
||||
private void EnsureTextBoxContrast()
|
||||
{
|
||||
Color lc = GetFieldValueAsColor(FieldType.LINE_COLOR);
|
||||
if (lc.R > 203 && lc.G > 203 && lc.B > 203) {
|
||||
if (lc.R > 203 && lc.G > 203 && lc.B > 203)
|
||||
{
|
||||
_textBox.BackColor = Color.FromArgb(51, 51, 51);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
_textBox.BackColor = Color.White;
|
||||
}
|
||||
}
|
||||
|
||||
private void HideTextBox() {
|
||||
|
||||
private void HideTextBox()
|
||||
{
|
||||
_parent.Focus();
|
||||
_textBox.Hide();
|
||||
_parent.KeysLocked = false;
|
||||
|
@ -240,7 +304,8 @@ namespace Greenshot.Drawing {
|
|||
/// Make sure the size of the font is scaled
|
||||
/// </summary>
|
||||
/// <param name="matrix"></param>
|
||||
public override void Transform(Matrix matrix) {
|
||||
public override void Transform(Matrix matrix)
|
||||
{
|
||||
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
||||
int pixelsBefore = rect.Width * rect.Height;
|
||||
|
||||
|
@ -257,58 +322,98 @@ namespace Greenshot.Drawing {
|
|||
UpdateFormat();
|
||||
}
|
||||
|
||||
private Font CreateFont(string fontFamilyName, bool fontBold, bool fontItalic, float fontSize)
|
||||
{
|
||||
FontStyle fontStyle = FontStyle.Regular;
|
||||
|
||||
bool hasStyle = false;
|
||||
using (var fontFamily = new FontFamily(fontFamilyName))
|
||||
{
|
||||
bool boldAvailable = fontFamily.IsStyleAvailable(FontStyle.Bold);
|
||||
if (fontBold && boldAvailable)
|
||||
{
|
||||
fontStyle |= FontStyle.Bold;
|
||||
hasStyle = true;
|
||||
}
|
||||
|
||||
bool italicAvailable = fontFamily.IsStyleAvailable(FontStyle.Italic);
|
||||
if (fontItalic && italicAvailable)
|
||||
{
|
||||
fontStyle |= FontStyle.Italic;
|
||||
hasStyle = true;
|
||||
}
|
||||
|
||||
if (!hasStyle)
|
||||
{
|
||||
bool regularAvailable = fontFamily.IsStyleAvailable(FontStyle.Regular);
|
||||
if (regularAvailable)
|
||||
{
|
||||
fontStyle = FontStyle.Regular;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (boldAvailable)
|
||||
{
|
||||
fontStyle = FontStyle.Bold;
|
||||
}
|
||||
else if (italicAvailable)
|
||||
{
|
||||
fontStyle = FontStyle.Italic;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Font(fontFamily, fontSize, fontStyle, GraphicsUnit.Pixel);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate the Font-Formal so we can draw correctly
|
||||
/// </summary>
|
||||
protected void UpdateFormat() {
|
||||
protected void UpdateFormat()
|
||||
{
|
||||
if (_textBox == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
string fontFamily = GetFieldValueAsString(FieldType.FONT_FAMILY);
|
||||
bool fontBold = GetFieldValueAsBool(FieldType.FONT_BOLD);
|
||||
bool fontItalic = GetFieldValueAsBool(FieldType.FONT_ITALIC);
|
||||
float fontSize = GetFieldValueAsFloat(FieldType.FONT_SIZE);
|
||||
try {
|
||||
FontStyle fs = FontStyle.Regular;
|
||||
|
||||
bool hasStyle = false;
|
||||
using(FontFamily fam = new FontFamily(fontFamily)) {
|
||||
bool boldAvailable = fam.IsStyleAvailable(FontStyle.Bold);
|
||||
if (fontBold && boldAvailable) {
|
||||
fs |= FontStyle.Bold;
|
||||
hasStyle = true;
|
||||
}
|
||||
|
||||
bool italicAvailable = fam.IsStyleAvailable(FontStyle.Italic);
|
||||
if (fontItalic && italicAvailable) {
|
||||
fs |= FontStyle.Italic;
|
||||
hasStyle = true;
|
||||
}
|
||||
|
||||
if (!hasStyle) {
|
||||
bool regularAvailable = fam.IsStyleAvailable(FontStyle.Regular);
|
||||
if (regularAvailable) {
|
||||
fs = FontStyle.Regular;
|
||||
} else {
|
||||
if (boldAvailable) {
|
||||
fs = FontStyle.Bold;
|
||||
} else if(italicAvailable) {
|
||||
fs = FontStyle.Italic;
|
||||
}
|
||||
}
|
||||
}
|
||||
_font = new Font(fam, fontSize, fs, GraphicsUnit.Pixel);
|
||||
try
|
||||
{
|
||||
var newFont = CreateFont(fontFamily, fontBold, fontItalic, fontSize);
|
||||
_font?.Dispose();
|
||||
_font = newFont;
|
||||
_textBox.Font = _font;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Problem, try again with the default
|
||||
try
|
||||
{
|
||||
fontFamily = FontFamily.GenericSansSerif.Name;
|
||||
SetFieldValue(FieldType.FONT_FAMILY, fontFamily);
|
||||
var newFont = CreateFont(fontFamily, fontBold, fontItalic, fontSize);
|
||||
_font?.Dispose();
|
||||
_font = newFont;
|
||||
_textBox.Font = _font;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.Data.Add("fontFamily", fontFamily);
|
||||
ex.Data.Add("fontBold", fontBold);
|
||||
ex.Data.Add("fontItalic", fontItalic);
|
||||
ex.Data.Add("fontSize", fontSize);
|
||||
throw;
|
||||
catch (Exception)
|
||||
{
|
||||
// When this happens... the PC is broken
|
||||
ex.Data.Add("fontFamilyName", fontFamily);
|
||||
ex.Data.Add("fontBold", fontBold);
|
||||
ex.Data.Add("fontItalic", fontItalic);
|
||||
ex.Data.Add("fontSize", fontSize);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdateAlignment();
|
||||
}
|
||||
|
||||
private void UpdateAlignment() {
|
||||
private void UpdateAlignment()
|
||||
{
|
||||
_stringFormat.Alignment = (StringAlignment)GetFieldValue(FieldType.TEXT_HORIZONTAL_ALIGNMENT);
|
||||
_stringFormat.LineAlignment = (StringAlignment)GetFieldValue(FieldType.TEXT_VERTICAL_ALIGNMENT);
|
||||
}
|
||||
|
@ -317,36 +422,43 @@ namespace Greenshot.Drawing {
|
|||
/// This will create the textbox exactly to the inner size of the element
|
||||
/// is a bit of a hack, but for now it seems to work...
|
||||
/// </summary>
|
||||
private void UpdateTextBoxPosition() {
|
||||
private void UpdateTextBoxPosition()
|
||||
{
|
||||
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
|
||||
|
||||
int lineWidth = (int)Math.Floor(lineThickness / 2d);
|
||||
int correction = (lineThickness +1 ) % 2;
|
||||
if (lineThickness <= 1) {
|
||||
int correction = (lineThickness + 1) % 2;
|
||||
if (lineThickness <= 1)
|
||||
{
|
||||
lineWidth = 1;
|
||||
correction = -1;
|
||||
}
|
||||
Rectangle absRectangle = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
||||
_textBox.Left = absRectangle.Left + lineWidth;
|
||||
_textBox.Top = absRectangle.Top + lineWidth;
|
||||
if (lineThickness <= 1) {
|
||||
if (lineThickness <= 1)
|
||||
{
|
||||
lineWidth = 0;
|
||||
}
|
||||
_textBox.Width = absRectangle.Width - (2 * lineWidth) + correction;
|
||||
_textBox.Height = absRectangle.Height - (2 * lineWidth) + correction;
|
||||
_textBox.Width = absRectangle.Width - 2 * lineWidth + correction;
|
||||
_textBox.Height = absRectangle.Height - 2 * lineWidth + correction;
|
||||
}
|
||||
|
||||
public override void ApplyBounds(RectangleF newBounds) {
|
||||
public override void ApplyBounds(RectangleF newBounds)
|
||||
{
|
||||
base.ApplyBounds(newBounds);
|
||||
UpdateTextBoxPosition();
|
||||
}
|
||||
|
||||
private void UpdateTextBoxFormat() {
|
||||
if (_textBox == null) {
|
||||
private void UpdateTextBoxFormat()
|
||||
{
|
||||
if (_textBox == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
StringAlignment alignment = (StringAlignment)GetFieldValue(FieldType.TEXT_HORIZONTAL_ALIGNMENT);
|
||||
switch (alignment) {
|
||||
var alignment = (StringAlignment)GetFieldValue(FieldType.TEXT_HORIZONTAL_ALIGNMENT);
|
||||
switch (alignment)
|
||||
{
|
||||
case StringAlignment.Near:
|
||||
_textBox.TextAlign = HorizontalAlignment.Left;
|
||||
break;
|
||||
|
@ -358,25 +470,29 @@ namespace Greenshot.Drawing {
|
|||
break;
|
||||
}
|
||||
|
||||
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
|
||||
var lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
|
||||
_textBox.ForeColor = lineColor;
|
||||
}
|
||||
|
||||
void textBox_KeyDown(object sender, KeyEventArgs e) {
|
||||
|
||||
private void textBox_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
// ESC and Enter/Return (w/o Shift) hide text editor
|
||||
if(e.KeyCode == Keys.Escape || ((e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) && e.Modifiers == Keys.None)) {
|
||||
if (e.KeyCode == Keys.Escape || ((e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) && e.Modifiers == Keys.None))
|
||||
{
|
||||
HideTextBox();
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
}
|
||||
|
||||
void textBox_LostFocus(object sender, EventArgs e) {
|
||||
private void textBox_LostFocus(object sender, EventArgs e)
|
||||
{
|
||||
// next change will be made undoable
|
||||
makeUndoable = true;
|
||||
HideTextBox();
|
||||
}
|
||||
|
||||
public override void Draw(Graphics graphics, RenderMode rm) {
|
||||
|
||||
public override void Draw(Graphics graphics, RenderMode rm)
|
||||
{
|
||||
base.Draw(graphics, rm);
|
||||
|
||||
graphics.SmoothingMode = SmoothingMode.HighQuality;
|
||||
|
@ -386,11 +502,13 @@ namespace Greenshot.Drawing {
|
|||
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
|
||||
|
||||
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
||||
if (Selected && rm == RenderMode.EDIT) {
|
||||
if (Selected && rm == RenderMode.EDIT)
|
||||
{
|
||||
DrawSelectionBorder(graphics, rect);
|
||||
}
|
||||
|
||||
if (text == null || text.Length == 0 ) {
|
||||
|
||||
if (string.IsNullOrEmpty(text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -411,24 +529,38 @@ namespace Greenshot.Drawing {
|
|||
/// <param name="drawingRectange"></param>
|
||||
/// <param name="lineThickness"></param>
|
||||
/// <param name="fontColor"></param>
|
||||
/// <param name="drawShadow"></param>
|
||||
/// <param name="stringFormat"></param>
|
||||
/// <param name="text"></param>
|
||||
/// <param name="font"></param>
|
||||
public static void DrawText(Graphics graphics, Rectangle drawingRectange, int lineThickness, Color fontColor, bool drawShadow, StringFormat stringFormat, string text, Font font) {
|
||||
int textOffset = (lineThickness > 0) ? (int)Math.Ceiling(lineThickness / 2d) : 0;
|
||||
public static void DrawText(Graphics graphics, Rectangle drawingRectange, int lineThickness, Color fontColor, bool drawShadow, StringFormat stringFormat, string text, Font font)
|
||||
{
|
||||
#if DEBUG
|
||||
Debug.Assert(font != null);
|
||||
#else
|
||||
if (font == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
int textOffset = lineThickness > 0 ? (int)Math.Ceiling(lineThickness / 2d) : 0;
|
||||
// draw shadow before anything else
|
||||
if (drawShadow) {
|
||||
if (drawShadow)
|
||||
{
|
||||
int basealpha = 100;
|
||||
int alpha = basealpha;
|
||||
int steps = 5;
|
||||
int currentStep = 1;
|
||||
while (currentStep <= steps) {
|
||||
while (currentStep <= steps)
|
||||
{
|
||||
int offset = currentStep;
|
||||
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(drawingRectange.Left + offset, drawingRectange.Top + offset, drawingRectange.Width, drawingRectange.Height);
|
||||
if (lineThickness > 0) {
|
||||
if (lineThickness > 0)
|
||||
{
|
||||
shadowRect.Inflate(-textOffset, -textOffset);
|
||||
}
|
||||
using (Brush fontBrush = new SolidBrush(Color.FromArgb(alpha, 100, 100, 100))) {
|
||||
using (Brush fontBrush = new SolidBrush(Color.FromArgb(alpha, 100, 100, 100)))
|
||||
{
|
||||
graphics.DrawString(text, font, fontBrush, shadowRect, stringFormat);
|
||||
currentStep++;
|
||||
alpha = alpha - basealpha / steps;
|
||||
|
@ -436,19 +568,25 @@ namespace Greenshot.Drawing {
|
|||
}
|
||||
}
|
||||
|
||||
if (lineThickness > 0) {
|
||||
if (lineThickness > 0)
|
||||
{
|
||||
drawingRectange.Inflate(-textOffset, -textOffset);
|
||||
}
|
||||
using (Brush fontBrush = new SolidBrush(fontColor)) {
|
||||
if (stringFormat != null) {
|
||||
using (Brush fontBrush = new SolidBrush(fontColor))
|
||||
{
|
||||
if (stringFormat != null)
|
||||
{
|
||||
graphics.DrawString(text, font, fontBrush, drawingRectange, stringFormat);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.DrawString(text, font, fontBrush, drawingRectange);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ClickableAt(int x, int y) {
|
||||
public override bool ClickableAt(int x, int y)
|
||||
{
|
||||
Rectangle r = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
||||
r.Inflate(5, 5);
|
||||
return r.Contains(x, y);
|
||||
|
|
12
Greenshot/Forms/AboutForm.Designer.cs
generated
12
Greenshot/Forms/AboutForm.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -19,6 +19,8 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Reflection;
|
||||
|
||||
namespace Greenshot {
|
||||
partial class AboutForm {
|
||||
/// <summary>
|
||||
|
@ -104,7 +106,7 @@ namespace Greenshot {
|
|||
this.linkLblHost.Size = new System.Drawing.Size(465, 23);
|
||||
this.linkLblHost.TabIndex = 6;
|
||||
this.linkLblHost.TabStop = true;
|
||||
this.linkLblHost.Text = "http://sourceforge.net/projects/greenshot/";
|
||||
this.linkLblHost.Text = "https://github.com/greenshot/greenshot";
|
||||
this.linkLblHost.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
|
||||
//
|
||||
// linkLblBugs
|
||||
|
@ -114,7 +116,7 @@ namespace Greenshot {
|
|||
this.linkLblBugs.Size = new System.Drawing.Size(465, 23);
|
||||
this.linkLblBugs.TabIndex = 8;
|
||||
this.linkLblBugs.TabStop = true;
|
||||
this.linkLblBugs.Text = "http://getgreenshot.org/tickets/";
|
||||
this.linkLblBugs.Text = "http://getgreenshot.org/tickets/?version=" + Assembly.GetEntryAssembly().GetName().Version;
|
||||
this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
|
||||
//
|
||||
// lblBugs
|
||||
|
@ -132,7 +134,7 @@ namespace Greenshot {
|
|||
this.linkLblDonations.Size = new System.Drawing.Size(465, 23);
|
||||
this.linkLblDonations.TabIndex = 10;
|
||||
this.linkLblDonations.TabStop = true;
|
||||
this.linkLblDonations.Text = "http://getgreenshot.org/support/";
|
||||
this.linkLblDonations.Text = "http://getgreenshot.org/support/?version=" + Assembly.GetEntryAssembly().GetName().Version;
|
||||
this.linkLblDonations.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
|
||||
//
|
||||
// lblDonations
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -41,21 +41,21 @@ namespace Greenshot {
|
|||
/// The about form
|
||||
/// </summary>
|
||||
public partial class AboutForm : AnimatingBaseForm {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(AboutForm));
|
||||
private Bitmap gBitmap;
|
||||
private ColorAnimator backgroundAnimation;
|
||||
private List<RectangleAnimator> pixels = new List<RectangleAnimator>();
|
||||
private List<Color> colorFlow = new List<Color>();
|
||||
private List<Color> pixelColors = new List<Color>();
|
||||
private Random rand = new Random();
|
||||
private readonly Color backColor = Color.FromArgb(61, 61, 61);
|
||||
private readonly Color pixelColor = Color.FromArgb(138, 255, 0);
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(AboutForm));
|
||||
private Bitmap _bitmap;
|
||||
private readonly ColorAnimator _backgroundAnimation;
|
||||
private readonly IList<RectangleAnimator> _pixels = new List<RectangleAnimator>();
|
||||
private readonly IList<Color> _colorFlow = new List<Color>();
|
||||
private readonly IList<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 = 0;
|
||||
private int colorIndex = 0;
|
||||
private int scrollCount = 0;
|
||||
private bool hasAnimationsLeft;
|
||||
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;
|
||||
|
@ -70,7 +70,7 @@ namespace Greenshot {
|
|||
/// <summary>
|
||||
/// The location of every dot in the "G"
|
||||
/// </summary>
|
||||
private List<Point> gSpots = new List<Point>() {
|
||||
private readonly List<Point> gSpots = new List<Point>() {
|
||||
// Top row
|
||||
new Point(p2, p1), // 0
|
||||
new Point(p3, p1), // 1
|
||||
|
@ -116,15 +116,15 @@ namespace Greenshot {
|
|||
// 18 19 20 21 22 23
|
||||
|
||||
// The order in which we draw the dots & flow the collors.
|
||||
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 };
|
||||
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 (gBitmap != null) {
|
||||
gBitmap.Dispose();
|
||||
gBitmap = null;
|
||||
if (_bitmap != null) {
|
||||
_bitmap.Dispose();
|
||||
_bitmap = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,22 +144,22 @@ namespace Greenshot {
|
|||
InitializeComponent();
|
||||
|
||||
// Only use double-buffering when we are NOT in a Terminal Server session
|
||||
DoubleBuffered = !isTerminalServerSession;
|
||||
DoubleBuffered = !IsTerminalServerSession;
|
||||
|
||||
// Use the self drawn image, first we create the background to be the backcolor (as we animate from this)
|
||||
gBitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96);
|
||||
pictureBox1.Image = gBitmap;
|
||||
_bitmap = ImageHelper.CreateEmpty(90, 90, PixelFormat.Format24bppRgb, BackColor, 96, 96);
|
||||
pictureBox1.Image = _bitmap;
|
||||
Version v = Assembly.GetExecutingAssembly().GetName().Version;
|
||||
|
||||
// Format is like this: AssemblyVersion("Major.Minor.Build.Revision")]
|
||||
lblTitle.Text = "Greenshot " + v.Major + "." + v.Minor + "." + v.Build + " Build " + v.Revision + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OSInfo.Bits + " bit)");
|
||||
lblTitle.Text = "Greenshot " + v.Major + "." + v.Minor + "." + v.Build + " Build " + v.Revision + (IniConfig.IsPortable ? " Portable" : "") + (" (" + OsInfo.Bits) + " bit)";
|
||||
|
||||
//Random rand = new Random();
|
||||
|
||||
// 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);
|
||||
_waitFrames = FramesForMillis(6000);
|
||||
|
||||
// Every pixel is created after pixelWaitFrames frames, which is increased in the loop.
|
||||
int pixelWaitFrames = FramesForMillis(2000);
|
||||
|
@ -174,7 +174,7 @@ namespace Greenshot {
|
|||
int offset = (w - 2) / 2;
|
||||
|
||||
// If the optimize for Terminal Server is set we make the animation without much ado
|
||||
if (isTerminalServerSession) {
|
||||
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 {
|
||||
|
@ -187,23 +187,23 @@ namespace Greenshot {
|
|||
// Increase the wait frames
|
||||
pixelWaitFrames += FramesForMillis(100);
|
||||
// Add to the list of to be animated pixels
|
||||
pixels.Add(pixelAnimation);
|
||||
_pixels.Add(pixelAnimation);
|
||||
// Add a color to the list for this pixel.
|
||||
pixelColors.Add(pixelColor);
|
||||
_pixelColors.Add(_pixelColor);
|
||||
}
|
||||
// Make sure the frame "loop" knows we have to animate
|
||||
hasAnimationsLeft = true;
|
||||
_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);
|
||||
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);
|
||||
_colorFlow.Add(pixelColorAnimator.Current);
|
||||
pixelColorAnimator.Next();
|
||||
} while (pixelColorAnimator.hasNext);
|
||||
} while (pixelColorAnimator.HasNext);
|
||||
|
||||
// color animation for the background
|
||||
backgroundAnimation = new ColorAnimator(BackColor, backColor, FramesForMillis(5000), EasingType.Linear, EasingMode.EaseIn);
|
||||
_backgroundAnimation = new ColorAnimator(BackColor, _backColor, FramesForMillis(5000), EasingType.Linear, EasingMode.EaseIn);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -211,7 +211,7 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void LinkLabelClicked(object sender, LinkLabelLinkClickedEventArgs e) {
|
||||
private void LinkLabelClicked(object sender, LinkLabelLinkClickedEventArgs e) {
|
||||
LinkLabel linkLabel = sender as LinkLabel;
|
||||
if (linkLabel != null) {
|
||||
try {
|
||||
|
@ -227,63 +227,63 @@ namespace Greenshot {
|
|||
/// Called from the AnimatingForm, for every frame
|
||||
/// </summary>
|
||||
protected override void Animate() {
|
||||
if (gBitmap == null) {
|
||||
if (_bitmap == null) {
|
||||
return;
|
||||
}
|
||||
if (!isTerminalServerSession) {
|
||||
if (!IsTerminalServerSession) {
|
||||
// Color cycle
|
||||
if (waitFrames != 0) {
|
||||
waitFrames--;
|
||||
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) {
|
||||
if (!_hasAnimationsLeft) {
|
||||
return;
|
||||
}
|
||||
} else if (scrollCount < (pixelColors.Count + colorFlow.Count)) {
|
||||
} 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];
|
||||
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++];
|
||||
if (_colorIndex < _colorFlow.Count) {
|
||||
_pixelColors[0] = _colorFlow[_colorIndex++];
|
||||
}
|
||||
scrollCount++;
|
||||
_scrollCount++;
|
||||
} else {
|
||||
// Reset values, wait X time for the next one
|
||||
waitFrames = FramesForMillis(3000 + rand.Next(35000));
|
||||
colorIndex = 0;
|
||||
scrollCount = 0;
|
||||
_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) {
|
||||
if (!_hasAnimationsLeft) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (!hasAnimationsLeft) {
|
||||
} else if (!_hasAnimationsLeft) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Draw the "G"
|
||||
using (Graphics graphics = Graphics.FromImage(gBitmap)) {
|
||||
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.Clear(_backgroundAnimation.Next());
|
||||
|
||||
graphics.TranslateTransform(2, -2);
|
||||
graphics.RotateTransform(20);
|
||||
|
||||
using (SolidBrush brush = new SolidBrush(pixelColor)) {
|
||||
using (SolidBrush brush = new SolidBrush(_pixelColor)) {
|
||||
int index = 0;
|
||||
// We asume there is nothing to animate in the next Animate loop
|
||||
hasAnimationsLeft = false;
|
||||
_hasAnimationsLeft = false;
|
||||
// Pixels of the G
|
||||
foreach (RectangleAnimator pixel in pixels) {
|
||||
brush.Color = pixelColors[index++];
|
||||
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 = hasAnimationsLeft | pixel.hasNext;
|
||||
_hasAnimationsLeft = _hasAnimationsLeft | pixel.HasNext;
|
||||
pixel.Next();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
4
Greenshot/Forms/BugReportForm.Designer.cs
generated
4
Greenshot/Forms/BugReportForm.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -37,8 +37,8 @@ namespace Greenshot.Forms {
|
|||
public BugReportForm(string bugText) : this() {
|
||||
textBoxDescription.Text = bugText;
|
||||
}
|
||||
|
||||
void LinkLblBugsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
|
||||
|
||||
private void LinkLblBugsLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) {
|
||||
openLink((LinkLabel)sender);
|
||||
}
|
||||
|
||||
|
|
4
Greenshot/Forms/CaptureForm.Designer.cs
generated
4
Greenshot/Forms/CaptureForm.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -40,10 +40,10 @@ namespace Greenshot.Forms {
|
|||
/// <summary>
|
||||
/// The capture form is used to select a part of the capture
|
||||
/// </summary>
|
||||
public partial class CaptureForm : AnimatingForm {
|
||||
public sealed partial class CaptureForm : AnimatingForm {
|
||||
private enum FixMode {None, Initiated, Horizontal, Vertical};
|
||||
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(CaptureForm));
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(CaptureForm));
|
||||
private static readonly CoreConfiguration Conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private static readonly Brush GreenOverlayBrush = new SolidBrush(Color.FromArgb(50, Color.MediumSeaGreen));
|
||||
private static readonly Pen OverlayPen = new Pen(Color.FromArgb(50, Color.Black));
|
||||
|
@ -61,9 +61,9 @@ namespace Greenshot.Forms {
|
|||
private int _mX;
|
||||
private int _mY;
|
||||
private Point _mouseMovePos = Point.Empty;
|
||||
private Point _cursorPos = Point.Empty;
|
||||
private CaptureMode _captureMode = CaptureMode.None;
|
||||
private readonly List<WindowDetails> _windows = new List<WindowDetails>();
|
||||
private Point _cursorPos;
|
||||
private CaptureMode _captureMode;
|
||||
private readonly List<WindowDetails> _windows;
|
||||
private WindowDetails _selectedCaptureWindow;
|
||||
private bool _mouseDown;
|
||||
private Rectangle _captureRect = Rectangle.Empty;
|
||||
|
@ -73,34 +73,23 @@ namespace Greenshot.Forms {
|
|||
private RectangleAnimator _windowAnimator;
|
||||
private RectangleAnimator _zoomAnimator;
|
||||
private readonly bool _isZoomerTransparent = Conf.ZoomerOpacity < 1;
|
||||
private bool _isCtrlPressed = false;
|
||||
private bool _isCtrlPressed;
|
||||
private bool _showDebugInfo;
|
||||
|
||||
/// <summary>
|
||||
/// Property to access the selected capture rectangle
|
||||
/// </summary>
|
||||
public Rectangle CaptureRectangle {
|
||||
get {
|
||||
return _captureRect;
|
||||
}
|
||||
}
|
||||
public Rectangle CaptureRectangle => _captureRect;
|
||||
|
||||
/// <summary>
|
||||
/// Property to access the used capture mode
|
||||
/// </summary>
|
||||
public CaptureMode UsedCaptureMode {
|
||||
get {
|
||||
return _captureMode;
|
||||
}
|
||||
}
|
||||
public CaptureMode UsedCaptureMode => _captureMode;
|
||||
|
||||
/// <summary>
|
||||
/// Get the selected window
|
||||
/// </summary>
|
||||
public WindowDetails SelectedCaptureWindow {
|
||||
get {
|
||||
return _selectedCaptureWindow;
|
||||
}
|
||||
}
|
||||
public WindowDetails SelectedCaptureWindow => _selectedCaptureWindow;
|
||||
|
||||
/// <summary>
|
||||
/// This should prevent childs to draw backgrounds
|
||||
|
@ -108,19 +97,19 @@ namespace Greenshot.Forms {
|
|||
protected override CreateParams CreateParams {
|
||||
[SecurityPermission(SecurityAction.LinkDemand, Flags = SecurityPermissionFlag.UnmanagedCode)]
|
||||
get {
|
||||
CreateParams cp = base.CreateParams;
|
||||
cp.ExStyle |= 0x02000000;
|
||||
return cp;
|
||||
CreateParams createParams = base.CreateParams;
|
||||
createParams.ExStyle |= 0x02000000;
|
||||
return createParams;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClosedHandler(object sender, EventArgs e) {
|
||||
_currentForm = null;
|
||||
LOG.Debug("Remove CaptureForm from currentForm");
|
||||
Log.Debug("Remove CaptureForm from currentForm");
|
||||
}
|
||||
|
||||
private void ClosingHandler(object sender, EventArgs e) {
|
||||
LOG.Debug("Closing captureform");
|
||||
Log.Debug("Closing captureform");
|
||||
WindowDetails.UnregisterIgnoreHandle(Handle);
|
||||
}
|
||||
|
||||
|
@ -131,7 +120,7 @@ namespace Greenshot.Forms {
|
|||
/// <param name="windows"></param>
|
||||
public CaptureForm(ICapture capture, List<WindowDetails> windows) {
|
||||
if (_currentForm != null) {
|
||||
LOG.Warn("Found currentForm, Closing already opened CaptureForm");
|
||||
Log.Warn("Found currentForm, Closing already opened CaptureForm");
|
||||
_currentForm.Close();
|
||||
_currentForm = null;
|
||||
Application.DoEvents();
|
||||
|
@ -153,7 +142,7 @@ namespace Greenshot.Forms {
|
|||
//
|
||||
InitializeComponent();
|
||||
// Only double-buffer when we are not in a TerminalServerSession
|
||||
DoubleBuffered = !isTerminalServerSession;
|
||||
DoubleBuffered = !IsTerminalServerSession;
|
||||
Text = "Greenshot capture form";
|
||||
|
||||
// Make sure we never capture the captureform
|
||||
|
@ -184,18 +173,21 @@ namespace Greenshot.Forms {
|
|||
/// <summary>
|
||||
/// Create an animation for the zoomer, depending on if it's active or not.
|
||||
/// </summary>
|
||||
void InitializeZoomer(bool isOn) {
|
||||
private void InitializeZoomer(bool isOn) {
|
||||
if (isOn) {
|
||||
// Initialize the zoom with a invalid position
|
||||
_zoomAnimator = new RectangleAnimator(Rectangle.Empty, new Rectangle(int.MaxValue, int.MaxValue, 0, 0), FramesForMillis(1000), EasingType.Quintic, EasingMode.EaseOut);
|
||||
VerifyZoomAnimation(_cursorPos, false);
|
||||
} else if (_zoomAnimator != null) {
|
||||
_zoomAnimator.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), FramesForMillis(1000));
|
||||
}
|
||||
else
|
||||
{
|
||||
_zoomAnimator?.ChangeDestination(new Rectangle(Point.Empty, Size.Empty), FramesForMillis(1000));
|
||||
}
|
||||
}
|
||||
|
||||
#region key handling
|
||||
void CaptureFormKeyUp(object sender, KeyEventArgs e) {
|
||||
|
||||
private void CaptureFormKeyUp(object sender, KeyEventArgs e) {
|
||||
switch(e.KeyCode) {
|
||||
case Keys.ShiftKey:
|
||||
_fixMode = FixMode.None;
|
||||
|
@ -211,7 +203,7 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void CaptureFormKeyDown(object sender, KeyEventArgs e) {
|
||||
private void CaptureFormKeyDown(object sender, KeyEventArgs e) {
|
||||
int step = _isCtrlPressed ? 10 : 1;
|
||||
|
||||
switch (e.KeyCode) {
|
||||
|
@ -263,6 +255,14 @@ namespace Greenshot.Forms {
|
|||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case Keys.D:
|
||||
if (_captureMode == CaptureMode.Window)
|
||||
{
|
||||
// Toggle debug
|
||||
_showDebugInfo = !_showDebugInfo;
|
||||
Invalidate();
|
||||
}
|
||||
break;
|
||||
case Keys.Space:
|
||||
// Toggle capture mode
|
||||
switch (_captureMode) {
|
||||
|
@ -300,6 +300,10 @@ namespace Greenshot.Forms {
|
|||
HandleMouseUp();
|
||||
}
|
||||
break;
|
||||
case Keys.F:
|
||||
ToFront = !ToFront;
|
||||
TopMost = !TopMost;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -310,7 +314,7 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void OnMouseDown(object sender, MouseEventArgs e) {
|
||||
private void OnMouseDown(object sender, MouseEventArgs e) {
|
||||
if (e.Button == MouseButtons.Left) {
|
||||
HandleMouseDown();
|
||||
}
|
||||
|
@ -351,7 +355,7 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void OnMouseUp(object sender, MouseEventArgs e) {
|
||||
private void OnMouseUp(object sender, MouseEventArgs e) {
|
||||
if (_mouseDown) {
|
||||
HandleMouseUp();
|
||||
}
|
||||
|
@ -383,7 +387,7 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void OnMouseMove(object sender, MouseEventArgs e) {
|
||||
private void OnMouseMove(object sender, MouseEventArgs e) {
|
||||
// Make sure the mouse coordinates are fixed, when pressing shift
|
||||
_mouseMovePos = FixMouseCoordinates(User32.GetCursorLocation());
|
||||
_mouseMovePos = WindowCapture.GetLocationRelativeToScreenBounds(_mouseMovePos);
|
||||
|
@ -394,11 +398,11 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="animator"></param>
|
||||
/// <returns></returns>
|
||||
bool isAnimating(IAnimator animator) {
|
||||
private bool IsAnimating(IAnimator animator) {
|
||||
if (animator == null) {
|
||||
return false;
|
||||
}
|
||||
return animator.hasNext;
|
||||
return animator.HasNext;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -408,7 +412,7 @@ namespace Greenshot.Forms {
|
|||
Point lastPos = _cursorPos;
|
||||
_cursorPos = _mouseMovePos;
|
||||
|
||||
if (_selectedCaptureWindow != null && lastPos.Equals(_cursorPos) && !isAnimating(_zoomAnimator) && !isAnimating(_windowAnimator)) {
|
||||
if (_selectedCaptureWindow != null && lastPos.Equals(_cursorPos) && !IsAnimating(_zoomAnimator) && !IsAnimating(_windowAnimator)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -431,16 +435,14 @@ namespace Greenshot.Forms {
|
|||
Point cursorPosition = Cursor.Position;
|
||||
_selectedCaptureWindow = null;
|
||||
lock (_windows) {
|
||||
foreach (WindowDetails window in _windows) {
|
||||
if (window.Contains(cursorPosition)) {
|
||||
// Only go over the children if we are in window mode
|
||||
if (CaptureMode.Window == _captureMode) {
|
||||
_selectedCaptureWindow = window.FindChildUnderPoint(cursorPosition);
|
||||
} else {
|
||||
_selectedCaptureWindow = window;
|
||||
}
|
||||
break;
|
||||
foreach (var window in _windows) {
|
||||
if (!window.Contains(cursorPosition))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// Only go over the children if we are in window mode
|
||||
_selectedCaptureWindow = CaptureMode.Window == _captureMode ? window.FindChildUnderPoint(cursorPosition) : window;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,7 +488,7 @@ namespace Greenshot.Forms {
|
|||
invalidateRectangle = new Rectangle(x1,y1, x2-x1, y2-y1);
|
||||
Invalidate(invalidateRectangle);
|
||||
} else if (_captureMode != CaptureMode.Window) {
|
||||
if (!isTerminalServerSession) {
|
||||
if (!IsTerminalServerSession) {
|
||||
Rectangle allScreenBounds = WindowCapture.GetScreenBounds();
|
||||
allScreenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(allScreenBounds.Location);
|
||||
if (verticalMove) {
|
||||
|
@ -515,8 +517,8 @@ namespace Greenshot.Forms {
|
|||
// always animate the Window area through to the last frame, so we see the fade-in/out untill the end
|
||||
// Using a safety "offset" to make sure the text is invalidated too
|
||||
const int safetySize = 30;
|
||||
// Check if the
|
||||
if (isAnimating(_windowAnimator)) {
|
||||
// Check if the animation needs to be drawn
|
||||
if (IsAnimating(_windowAnimator)) {
|
||||
invalidateRectangle = _windowAnimator.Current;
|
||||
invalidateRectangle.Inflate(safetySize, safetySize);
|
||||
Invalidate(invalidateRectangle);
|
||||
|
@ -524,12 +526,12 @@ namespace Greenshot.Forms {
|
|||
invalidateRectangle.Inflate(safetySize, safetySize);
|
||||
Invalidate(invalidateRectangle);
|
||||
// Check if this was the last of the windows animations in the normal region capture.
|
||||
if (_captureMode != CaptureMode.Window && !isAnimating(_windowAnimator)) {
|
||||
if (_captureMode != CaptureMode.Window && !IsAnimating(_windowAnimator)) {
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
if (_zoomAnimator != null && (isAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) {
|
||||
if (_zoomAnimator != null && (IsAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) {
|
||||
// Make sure we invalidate the old zoom area
|
||||
invalidateRectangle = _zoomAnimator.Current;
|
||||
invalidateRectangle.Offset(lastPos);
|
||||
|
@ -540,11 +542,7 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
// The following logic is not needed, next always returns the current if there are no frames left
|
||||
// but it makes more sense if we want to change something in the logic
|
||||
if (isAnimating(_zoomAnimator)) {
|
||||
invalidateRectangle = _zoomAnimator.Next();
|
||||
} else {
|
||||
invalidateRectangle = _zoomAnimator.Current;
|
||||
}
|
||||
invalidateRectangle = IsAnimating(_zoomAnimator) ? _zoomAnimator.Next() : _zoomAnimator.Current;
|
||||
invalidateRectangle.Offset(_cursorPos);
|
||||
Invalidate(invalidateRectangle);
|
||||
}
|
||||
|
@ -570,7 +568,7 @@ namespace Greenshot.Forms {
|
|||
screenBounds.Location = WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location);
|
||||
int relativeZoomSize = Math.Min(screenBounds.Width, screenBounds.Height) / 5;
|
||||
// Make sure the final size is a plural of 4, this makes it look better
|
||||
relativeZoomSize = relativeZoomSize - (relativeZoomSize % 4);
|
||||
relativeZoomSize = relativeZoomSize - relativeZoomSize % 4;
|
||||
Size zoomSize = new Size(relativeZoomSize, relativeZoomSize);
|
||||
Point zoomOffset = new Point(20, 20);
|
||||
|
||||
|
@ -613,8 +611,10 @@ namespace Greenshot.Forms {
|
|||
|
||||
if (_isZoomerTransparent) {
|
||||
//create a color matrix object to change the opacy
|
||||
ColorMatrix opacyMatrix = new ColorMatrix();
|
||||
opacyMatrix.Matrix33 = Conf.ZoomerOpacity;
|
||||
ColorMatrix opacyMatrix = new ColorMatrix
|
||||
{
|
||||
Matrix33 = Conf.ZoomerOpacity
|
||||
};
|
||||
attributes = new ImageAttributes();
|
||||
attributes.SetColorMatrix(opacyMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
|
||||
} else {
|
||||
|
@ -652,9 +652,9 @@ namespace Greenshot.Forms {
|
|||
// Calculate some values
|
||||
int pixelThickness = destinationRectangle.Width / sourceRectangle.Width;
|
||||
int halfWidth = destinationRectangle.Width / 2;
|
||||
int halfWidthEnd = (destinationRectangle.Width / 2) - (pixelThickness / 2);
|
||||
int halfWidthEnd = destinationRectangle.Width / 2 - pixelThickness / 2;
|
||||
int halfHeight = destinationRectangle.Height / 2;
|
||||
int halfHeightEnd = (destinationRectangle.Height / 2) - (pixelThickness / 2);
|
||||
int halfHeightEnd = destinationRectangle.Height / 2 - pixelThickness / 2;
|
||||
|
||||
int drawAtHeight = destinationRectangle.Y + halfHeight;
|
||||
int drawAtWidth = destinationRectangle.X + halfWidth;
|
||||
|
@ -673,8 +673,8 @@ namespace Greenshot.Forms {
|
|||
graphics.DrawLine(pen, destinationRectangle.X + halfWidthEnd + 2 * padding, drawAtHeight, destinationRectangle.X + destinationRectangle.Width - padding, drawAtHeight);
|
||||
|
||||
// Fix offset for drawing the white rectangle around the crosshair-lines
|
||||
drawAtHeight -= (pixelThickness / 2);
|
||||
drawAtWidth -= (pixelThickness / 2);
|
||||
drawAtHeight -= pixelThickness / 2;
|
||||
drawAtWidth -= pixelThickness / 2;
|
||||
// Fix off by one error with the DrawRectangle
|
||||
pixelThickness -= 1;
|
||||
// Change the color and the pen width
|
||||
|
@ -689,9 +689,7 @@ namespace Greenshot.Forms {
|
|||
// Horizontal middle + 1 to right
|
||||
graphics.DrawRectangle(pen, destinationRectangle.X + halfWidthEnd + 2 * padding, drawAtHeight, halfWidthEnd - 2 * padding - 1, pixelThickness);
|
||||
}
|
||||
if (attributes != null) {
|
||||
attributes.Dispose();
|
||||
}
|
||||
attributes?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -699,7 +697,7 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void OnPaint(object sender, PaintEventArgs e) {
|
||||
private void OnPaint(object sender, PaintEventArgs e) {
|
||||
Graphics graphics = e.Graphics;
|
||||
Rectangle clipRectangle = e.ClipRectangle;
|
||||
//graphics.BitBlt((Bitmap)buffer, Point.Empty);
|
||||
|
@ -709,23 +707,16 @@ namespace Greenshot.Forms {
|
|||
graphics.DrawIcon(_capture.Cursor, _capture.CursorLocation.X, _capture.CursorLocation.Y);
|
||||
}
|
||||
|
||||
if (_mouseDown || _captureMode == CaptureMode.Window || isAnimating(_windowAnimator)) {
|
||||
if (_mouseDown || _captureMode == CaptureMode.Window || IsAnimating(_windowAnimator)) {
|
||||
_captureRect.Intersect(new Rectangle(Point.Empty, _capture.ScreenBounds.Size)); // crop what is outside the screen
|
||||
|
||||
Rectangle fixedRect;
|
||||
//if (captureMode == CaptureMode.Window) {
|
||||
if (isAnimating(_windowAnimator)) {
|
||||
// Use the animator
|
||||
fixedRect = _windowAnimator.Current;
|
||||
} else {
|
||||
fixedRect = _captureRect;
|
||||
}
|
||||
|
||||
var fixedRect = IsAnimating(_windowAnimator) ? _windowAnimator.Current : _captureRect;
|
||||
|
||||
// TODO: enable when the screen capture code works reliable
|
||||
//if (capture.CaptureDetails.CaptureMode == CaptureMode.Video) {
|
||||
// graphics.FillRectangle(RedOverlayBrush, fixedRect);
|
||||
//} else {
|
||||
graphics.FillRectangle(GreenOverlayBrush, fixedRect);
|
||||
graphics.FillRectangle(GreenOverlayBrush, fixedRect);
|
||||
//}
|
||||
graphics.DrawRectangle(OverlayPen, fixedRect);
|
||||
|
||||
|
@ -762,7 +753,7 @@ namespace Greenshot.Forms {
|
|||
graphics.DrawPath(rulerPen, p);
|
||||
graphics.DrawString(captureWidth, rulerFont, rulerPen.Brush, fixedRect.X + (fixedRect.Width / 2 - hSpace / 2) + 3, fixedRect.Y - dist - 7);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X, fixedRect.Y - dist, fixedRect.X + (fixedRect.Width / 2 - hSpace / 2), fixedRect.Y - dist);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X + (fixedRect.Width / 2 + hSpace / 2), fixedRect.Y - dist, fixedRect.X + fixedRect.Width, fixedRect.Y - dist);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X + fixedRect.Width / 2 + hSpace / 2, fixedRect.Y - dist, fixedRect.X + fixedRect.Width, fixedRect.Y - dist);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X, fixedRect.Y - dist - 3, fixedRect.X, fixedRect.Y - dist + 3);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X + fixedRect.Width, fixedRect.Y - dist - 3, fixedRect.X + fixedRect.Width, fixedRect.Y - dist + 3);
|
||||
}
|
||||
|
@ -780,7 +771,7 @@ namespace Greenshot.Forms {
|
|||
graphics.DrawPath(rulerPen, p);
|
||||
graphics.DrawString(captureHeight, rulerFont, rulerPen.Brush, fixedRect.X - measureHeight.Width + 1, fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2) + 2);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X - dist, fixedRect.Y, fixedRect.X - dist, fixedRect.Y + (fixedRect.Height / 2 - vSpace / 2));
|
||||
graphics.DrawLine(rulerPen, fixedRect.X - dist, fixedRect.Y + (fixedRect.Height / 2 + vSpace / 2), fixedRect.X - dist, fixedRect.Y + fixedRect.Height);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X - dist, fixedRect.Y + fixedRect.Height / 2 + vSpace / 2, fixedRect.X - dist, fixedRect.Y + fixedRect.Height);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X - dist - 3, fixedRect.Y, fixedRect.X - dist + 3, fixedRect.Y);
|
||||
graphics.DrawLine(rulerPen, fixedRect.X - dist - 3, fixedRect.Y + fixedRect.Height, fixedRect.X - dist + 3, fixedRect.Y + fixedRect.Height);
|
||||
}
|
||||
|
@ -796,17 +787,17 @@ namespace Greenshot.Forms {
|
|||
// When capturing a Region we need to add 1 to the height/width for correction
|
||||
string sizeText;
|
||||
if (_captureMode == CaptureMode.Region) {
|
||||
// correct the GUI width to real width for the shown size
|
||||
sizeText = (_captureRect.Width + 1) + " x " + (_captureRect.Height + 1);
|
||||
// correct the GUI width to real width for the shown size
|
||||
sizeText = _captureRect.Width + 1 + " x " + (_captureRect.Height + 1);
|
||||
} else {
|
||||
sizeText = _captureRect.Width + " x " + _captureRect.Height;
|
||||
}
|
||||
|
||||
|
||||
// Calculate the scaled font size.
|
||||
SizeF extent = graphics.MeasureString( sizeText, sizeFont );
|
||||
float hRatio = _captureRect.Height / (extent.Height * 2);
|
||||
float wRatio = _captureRect.Width / (extent.Width * 2);
|
||||
float ratio = ( hRatio < wRatio ? hRatio : wRatio );
|
||||
float ratio = hRatio < wRatio ? hRatio : wRatio;
|
||||
float newSize = sizeFont.Size * ratio;
|
||||
|
||||
if ( newSize >= 4 ) {
|
||||
|
@ -816,13 +807,20 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
// Draw the size.
|
||||
using (Font newSizeFont = new Font(FontFamily.GenericSansSerif, newSize, FontStyle.Bold)) {
|
||||
PointF sizeLocation = new PointF(fixedRect.X + (_captureRect.Width / 2) - (extent.Width / 2), fixedRect.Y + (_captureRect.Height / 2) - (newSizeFont.GetHeight() / 2));
|
||||
PointF sizeLocation = new PointF(fixedRect.X + _captureRect.Width / 2 - extent.Width / 2, fixedRect.Y + _captureRect.Height / 2 - newSizeFont.GetHeight() / 2);
|
||||
graphics.DrawString(sizeText, newSizeFont, Brushes.LightSeaGreen, sizeLocation);
|
||||
|
||||
if (_showDebugInfo && _selectedCaptureWindow != null)
|
||||
{
|
||||
string title = $"#{_selectedCaptureWindow.Handle.ToInt64():X} - {(_selectedCaptureWindow.Text.Length > 0 ? _selectedCaptureWindow.Text : _selectedCaptureWindow.Process.ProcessName)}";
|
||||
PointF debugLocation = new PointF(fixedRect.X, fixedRect.Y);
|
||||
graphics.DrawString(title, sizeFont, Brushes.DarkOrange, debugLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!isTerminalServerSession) {
|
||||
if (!IsTerminalServerSession) {
|
||||
using (Pen pen = new Pen(Color.LightSeaGreen)) {
|
||||
pen.DashStyle = DashStyle.Dot;
|
||||
Rectangle screenBounds = _capture.ScreenBounds;
|
||||
|
@ -848,11 +846,11 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
|
||||
// Zoom
|
||||
if (_zoomAnimator != null && (isAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) {
|
||||
if (_zoomAnimator != null && (IsAnimating(_zoomAnimator) || _captureMode != CaptureMode.Window)) {
|
||||
const int zoomSourceWidth = 25;
|
||||
const int zoomSourceHeight = 25;
|
||||
|
||||
Rectangle sourceRectangle = new Rectangle(_cursorPos.X - (zoomSourceWidth / 2), _cursorPos.Y - (zoomSourceHeight / 2), zoomSourceWidth, zoomSourceHeight);
|
||||
Rectangle sourceRectangle = new Rectangle(_cursorPos.X - zoomSourceWidth / 2, _cursorPos.Y - zoomSourceHeight / 2, zoomSourceWidth, zoomSourceHeight);
|
||||
|
||||
Rectangle destinationRectangle = _zoomAnimator.Current;
|
||||
destinationRectangle.Offset(_cursorPos);
|
||||
|
|
12
Greenshot/Forms/ColorDialog.Designer.cs
generated
12
Greenshot/Forms/ColorDialog.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -144,7 +144,7 @@ namespace Greenshot {
|
|||
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.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
|
||||
this.textBoxRed.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
|
||||
this.textBoxRed.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
|
||||
//
|
||||
|
@ -156,7 +156,7 @@ namespace Greenshot {
|
|||
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.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
|
||||
this.textBoxGreen.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
|
||||
this.textBoxGreen.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
|
||||
//
|
||||
|
@ -168,7 +168,7 @@ namespace Greenshot {
|
|||
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.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
|
||||
this.textBoxBlue.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
|
||||
this.textBoxBlue.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
|
||||
//
|
||||
|
@ -189,7 +189,7 @@ namespace Greenshot {
|
|||
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.TextChanged += new System.EventHandler(this.TextBoxRgbTextChanged);
|
||||
this.textBoxAlpha.GotFocus += new System.EventHandler(this.TextBoxGotFocus);
|
||||
this.textBoxAlpha.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TextBoxKeyDown);
|
||||
//
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -34,8 +34,8 @@ namespace Greenshot {
|
|||
/// Description of ColorDialog.
|
||||
/// </summary>
|
||||
public partial class ColorDialog : BaseForm {
|
||||
private static ColorDialog uniqueInstance;
|
||||
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
private static ColorDialog _uniqueInstance;
|
||||
private static readonly EditorConfiguration EditorConfig = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
|
||||
private ColorDialog() {
|
||||
SuspendLayout();
|
||||
|
@ -47,17 +47,15 @@ namespace Greenshot {
|
|||
UpdateRecentColorsButtonRow();
|
||||
}
|
||||
|
||||
public static ColorDialog GetInstance() {
|
||||
if (uniqueInstance == null) {
|
||||
uniqueInstance = new ColorDialog();
|
||||
}
|
||||
return uniqueInstance;
|
||||
public static ColorDialog GetInstance()
|
||||
{
|
||||
return _uniqueInstance ?? (_uniqueInstance = new ColorDialog());
|
||||
}
|
||||
|
||||
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 = false;
|
||||
private bool _updateInProgress;
|
||||
|
||||
public Color Color {
|
||||
get { return colorPanel.BackColor; }
|
||||
|
@ -108,13 +106,15 @@ namespace Greenshot {
|
|||
}
|
||||
|
||||
private Button CreateColorButton(Color color, int x, int y, int w, int h) {
|
||||
Button b = new Button();
|
||||
b.BackColor = color;
|
||||
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.FlatStyle = FlatStyle.Flat;
|
||||
b.Location = new Point(x, y);
|
||||
b.Size = new Size(w, h);
|
||||
b.TabStop = false;
|
||||
b.Click += ColorButtonClick;
|
||||
_toolTip.SetToolTip(b, ColorTranslator.ToHtml(color) + " | R:" + color.R + ", G:" + color.G + ", B:" + color.B);
|
||||
return b;
|
||||
|
@ -133,8 +133,8 @@ namespace Greenshot {
|
|||
|
||||
#region update user interface
|
||||
private void UpdateRecentColorsButtonRow() {
|
||||
for (int i = 0; i < editorConfiguration.RecentColors.Count && i < 12; i++) {
|
||||
_recentColorButtons[i].BackColor = editorConfiguration.RecentColors[i];
|
||||
for (int i = 0; i < EditorConfig.RecentColors.Count && i < 12; i++) {
|
||||
_recentColorButtons[i].BackColor = EditorConfig.RecentColors[i];
|
||||
_recentColorButtons[i].Enabled = true;
|
||||
}
|
||||
}
|
||||
|
@ -155,30 +155,31 @@ namespace Greenshot {
|
|||
}
|
||||
|
||||
private void AddToRecentColors(Color c) {
|
||||
editorConfiguration.RecentColors.Remove(c);
|
||||
editorConfiguration.RecentColors.Insert(0, c);
|
||||
if (editorConfiguration.RecentColors.Count > 12) {
|
||||
editorConfiguration.RecentColors.RemoveRange(12, editorConfiguration.RecentColors.Count - 12);
|
||||
EditorConfig.RecentColors.Remove(c);
|
||||
EditorConfig.RecentColors.Insert(0, c);
|
||||
if (EditorConfig.RecentColors.Count > 12) {
|
||||
EditorConfig.RecentColors.RemoveRange(12, EditorConfig.RecentColors.Count - 12);
|
||||
}
|
||||
UpdateRecentColorsButtonRow();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region textbox event handlers
|
||||
void TextBoxHexadecimalTextChanged(object sender, EventArgs e) {
|
||||
|
||||
private void TextBoxHexadecimalTextChanged(object sender, EventArgs e) {
|
||||
if (_updateInProgress) {
|
||||
return;
|
||||
}
|
||||
TextBox textBox = (TextBox)sender;
|
||||
string text = textBox.Text.Replace("#", "");
|
||||
int i = 0;
|
||||
int i;
|
||||
Color c;
|
||||
if (Int32.TryParse(text, NumberStyles.AllowHexSpecifier, Thread.CurrentThread.CurrentCulture, out i)) {
|
||||
if (int.TryParse(text, NumberStyles.AllowHexSpecifier, Thread.CurrentThread.CurrentCulture, out i)) {
|
||||
c = Color.FromArgb(i);
|
||||
} else {
|
||||
KnownColor knownColor;
|
||||
try {
|
||||
knownColor = (KnownColor)Enum.Parse(typeof(KnownColor), text, true);
|
||||
try
|
||||
{
|
||||
var knownColor = (KnownColor)Enum.Parse(typeof(KnownColor), text, true);
|
||||
c = Color.FromKnownColor(knownColor);
|
||||
} catch (Exception) {
|
||||
return;
|
||||
|
@ -188,7 +189,7 @@ namespace Greenshot {
|
|||
PreviewColor(opaqueColor, textBox);
|
||||
}
|
||||
|
||||
void TextBoxRGBTextChanged(object sender, EventArgs e) {
|
||||
private void TextBoxRgbTextChanged(object sender, EventArgs e) {
|
||||
if (_updateInProgress) {
|
||||
return;
|
||||
}
|
||||
|
@ -196,11 +197,11 @@ namespace Greenshot {
|
|||
PreviewColor(Color.FromArgb(GetColorPartIntFromString(textBoxAlpha.Text), GetColorPartIntFromString(textBoxRed.Text), GetColorPartIntFromString(textBoxGreen.Text), GetColorPartIntFromString(textBoxBlue.Text)), textBox);
|
||||
}
|
||||
|
||||
void TextBoxGotFocus(object sender, EventArgs e) {
|
||||
private void TextBoxGotFocus(object sender, EventArgs e) {
|
||||
textBoxHtmlColor.SelectAll();
|
||||
}
|
||||
|
||||
void TextBoxKeyDown(object sender, KeyEventArgs e) {
|
||||
private void TextBoxKeyDown(object sender, KeyEventArgs e) {
|
||||
if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) {
|
||||
AddToRecentColors(colorPanel.BackColor);
|
||||
}
|
||||
|
@ -208,15 +209,17 @@ namespace Greenshot {
|
|||
#endregion
|
||||
|
||||
#region button event handlers
|
||||
void ColorButtonClick(object sender, EventArgs e) {
|
||||
|
||||
private void ColorButtonClick(object sender, EventArgs e) {
|
||||
Button b = (Button)sender;
|
||||
PreviewColor(b.BackColor, b);
|
||||
}
|
||||
|
||||
void BtnTransparentClick(object sender, EventArgs e) {
|
||||
private void BtnTransparentClick(object sender, EventArgs e) {
|
||||
ColorButtonClick(sender, e);
|
||||
}
|
||||
void BtnApplyClick(object sender, EventArgs e) {
|
||||
|
||||
private void BtnApplyClick(object sender, EventArgs e) {
|
||||
DialogResult = DialogResult.OK;
|
||||
Hide();
|
||||
AddToRecentColors(colorPanel.BackColor);
|
||||
|
@ -225,17 +228,23 @@ namespace Greenshot {
|
|||
|
||||
#region helper functions
|
||||
private int GetColorPartIntFromString(string s) {
|
||||
int ret = 0;
|
||||
Int32.TryParse(s, out ret);
|
||||
if (ret < 0) ret = 0;
|
||||
else if (ret > 255) ret = 255;
|
||||
int ret;
|
||||
int.TryParse(s, out ret);
|
||||
if (ret < 0)
|
||||
{
|
||||
ret = 0;
|
||||
}
|
||||
else if (ret > 255)
|
||||
{
|
||||
ret = 255;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void PipetteUsed(object sender, PipetteUsedArgs e) {
|
||||
Color = e.color;
|
||||
Color = e.Color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -21,15 +21,14 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Core;
|
||||
using GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Effects;
|
||||
|
||||
namespace Greenshot.Forms {
|
||||
public partial class DropShadowSettingsForm : BaseForm {
|
||||
private DropShadowEffect effect;
|
||||
private readonly DropShadowEffect _effect;
|
||||
|
||||
public DropShadowSettingsForm(DropShadowEffect effect) {
|
||||
this.effect = effect;
|
||||
_effect = effect;
|
||||
InitializeComponent();
|
||||
ShowSettings();
|
||||
}
|
||||
|
@ -38,22 +37,17 @@ namespace Greenshot.Forms {
|
|||
/// 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;
|
||||
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 = (float)trackBar1.Value / (float)40;
|
||||
effect.ShadowOffset = new Point((int)offsetX.Value, (int)offsetY.Value);
|
||||
effect.ShadowSize = (int)thickness.Value;
|
||||
_effect.Darkness = trackBar1.Value / (float)40;
|
||||
_effect.ShadowOffset = new Point((int)offsetX.Value, (int)offsetY.Value);
|
||||
_effect.ShadowSize = (int)thickness.Value;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void ButtonReset_Click(object sender, EventArgs e) {
|
||||
effect.Reset();
|
||||
ShowSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
37
Greenshot/Forms/ImageEditorForm.Designer.cs
generated
37
Greenshot/Forms/ImageEditorForm.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -152,6 +152,8 @@ namespace Greenshot {
|
|||
this.btnLineColor = new Greenshot.Controls.ToolStripColorButton();
|
||||
this.lineThicknessLabel = new GreenshotPlugin.Controls.GreenshotToolStripLabel();
|
||||
this.lineThicknessUpDown = new Greenshot.Controls.ToolStripNumericUpDown();
|
||||
this.counterLabel = new GreenshotPlugin.Controls.GreenshotToolStripLabel();
|
||||
this.counterUpDown = new Greenshot.Controls.ToolStripNumericUpDown();
|
||||
this.fontFamilyComboBox = new Greenshot.Controls.FontFamilyComboBox();
|
||||
this.fontSizeLabel = new GreenshotPlugin.Controls.GreenshotToolStripLabel();
|
||||
this.fontSizeUpDown = new Greenshot.Controls.ToolStripNumericUpDown();
|
||||
|
@ -464,13 +466,13 @@ namespace Greenshot {
|
|||
//
|
||||
this.addDropshadowToolStripMenuItem.LanguageKey = "editor_image_shadow";
|
||||
this.addDropshadowToolStripMenuItem.Name = "addDropshadowToolStripMenuItem";
|
||||
this.addDropshadowToolStripMenuItem.Click += new System.EventHandler(this.AddDropshadowToolStripMenuItemClick);
|
||||
this.addDropshadowToolStripMenuItem.MouseUp += AddDropshadowToolStripMenuItemMouseUp;
|
||||
//
|
||||
// tornEdgesToolStripMenuItem
|
||||
//
|
||||
this.tornEdgesToolStripMenuItem.LanguageKey = "editor_torn_edge";
|
||||
this.tornEdgesToolStripMenuItem.Name = "tornEdgesToolStripMenuItem";
|
||||
this.tornEdgesToolStripMenuItem.Click += new System.EventHandler(this.TornEdgesToolStripMenuItemClick);
|
||||
this.tornEdgesToolStripMenuItem.MouseUp += TornEdgesToolStripMenuItemMouseUp;
|
||||
//
|
||||
// grayscaleToolStripMenuItem
|
||||
//
|
||||
|
@ -1022,7 +1024,7 @@ namespace Greenshot {
|
|||
this.propertiesToolStrip.Renderer = new CustomToolStripProfessionalRenderer();
|
||||
this.propertiesToolStrip.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.propertiesToolStrip.OverflowButton.DropDown.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.propertiesToolStrip.Paint += propertiesToolStrip_Paint;
|
||||
this.propertiesToolStrip.Paint += PropertiesToolStrip_Paint;
|
||||
this.propertiesToolStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.obfuscateModeButton,
|
||||
this.highlightModeButton,
|
||||
|
@ -1053,7 +1055,9 @@ namespace Greenshot {
|
|||
this.toolStripSeparator,
|
||||
this.toolStripSeparator10,
|
||||
this.btnConfirm,
|
||||
this.btnCancel});
|
||||
this.btnCancel,
|
||||
this.counterLabel,
|
||||
this.counterUpDown});
|
||||
//
|
||||
// obfuscateModeButton
|
||||
//
|
||||
|
@ -1143,6 +1147,23 @@ namespace Greenshot {
|
|||
this.btnLineColor.Name = "btnLineColor";
|
||||
this.btnLineColor.SelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(203)))), ((int)(((byte)(222)))), ((int)(((byte)(250)))));
|
||||
//
|
||||
// counterLabel
|
||||
//
|
||||
this.counterLabel.LanguageKey = "editor_counter_startvalue";
|
||||
this.counterLabel.Name = "counterLabel";
|
||||
//
|
||||
// counterUpDown
|
||||
//
|
||||
this.counterUpDown.DecimalPlaces = 0;
|
||||
this.counterUpDown.Increment = 1;
|
||||
this.counterUpDown.Maximum = 100;
|
||||
this.counterUpDown.Minimum = 0;
|
||||
this.counterUpDown.Name = "counterUpDown";
|
||||
this.counterUpDown.Text = "1";
|
||||
this.counterUpDown.Value = 1;
|
||||
this.counterUpDown.GotFocus += new System.EventHandler(this.ToolBarFocusableElementGotFocus);
|
||||
this.counterUpDown.LostFocus += new System.EventHandler(this.ToolBarFocusableElementLostFocus);
|
||||
//
|
||||
// lineThicknessLabel
|
||||
//
|
||||
this.lineThicknessLabel.LanguageKey = "editor_thickness";
|
||||
|
@ -1691,6 +1712,8 @@ namespace Greenshot {
|
|||
private Greenshot.Controls.ToolStripEx propertiesToolStrip;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripLabel lineThicknessLabel;
|
||||
private Greenshot.Controls.ToolStripNumericUpDown lineThicknessUpDown;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripLabel counterLabel;
|
||||
private Greenshot.Controls.ToolStripNumericUpDown counterUpDown;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator14;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator15;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator16;
|
||||
|
@ -1736,7 +1759,7 @@ namespace Greenshot {
|
|||
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem removeObjectToolStripMenuItem;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addTextBoxToolStripMenuItem;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addSpeechBubbleToolStripMenuItem;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addCounterToolStripMenuItem;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addCounterToolStripMenuItem;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addEllipseToolStripMenuItem;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem addRectangleToolStripMenuItem;
|
||||
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem objectToolStripMenuItem;
|
||||
|
|
File diff suppressed because it is too large
Load diff
4
Greenshot/Forms/LanguageDialog.Designer.cs
generated
4
Greenshot/Forms/LanguageDialog.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -29,9 +29,9 @@ namespace Greenshot.Forms {
|
|||
/// Description of LanguageDialog.
|
||||
/// </summary>
|
||||
public partial class LanguageDialog : Form {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(LanguageDialog));
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(LanguageDialog));
|
||||
private static LanguageDialog uniqueInstance;
|
||||
private bool properOkPressed = false;
|
||||
private bool properOkPressed;
|
||||
|
||||
private LanguageDialog() {
|
||||
//
|
||||
|
@ -78,8 +78,8 @@ namespace Greenshot.Forms {
|
|||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void BtnOKClick(object sender, EventArgs e) {
|
||||
|
||||
private void BtnOKClick(object sender, EventArgs e) {
|
||||
properOkPressed = true;
|
||||
// Fix for Bug #3431100
|
||||
Language.CurrentLanguage = SelectedLanguage;
|
||||
|
|
6
Greenshot/Forms/MainForm.Designer.cs
generated
6
Greenshot/Forms/MainForm.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -162,7 +162,7 @@ namespace Greenshot {
|
|||
//
|
||||
this.contextmenu_captureiefromlist.Name = "contextmenu_captureiefromlist";
|
||||
this.contextmenu_captureiefromlist.Size = new System.Drawing.Size(170, 22);
|
||||
this.contextmenu_captureiefromlist.DropDownOpening += new System.EventHandler(this.CaptureIEMenuDropDownOpening);
|
||||
this.contextmenu_captureiefromlist.DropDownOpening += new System.EventHandler(this.CaptureIeMenuDropDownOpening);
|
||||
//
|
||||
// toolStripOtherSourcesSeparator
|
||||
//
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -25,9 +25,8 @@ using System.ComponentModel;
|
|||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
@ -43,6 +42,7 @@ using GreenshotPlugin.Controls;
|
|||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Destinations;
|
||||
using Greenshot.Drawing;
|
||||
using log4net;
|
||||
using Timer = System.Timers.Timer;
|
||||
|
||||
|
@ -52,19 +52,18 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
public partial class MainForm : BaseForm {
|
||||
private static ILog LOG;
|
||||
private static Mutex _applicationMutex;
|
||||
private static ResourceMutex _applicationMutex;
|
||||
private static CoreConfiguration _conf;
|
||||
public static string LogFileLocation = null;
|
||||
public static string LogFileLocation;
|
||||
|
||||
public static void Start(string[] args) {
|
||||
bool isAlreadyRunning = false;
|
||||
List<string> filesToOpen = new List<string>();
|
||||
public static void Start(string[] arguments) {
|
||||
var filesToOpen = new List<string>();
|
||||
|
||||
// Set the Thread name, is better than "1"
|
||||
Thread.CurrentThread.Name = Application.ProductName;
|
||||
|
||||
// Init Log4NET
|
||||
LogFileLocation = LogHelper.InitializeLog4NET();
|
||||
LogFileLocation = LogHelper.InitializeLog4Net();
|
||||
// Get logger
|
||||
LOG = LogManager.GetLogger(typeof(MainForm));
|
||||
|
||||
|
@ -82,49 +81,21 @@ namespace Greenshot {
|
|||
try {
|
||||
// Fix for Bug 2495900, Multi-user Environment
|
||||
// check whether there's an local instance running already
|
||||
|
||||
try {
|
||||
// Added Mutex Security, hopefully this prevents the UnauthorizedAccessException more gracefully
|
||||
// See an example in Bug #3131534
|
||||
SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
|
||||
MutexSecurity mutexsecurity = new MutexSecurity();
|
||||
mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.FullControl, AccessControlType.Allow));
|
||||
mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.ChangePermissions, AccessControlType.Deny));
|
||||
mutexsecurity.AddAccessRule(new MutexAccessRule(sid, MutexRights.Delete, AccessControlType.Deny));
|
||||
_applicationMutex = ResourceMutex.Create("F48E86D3-E34C-4DB7-8F8F-9A0EA55F0D08", "Greenshot", false);
|
||||
|
||||
bool created;
|
||||
// 1) Create Mutex
|
||||
_applicationMutex = new Mutex(false, @"Local\F48E86D3-E34C-4DB7-8F8F-9A0EA55F0D08", out created, mutexsecurity);
|
||||
// 2) Get the right to it, this returns false if it's already locked
|
||||
if (!_applicationMutex.WaitOne(0, false)) {
|
||||
LOG.Debug("Greenshot seems already to be running!");
|
||||
isAlreadyRunning = true;
|
||||
// Clean up
|
||||
_applicationMutex.Close();
|
||||
_applicationMutex = null;
|
||||
}
|
||||
} catch (AbandonedMutexException e) {
|
||||
// Another Greenshot instance didn't cleanup correctly!
|
||||
// we can ignore the exception, it happend on the "waitone" but still the mutex belongs to us
|
||||
LOG.Warn("Greenshot didn't cleanup correctly!", e);
|
||||
} catch (UnauthorizedAccessException e) {
|
||||
LOG.Warn("Greenshot is most likely already running for a different user in the same session, can't create mutex due to error: ", e);
|
||||
isAlreadyRunning = true;
|
||||
} catch (Exception e) {
|
||||
LOG.Warn("Problem obtaining the Mutex, assuming it was already taken!", e);
|
||||
isAlreadyRunning = true;
|
||||
}
|
||||
var isAlreadyRunning = !_applicationMutex.IsLocked;
|
||||
|
||||
if (args.Length > 0 && LOG.IsDebugEnabled) {
|
||||
if (arguments.Length > 0 && LOG.IsDebugEnabled) {
|
||||
StringBuilder argumentString = new StringBuilder();
|
||||
for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
|
||||
argumentString.Append("[").Append(args[argumentNr]).Append("] ");
|
||||
foreach (string argument in arguments)
|
||||
{
|
||||
argumentString.Append("[").Append(argument).Append("] ");
|
||||
}
|
||||
LOG.Debug("Greenshot arguments: " + argumentString);
|
||||
}
|
||||
|
||||
for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
|
||||
string argument = args[argumentNr];
|
||||
for(int argumentNr = 0; argumentNr < arguments.Length; argumentNr++) {
|
||||
string argument = arguments[argumentNr];
|
||||
// Help
|
||||
if (argument.ToLower().Equals("/help") || argument.ToLower().Equals("/h") || argument.ToLower().Equals("/?")) {
|
||||
// Try to attach to the console
|
||||
|
@ -133,7 +104,7 @@ namespace Greenshot {
|
|||
if (!attachedToConsole) {
|
||||
Kernel32.AllocConsole();
|
||||
}
|
||||
StringBuilder helpOutput = new StringBuilder();
|
||||
var helpOutput = new StringBuilder();
|
||||
helpOutput.AppendLine();
|
||||
helpOutput.AppendLine("Greenshot commandline options:");
|
||||
helpOutput.AppendLine();
|
||||
|
@ -202,14 +173,14 @@ namespace Greenshot {
|
|||
|
||||
// Language
|
||||
if (argument.ToLower().Equals("/language")) {
|
||||
_conf.Language = args[++argumentNr];
|
||||
_conf.Language = arguments[++argumentNr];
|
||||
IniConfig.Save();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Setting the INI-directory
|
||||
if (argument.ToLower().Equals("/inidirectory")) {
|
||||
IniConfig.IniDirectory = args[++argumentNr];
|
||||
IniConfig.IniDirectory = arguments[++argumentNr];
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -258,7 +229,7 @@ namespace Greenshot {
|
|||
using (Form dummyForm = new Form()) {
|
||||
dummyForm.Icon = GreenshotResources.getGreenshotIcon();
|
||||
dummyForm.ShowInTaskbar = true;
|
||||
dummyForm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
|
||||
dummyForm.FormBorderStyle = FormBorderStyle.None;
|
||||
dummyForm.Location = new Point(int.MinValue, int.MinValue);
|
||||
dummyForm.Load += delegate { dummyForm.Size = Size.Empty; };
|
||||
dummyForm.Show();
|
||||
|
@ -316,7 +287,7 @@ namespace Greenshot {
|
|||
// Remove the application mutex
|
||||
if (_applicationMutex != null) {
|
||||
try {
|
||||
_applicationMutex.ReleaseMutex();
|
||||
_applicationMutex.Dispose();
|
||||
_applicationMutex = null;
|
||||
} catch (Exception ex) {
|
||||
LOG.Error("Error releasing Mutex!", ex);
|
||||
|
@ -325,11 +296,7 @@ namespace Greenshot {
|
|||
}
|
||||
|
||||
private static MainForm _instance;
|
||||
public static MainForm Instance {
|
||||
get {
|
||||
return _instance;
|
||||
}
|
||||
}
|
||||
public static MainForm Instance => _instance;
|
||||
|
||||
private readonly CopyData _copyData;
|
||||
|
||||
|
@ -342,15 +309,14 @@ namespace Greenshot {
|
|||
// Timer for the double click test
|
||||
private readonly Timer _doubleClickTimer = new Timer();
|
||||
|
||||
public NotifyIcon NotifyIcon {
|
||||
get {
|
||||
return notifyIcon;
|
||||
}
|
||||
}
|
||||
public NotifyIcon NotifyIcon => notifyIcon;
|
||||
|
||||
public MainForm(CopyDataTransport dataTransport) {
|
||||
_instance = this;
|
||||
|
||||
// Factory for surface objects
|
||||
ImageHelper.SurfaceFactory = () => new Surface();
|
||||
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
|
@ -367,12 +333,12 @@ namespace Greenshot {
|
|||
contextmenu_settings.Visible = !_conf.DisableSettings;
|
||||
|
||||
// Make sure all hotkeys pass this window!
|
||||
HotkeyControl.RegisterHotkeyHWND(Handle);
|
||||
HotkeyControl.RegisterHotkeyHwnd(Handle);
|
||||
RegisterHotkeys();
|
||||
|
||||
new ToolTip();
|
||||
|
||||
UpdateUI();
|
||||
UpdateUi();
|
||||
|
||||
// This forces the registration of all destinations inside Greenshot itself.
|
||||
DestinationHelper.GetAllDestinations();
|
||||
|
@ -478,7 +444,7 @@ namespace Greenshot {
|
|||
IniConfig.Reload();
|
||||
Invoke((MethodInvoker) delegate {
|
||||
// Even update language when needed
|
||||
UpdateUI();
|
||||
UpdateUi();
|
||||
// Update the hotkey
|
||||
// Make sure the current hotkeys are disabled
|
||||
HotkeyControl.UnregisterHotkeys();
|
||||
|
@ -506,9 +472,10 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
|
||||
public ContextMenuStrip MainMenu {
|
||||
get {return contextMenu;}
|
||||
}
|
||||
/// <summary>
|
||||
/// Main context menu
|
||||
/// </summary>
|
||||
public ContextMenuStrip MainMenu => contextMenu;
|
||||
|
||||
protected override void WndProc(ref Message m) {
|
||||
if (HotkeyControl.HandleMessages(ref m)) {
|
||||
|
@ -519,7 +486,7 @@ namespace Greenshot {
|
|||
{
|
||||
return;
|
||||
}
|
||||
base.WndProc(ref m);
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
#region hotkeys
|
||||
|
@ -581,7 +548,7 @@ namespace Greenshot {
|
|||
contextMenu.ImageScalingSize = coreConfiguration.IconSize;
|
||||
string ieExePath = PluginUtils.GetExePath("iexplore.exe");
|
||||
if (!string.IsNullOrEmpty(ieExePath)) {
|
||||
this.contextmenu_captureie.Image = PluginUtils.GetCachedExeIcon(ieExePath, 0);
|
||||
contextmenu_captureie.Image = PluginUtils.GetCachedExeIcon(ieExePath, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -637,6 +604,31 @@ namespace Greenshot {
|
|||
return success || ignoreFailedRegistration;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Check if OneDrive is blocking hotkeys
|
||||
/// </summary>
|
||||
/// <returns>true if onedrive has hotkeys turned on</returns>
|
||||
private static bool IsOneDriveBlockingHotkey()
|
||||
{
|
||||
if (!Environment.OSVersion.IsWindows10())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var localAppData = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
||||
var oneDriveSettingsPath = Path.Combine(localAppData, @"Microsoft\OneDrive\settings\Personal");
|
||||
if (!Directory.Exists(oneDriveSettingsPath))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var oneDriveSettingsFile = Directory.GetFiles(oneDriveSettingsPath, "*_screenshot.dat").FirstOrDefault();
|
||||
if (!File.Exists(oneDriveSettingsFile))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var screenshotSetting = File.ReadAllLines(oneDriveSettingsFile).Skip(1).Take(1).First();
|
||||
return "2".Equals(screenshotSetting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Displays a dialog for the user to choose how to handle hotkey registration failures:
|
||||
/// retry (allowing to shut down the conflicting application before),
|
||||
|
@ -647,7 +639,9 @@ namespace Greenshot {
|
|||
/// <returns></returns>
|
||||
private static bool HandleFailedHotkeyRegistration(string failedKeys) {
|
||||
bool success = false;
|
||||
DialogResult dr = MessageBox.Show(Instance, Language.GetFormattedString(LangKey.warning_hotkeys, failedKeys), Language.GetString(LangKey.warning), MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation);
|
||||
var warningTitle = Language.GetString(LangKey.warning);
|
||||
var message = string.Format(Language.GetString(LangKey.warning_hotkeys), failedKeys, IsOneDriveBlockingHotkey() ? " (OneDrive)": "");
|
||||
DialogResult dr = MessageBox.Show(Instance, message, warningTitle, MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Exclamation);
|
||||
if (dr == DialogResult.Retry) {
|
||||
LOG.DebugFormat("Re-trying to register hotkeys");
|
||||
HotkeyControl.UnregisterHotkeys();
|
||||
|
@ -661,7 +655,7 @@ namespace Greenshot {
|
|||
}
|
||||
#endregion
|
||||
|
||||
public void UpdateUI() {
|
||||
public void UpdateUi() {
|
||||
// As the form is never loaded, call ApplyLanguage ourselves
|
||||
ApplyLanguage();
|
||||
|
||||
|
@ -675,26 +669,30 @@ namespace Greenshot {
|
|||
|
||||
|
||||
#region mainform events
|
||||
void MainFormFormClosing(object sender, FormClosingEventArgs e) {
|
||||
|
||||
private void MainFormFormClosing(object sender, FormClosingEventArgs e) {
|
||||
LOG.DebugFormat("Mainform closing, reason: {0}", e.CloseReason);
|
||||
_instance = null;
|
||||
Exit();
|
||||
}
|
||||
|
||||
void MainFormActivated(object sender, EventArgs e) {
|
||||
private void MainFormActivated(object sender, EventArgs e) {
|
||||
Hide();
|
||||
ShowInTaskbar = false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region key handlers
|
||||
void CaptureRegion() {
|
||||
|
||||
private void CaptureRegion() {
|
||||
CaptureHelper.CaptureRegion(true);
|
||||
}
|
||||
|
||||
void CaptureFile() {
|
||||
var openFileDialog = new OpenFileDialog();
|
||||
openFileDialog.Filter = "Image files (*.greenshot, *.png, *.jpg, *.gif, *.bmp, *.ico, *.tiff, *.wmf)|*.greenshot; *.png; *.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.tiff; *.tif; *.wmf";
|
||||
private void CaptureFile() {
|
||||
var openFileDialog = new OpenFileDialog
|
||||
{
|
||||
Filter = "Image files (*.greenshot, *.png, *.jpg, *.gif, *.bmp, *.ico, *.tiff, *.wmf)|*.greenshot; *.png; *.jpg; *.jpeg; *.gif; *.bmp; *.ico; *.tiff; *.tif; *.wmf"
|
||||
};
|
||||
if (openFileDialog.ShowDialog() == DialogResult.OK) {
|
||||
if (File.Exists(openFileDialog.FileName)) {
|
||||
CaptureHelper.CaptureFile(openFileDialog.FileName);
|
||||
|
@ -702,21 +700,21 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
|
||||
void CaptureFullScreen() {
|
||||
private void CaptureFullScreen() {
|
||||
CaptureHelper.CaptureFullscreen(true, _conf.ScreenCaptureMode);
|
||||
}
|
||||
|
||||
void CaptureLastRegion() {
|
||||
private void CaptureLastRegion() {
|
||||
CaptureHelper.CaptureLastRegion(true);
|
||||
}
|
||||
|
||||
void CaptureIE() {
|
||||
private void CaptureIE() {
|
||||
if (_conf.IECapture) {
|
||||
CaptureHelper.CaptureIE(true, null);
|
||||
CaptureHelper.CaptureIe(true, null);
|
||||
}
|
||||
}
|
||||
|
||||
void CaptureWindow() {
|
||||
private void CaptureWindow() {
|
||||
if (_conf.CaptureWindowsInteractive) {
|
||||
CaptureHelper.CaptureWindowInteractive(true);
|
||||
} else {
|
||||
|
@ -727,13 +725,14 @@ namespace Greenshot {
|
|||
|
||||
|
||||
#region contextmenu
|
||||
void ContextMenuOpening(object sender, CancelEventArgs e) {
|
||||
|
||||
private void ContextMenuOpening(object sender, CancelEventArgs e) {
|
||||
contextmenu_captureclipboard.Enabled = ClipboardHelper.ContainsImage();
|
||||
contextmenu_capturelastregion.Enabled = coreConfiguration.LastCapturedRegion != Rectangle.Empty;
|
||||
|
||||
// IE context menu code
|
||||
try {
|
||||
if (_conf.IECapture && IECaptureHelper.IsIERunning()) {
|
||||
if (_conf.IECapture && IeCaptureHelper.IsIeRunning()) {
|
||||
contextmenu_captureie.Enabled = true;
|
||||
contextmenu_captureiefromlist.Enabled = true;
|
||||
} else {
|
||||
|
@ -757,13 +756,13 @@ namespace Greenshot {
|
|||
|
||||
var now = DateTime.Now;
|
||||
if ((now.Month == 12 && now.Day > 19 && now.Day < 27) || // christmas
|
||||
(now.Month == 3 && now.Day > 13 && now.Day < 21)) { // birthday
|
||||
(now.Month == 3 && now.Day > 13 && now.Day < 21)) { // birthday
|
||||
var resources = new ComponentResourceManager(typeof(MainForm));
|
||||
contextmenu_donate.Image = (Image)resources.GetObject("contextmenu_present.Image");
|
||||
}
|
||||
}
|
||||
|
||||
void ContextMenuClosing(object sender, EventArgs e) {
|
||||
|
||||
private void ContextMenuClosing(object sender, EventArgs e) {
|
||||
contextmenu_captureiefromlist.DropDownItems.Clear();
|
||||
contextmenu_capturewindowfromlist.DropDownItems.Clear();
|
||||
CleanupThumbnail();
|
||||
|
@ -772,12 +771,12 @@ namespace Greenshot {
|
|||
/// <summary>
|
||||
/// Build a selectable list of IE tabs when we enter the menu item
|
||||
/// </summary>
|
||||
void CaptureIEMenuDropDownOpening(object sender, EventArgs e) {
|
||||
private void CaptureIeMenuDropDownOpening(object sender, EventArgs e) {
|
||||
if (!_conf.IECapture) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<KeyValuePair<WindowDetails, string>> tabs = IECaptureHelper.GetBrowserTabs();
|
||||
List<KeyValuePair<WindowDetails, string>> tabs = IeCaptureHelper.GetBrowserTabs();
|
||||
contextmenu_captureiefromlist.DropDownItems.Clear();
|
||||
if (tabs.Count > 0) {
|
||||
contextmenu_captureie.Enabled = true;
|
||||
|
@ -792,12 +791,12 @@ namespace Greenshot {
|
|||
if (title.Length > _conf.MaxMenuItemLength) {
|
||||
title = title.Substring(0, Math.Min(title.Length, _conf.MaxMenuItemLength));
|
||||
}
|
||||
ToolStripItem captureIETabItem = contextmenu_captureiefromlist.DropDownItems.Add(title);
|
||||
var captureIeTabItem = contextmenu_captureiefromlist.DropDownItems.Add(title);
|
||||
int index = counter.ContainsKey(tabData.Key) ? counter[tabData.Key] : 0;
|
||||
captureIETabItem.Image = tabData.Key.DisplayIcon;
|
||||
captureIETabItem.Tag = new KeyValuePair<WindowDetails, int>(tabData.Key, index++);
|
||||
captureIETabItem.Click += Contextmenu_captureiefromlist_Click;
|
||||
contextmenu_captureiefromlist.DropDownItems.Add(captureIETabItem);
|
||||
captureIeTabItem.Image = tabData.Key.DisplayIcon;
|
||||
captureIeTabItem.Tag = new KeyValuePair<WindowDetails, int>(tabData.Key, index++);
|
||||
captureIeTabItem.Click += Contextmenu_captureiefromlist_Click;
|
||||
contextmenu_captureiefromlist.DropDownItems.Add(captureIeTabItem);
|
||||
if (counter.ContainsKey(tabData.Key)) {
|
||||
counter[tabData.Key] = index;
|
||||
} else {
|
||||
|
@ -822,10 +821,9 @@ namespace Greenshot {
|
|||
ToolStripMenuItem captureScreenMenuItem = (ToolStripMenuItem)sender;
|
||||
captureScreenMenuItem.DropDownItems.Clear();
|
||||
if (Screen.AllScreens.Length > 1) {
|
||||
ToolStripMenuItem captureScreenItem;
|
||||
Rectangle allScreensBounds = WindowCapture.GetScreenBounds();
|
||||
|
||||
captureScreenItem = new ToolStripMenuItem(Language.GetString(LangKey.contextmenu_capturefullscreen_all));
|
||||
var captureScreenItem = new ToolStripMenuItem(Language.GetString(LangKey.contextmenu_capturefullscreen_all));
|
||||
captureScreenItem.Click += delegate {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureHelper.CaptureFullscreen(false, ScreenCaptureMode.FullScreen);
|
||||
|
@ -845,7 +843,7 @@ namespace Greenshot {
|
|||
} else if(screen.Bounds.Left != allScreensBounds.Left && screen.Bounds.Right == allScreensBounds.Right) {
|
||||
deviceAlignment += " " + Language.GetString(LangKey.contextmenu_capturefullscreen_right);
|
||||
}
|
||||
captureScreenItem = new ToolStripMenuItem(deviceAlignment);
|
||||
captureScreenItem = new ToolStripMenuItem(deviceAlignment);
|
||||
captureScreenItem.Click += delegate {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureHelper.CaptureRegion(false, screenToCapture.Bounds);
|
||||
|
@ -892,26 +890,26 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
|
||||
private void HideThumbnailOnLeave(object sender, EventArgs e) {
|
||||
if (_thumbnailForm != null) {
|
||||
_thumbnailForm.Hide();
|
||||
}
|
||||
private void HideThumbnailOnLeave(object sender, EventArgs e)
|
||||
{
|
||||
_thumbnailForm?.Hide();
|
||||
}
|
||||
|
||||
private void CleanupThumbnail() {
|
||||
if (_thumbnailForm != null) {
|
||||
_thumbnailForm.Close();
|
||||
_thumbnailForm = null;
|
||||
if (_thumbnailForm == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_thumbnailForm.Close();
|
||||
_thumbnailForm = null;
|
||||
}
|
||||
|
||||
public void AddCaptureWindowMenuItems(ToolStripMenuItem menuItem, EventHandler eventHandler) {
|
||||
menuItem.DropDownItems.Clear();
|
||||
// check if thumbnailPreview is enabled and DWM is enabled
|
||||
bool thumbnailPreview = _conf.ThumnailPreview && DWM.isDWMEnabled();
|
||||
bool thumbnailPreview = _conf.ThumnailPreview && DWM.IsDwmEnabled();
|
||||
|
||||
List<WindowDetails> windows = WindowDetails.GetTopLevelWindows();
|
||||
foreach(WindowDetails window in windows) {
|
||||
foreach(WindowDetails window in WindowDetails.GetTopLevelWindows()) {
|
||||
|
||||
string title = window.Text;
|
||||
if (title != null) {
|
||||
|
@ -931,43 +929,39 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
|
||||
void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
private void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureHelper.CaptureRegion(false);
|
||||
});
|
||||
}
|
||||
|
||||
void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureHelper.CaptureClipboard();
|
||||
});
|
||||
}
|
||||
|
||||
void OpenFileToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureFile();
|
||||
});
|
||||
private void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)CaptureHelper.CaptureClipboard);
|
||||
}
|
||||
|
||||
void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
private void OpenFileToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)CaptureFile);
|
||||
}
|
||||
|
||||
private void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureHelper.CaptureFullscreen(false, _conf.ScreenCaptureMode);
|
||||
});
|
||||
}
|
||||
|
||||
void Contextmenu_capturelastregionClick(object sender, EventArgs e) {
|
||||
|
||||
private void Contextmenu_capturelastregionClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureHelper.CaptureLastRegion(false);
|
||||
});
|
||||
}
|
||||
|
||||
void Contextmenu_capturewindow_Click(object sender,EventArgs e) {
|
||||
|
||||
private void Contextmenu_capturewindow_Click(object sender,EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
CaptureHelper.CaptureWindowInteractive(false);
|
||||
});
|
||||
}
|
||||
|
||||
void Contextmenu_capturewindowfromlist_Click(object sender,EventArgs e) {
|
||||
private void Contextmenu_capturewindowfromlist_Click(object sender,EventArgs e) {
|
||||
ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
try {
|
||||
|
@ -978,12 +972,12 @@ namespace Greenshot {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Contextmenu_captureie_Click(object sender, EventArgs e) {
|
||||
|
||||
private void Contextmenu_captureie_Click(object sender, EventArgs e) {
|
||||
CaptureIE();
|
||||
}
|
||||
|
||||
void Contextmenu_captureiefromlist_Click(object sender, EventArgs e) {
|
||||
private void Contextmenu_captureiefromlist_Click(object sender, EventArgs e) {
|
||||
if (!_conf.IECapture) {
|
||||
LOG.InfoFormat("IE Capture is disabled.");
|
||||
return;
|
||||
|
@ -996,12 +990,12 @@ namespace Greenshot {
|
|||
ieWindowToCapture.Restore();
|
||||
}
|
||||
try {
|
||||
IECaptureHelper.ActivateIETab(ieWindowToCapture, tabData.Value);
|
||||
IeCaptureHelper.ActivateIeTab(ieWindowToCapture, tabData.Value);
|
||||
} catch (Exception exception) {
|
||||
LOG.Error(exception);
|
||||
}
|
||||
try {
|
||||
CaptureHelper.CaptureIE(false, ieWindowToCapture);
|
||||
CaptureHelper.CaptureIe(false, ieWindowToCapture);
|
||||
} catch (Exception exception) {
|
||||
LOG.Error(exception);
|
||||
}
|
||||
|
@ -1013,9 +1007,9 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Contextmenu_donateClick(object sender, EventArgs e) {
|
||||
private void Contextmenu_donateClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
Process.Start("http://getgreenshot.org/support/");
|
||||
Process.Start("http://getgreenshot.org/support/?version=" + Assembly.GetEntryAssembly().GetName().Version);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1024,10 +1018,8 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Contextmenu_settingsClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)delegate {
|
||||
ShowSetting();
|
||||
});
|
||||
private void Contextmenu_settingsClick(object sender, EventArgs e) {
|
||||
BeginInvoke((MethodInvoker)ShowSetting);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1054,7 +1046,7 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Contextmenu_aboutClick(object sender, EventArgs e) {
|
||||
private void Contextmenu_aboutClick(object sender, EventArgs e) {
|
||||
ShowAbout();
|
||||
}
|
||||
|
||||
|
@ -1077,7 +1069,7 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Contextmenu_helpClick(object sender, EventArgs e) {
|
||||
private void Contextmenu_helpClick(object sender, EventArgs e) {
|
||||
HelpFileLoader.LoadHelp();
|
||||
}
|
||||
|
||||
|
@ -1086,7 +1078,7 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
void Contextmenu_exitClick(object sender, EventArgs e) {
|
||||
private void Contextmenu_exitClick(object sender, EventArgs e) {
|
||||
Exit();
|
||||
}
|
||||
|
||||
|
@ -1110,10 +1102,12 @@ namespace Greenshot {
|
|||
// Only add if the value is not fixed
|
||||
if (!_conf.Values["CaptureMousepointer"].IsFixed) {
|
||||
// For the capture mousecursor option
|
||||
ToolStripMenuSelectListItem captureMouseItem = new ToolStripMenuSelectListItem();
|
||||
captureMouseItem.Text = Language.GetString("settings_capture_mousepointer");
|
||||
captureMouseItem.Checked = _conf.CaptureMousepointer;
|
||||
captureMouseItem.CheckOnClick = true;
|
||||
ToolStripMenuSelectListItem captureMouseItem = new ToolStripMenuSelectListItem
|
||||
{
|
||||
Text = Language.GetString("settings_capture_mousepointer"),
|
||||
Checked = _conf.CaptureMousepointer,
|
||||
CheckOnClick = true
|
||||
};
|
||||
captureMouseItem.CheckStateChanged += CheckStateChangedHandler;
|
||||
|
||||
contextmenu_quicksettings.DropDownItems.Add(captureMouseItem);
|
||||
|
@ -1121,10 +1115,12 @@ namespace Greenshot {
|
|||
ToolStripMenuSelectList selectList;
|
||||
if (!_conf.Values["Destinations"].IsFixed) {
|
||||
// screenshot destination
|
||||
selectList = new ToolStripMenuSelectList("destinations", true);
|
||||
selectList.Text = Language.GetString(LangKey.settings_destination);
|
||||
selectList = new ToolStripMenuSelectList("destinations", true)
|
||||
{
|
||||
Text = Language.GetString(LangKey.settings_destination)
|
||||
};
|
||||
// Working with IDestination:
|
||||
foreach (IDestination destination in DestinationHelper.GetAllDestinations()) {
|
||||
foreach (var destination in DestinationHelper.GetAllDestinations()) {
|
||||
selectList.AddItem(destination.Description, destination, _conf.OutputDestinations.Contains(destination.Designation));
|
||||
}
|
||||
selectList.CheckedChanged += QuickSettingDestinationChanged;
|
||||
|
@ -1133,20 +1129,24 @@ namespace Greenshot {
|
|||
|
||||
if (!_conf.Values["WindowCaptureMode"].IsFixed) {
|
||||
// Capture Modes
|
||||
selectList = new ToolStripMenuSelectList("capturemodes", false);
|
||||
selectList.Text = Language.GetString(LangKey.settings_window_capture_mode);
|
||||
selectList = new ToolStripMenuSelectList("capturemodes", false)
|
||||
{
|
||||
Text = Language.GetString(LangKey.settings_window_capture_mode)
|
||||
};
|
||||
string enumTypeName = typeof(WindowCaptureMode).Name;
|
||||
foreach (WindowCaptureMode captureMode in Enum.GetValues(typeof(WindowCaptureMode))) {
|
||||
selectList.AddItem(Language.GetString(enumTypeName + "." + captureMode.ToString()), captureMode, _conf.WindowCaptureMode == captureMode);
|
||||
selectList.AddItem(Language.GetString(enumTypeName + "." + captureMode), captureMode, _conf.WindowCaptureMode == captureMode);
|
||||
}
|
||||
selectList.CheckedChanged += QuickSettingCaptureModeChanged;
|
||||
contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
}
|
||||
|
||||
// print options
|
||||
selectList = new ToolStripMenuSelectList("printoptions",true);
|
||||
selectList.Text = Language.GetString(LangKey.settings_printoptions);
|
||||
|
||||
selectList = new ToolStripMenuSelectList("printoptions", true)
|
||||
{
|
||||
Text = Language.GetString(LangKey.settings_printoptions)
|
||||
};
|
||||
|
||||
IniValue iniValue;
|
||||
foreach(string propertyName in _conf.Values.Keys) {
|
||||
if (propertyName.StartsWith("OutputPrint")) {
|
||||
|
@ -1162,8 +1162,10 @@ namespace Greenshot {
|
|||
}
|
||||
|
||||
// effects
|
||||
selectList = new ToolStripMenuSelectList("effects",true);
|
||||
selectList.Text = Language.GetString(LangKey.settings_visualization);
|
||||
selectList = new ToolStripMenuSelectList("effects", true)
|
||||
{
|
||||
Text = Language.GetString(LangKey.settings_visualization)
|
||||
};
|
||||
|
||||
iniValue = _conf.Values["PlayCameraSound"];
|
||||
if (!iniValue.IsFixed) {
|
||||
|
@ -1178,8 +1180,8 @@ namespace Greenshot {
|
|||
contextmenu_quicksettings.DropDownItems.Add(selectList);
|
||||
}
|
||||
}
|
||||
|
||||
void QuickSettingCaptureModeChanged(object sender, EventArgs e) {
|
||||
|
||||
private void QuickSettingCaptureModeChanged(object sender, EventArgs e) {
|
||||
ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item;
|
||||
WindowCaptureMode windowsCaptureMode = (WindowCaptureMode)item.Data;
|
||||
if (item.Checked) {
|
||||
|
@ -1187,7 +1189,7 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
|
||||
void QuickSettingBoolItemChanged(object sender, EventArgs e) {
|
||||
private void QuickSettingBoolItemChanged(object sender, EventArgs e) {
|
||||
ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item;
|
||||
IniValue iniValue = item.Data as IniValue;
|
||||
if (iniValue != null) {
|
||||
|
@ -1196,7 +1198,7 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
|
||||
void QuickSettingDestinationChanged(object sender, EventArgs e) {
|
||||
private void QuickSettingDestinationChanged(object sender, EventArgs e) {
|
||||
ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item;
|
||||
IDestination selectedDestination = (IDestination)item.Data;
|
||||
if (item.Checked) {
|
||||
|
@ -1234,7 +1236,7 @@ namespace Greenshot {
|
|||
LOG.Error("Exception caught in the UnhandledException handler.");
|
||||
LOG.Error(exceptionText);
|
||||
if (exceptionText != null && exceptionText.Contains("InputLanguageChangedEventArgs"))
|
||||
{
|
||||
{
|
||||
// Ignore for BUG-1809
|
||||
return;
|
||||
}
|
||||
|
@ -1245,7 +1247,7 @@ namespace Greenshot {
|
|||
Exception exceptionToLog = e.Exception;
|
||||
string exceptionText = EnvironmentInfo.BuildReport(exceptionToLog);
|
||||
LOG.Error("Exception caught in the ThreadException handler.");
|
||||
LOG.Error(exceptionText);
|
||||
LOG.Error(exceptionText);
|
||||
if (exceptionText != null && exceptionText.Contains("InputLanguageChangedEventArgs"))
|
||||
{
|
||||
// Ignore for BUG-1809
|
||||
|
@ -1305,23 +1307,38 @@ namespace Greenshot {
|
|||
private void NotifyIconClick(ClickActions clickAction) {
|
||||
switch (clickAction) {
|
||||
case ClickActions.OPEN_LAST_IN_EXPLORER:
|
||||
string path = null;
|
||||
if (!string.IsNullOrEmpty(_conf.OutputFileAsFullpath)) {
|
||||
string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath);
|
||||
if (!string.IsNullOrEmpty(lastFilePath) && Directory.Exists(lastFilePath)) {
|
||||
path = lastFilePath;
|
||||
}
|
||||
}
|
||||
if (path == null) {
|
||||
string configPath = FilenameHelper.FillVariables(_conf.OutputFilePath, false);
|
||||
if (Directory.Exists(configPath)) {
|
||||
path = configPath;
|
||||
}
|
||||
}
|
||||
string path = _conf.OutputFileAsFullpath;
|
||||
if (!File.Exists(path)) {
|
||||
string lastFilePath = Path.GetDirectoryName(_conf.OutputFileAsFullpath);
|
||||
if (!string.IsNullOrEmpty(lastFilePath) && Directory.Exists(lastFilePath)) {
|
||||
path = lastFilePath;
|
||||
}
|
||||
}
|
||||
if (path == null) {
|
||||
string configPath = FilenameHelper.FillVariables(_conf.OutputFilePath, false);
|
||||
if (Directory.Exists(configPath)) {
|
||||
path = configPath;
|
||||
}
|
||||
}
|
||||
|
||||
if (path != null) {
|
||||
try {
|
||||
using (Process.Start(path)) {}
|
||||
// Check if path is a directory
|
||||
if (Directory.Exists(path))
|
||||
{
|
||||
using (Process.Start(path))
|
||||
{
|
||||
}
|
||||
}
|
||||
// Check if path is a file
|
||||
else if (File.Exists(path))
|
||||
{
|
||||
// Start the explorer process and select the file
|
||||
using (var explorer = Process.Start("explorer.exe", $"/select,\"{path}\""))
|
||||
{
|
||||
explorer?.WaitForInputIdle(500);
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
// Make sure we show what we tried to open in the exception
|
||||
ex.Data.Add("path", path);
|
||||
|
@ -1383,7 +1400,7 @@ namespace Greenshot {
|
|||
// Close all open forms (except this), use a separate List to make sure we don't get a "InvalidOperationException: Collection was modified"
|
||||
List<Form> formsToClose = new List<Form>();
|
||||
foreach(Form form in Application.OpenForms) {
|
||||
if (form.Handle != Handle && !form.GetType().Equals(typeof(ImageEditorForm))) {
|
||||
if (form.Handle != Handle && form.GetType() != typeof(ImageEditorForm)) {
|
||||
formsToClose.Add(form);
|
||||
}
|
||||
}
|
||||
|
@ -1459,9 +1476,11 @@ namespace Greenshot {
|
|||
if (UpdateHelper.IsUpdateCheckNeeded()) {
|
||||
LOG.Debug("BackgroundWorkerTimerTick checking for update");
|
||||
// Start update check in the background
|
||||
Thread backgroundTask = new Thread (UpdateHelper.CheckAndAskForUpdate);
|
||||
backgroundTask.Name = "Update check";
|
||||
backgroundTask.IsBackground = true;
|
||||
var backgroundTask = new Thread(UpdateHelper.CheckAndAskForUpdate)
|
||||
{
|
||||
Name = "Update check",
|
||||
IsBackground = true
|
||||
};
|
||||
backgroundTask.Start();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -85,8 +85,8 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="screenCoordinates">Point with the coordinates</param>
|
||||
/// <returns>Color at the specified screenCoordinates</returns>
|
||||
static private Color GetPixelColor(Point screenCoordinates) {
|
||||
using (SafeWindowDCHandle screenDC = SafeWindowDCHandle.fromDesktop()) {
|
||||
private static Color GetPixelColor(Point screenCoordinates) {
|
||||
using (SafeWindowDcHandle screenDC = SafeWindowDcHandle.FromDesktop()) {
|
||||
try {
|
||||
uint pixel = GDI32.GetPixel(screenDC, screenCoordinates.X, screenCoordinates.Y);
|
||||
Color color = Color.FromArgb(255, (int)(pixel & 0xFF), (int)(pixel & 0xFF00) >> 8, (int)(pixel & 0xFF0000) >> 16);
|
||||
|
|
4
Greenshot/Forms/PrintOptionsDialog.Designer.cs
generated
4
Greenshot/Forms/PrintOptionsDialog.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -21,7 +21,6 @@
|
|||
using System;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.IniFile;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace Greenshot.Forms {
|
||||
/// <summary>
|
||||
|
@ -35,9 +34,9 @@ namespace Greenshot.Forms {
|
|||
InitializeComponent();
|
||||
checkbox_dontaskagain.Checked = false;
|
||||
}
|
||||
|
||||
|
||||
void Button_okClick(object sender, EventArgs e) {
|
||||
|
||||
|
||||
private void Button_okClick(object sender, EventArgs e) {
|
||||
// update config
|
||||
coreConfiguration.OutputPrintPromptOptions = !checkbox_dontaskagain.Checked;
|
||||
IniConfig.Save();
|
||||
|
|
4
Greenshot/Forms/ResizeSettingsForm.Designer.cs
generated
4
Greenshot/Forms/ResizeSettingsForm.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -21,137 +21,130 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Core;
|
||||
using GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Effects;
|
||||
|
||||
namespace Greenshot.Forms {
|
||||
/// <summary>
|
||||
/// A form to set the resize settings
|
||||
/// </summary>
|
||||
public partial class ResizeSettingsForm : BaseForm {
|
||||
private ResizeEffect effect;
|
||||
private string value_pixel;
|
||||
private string value_percent;
|
||||
private double newWidth, newHeight;
|
||||
private readonly ResizeEffect _effect;
|
||||
private readonly string _valuePercent;
|
||||
private double _newWidth, _newHeight;
|
||||
|
||||
public ResizeSettingsForm(ResizeEffect effect) {
|
||||
this.effect = effect;
|
||||
_effect = effect;
|
||||
InitializeComponent();
|
||||
value_pixel = Language.GetString("editor_resize_pixel");
|
||||
value_percent = Language.GetString("editor_resize_percent");
|
||||
combobox_width.Items.Add(value_pixel);
|
||||
combobox_width.Items.Add(value_percent);
|
||||
combobox_width.SelectedItem = value_pixel;
|
||||
combobox_height.Items.Add(value_pixel);
|
||||
combobox_height.Items.Add(value_percent);
|
||||
combobox_height.SelectedItem = value_pixel;
|
||||
var valuePixel = Language.GetString("editor_resize_pixel");
|
||||
_valuePercent = Language.GetString("editor_resize_percent");
|
||||
combobox_width.Items.Add(valuePixel);
|
||||
combobox_width.Items.Add(_valuePercent);
|
||||
combobox_width.SelectedItem = valuePixel;
|
||||
combobox_height.Items.Add(valuePixel);
|
||||
combobox_height.Items.Add(_valuePercent);
|
||||
combobox_height.SelectedItem = valuePixel;
|
||||
|
||||
textbox_width.Text = effect.Width.ToString();
|
||||
textbox_height.Text = effect.Height.ToString();
|
||||
newWidth = effect.Width;
|
||||
newHeight = effect.Height;
|
||||
combobox_width.SelectedIndexChanged += new System.EventHandler(this.combobox_SelectedIndexChanged);
|
||||
combobox_height.SelectedIndexChanged += new System.EventHandler(this.combobox_SelectedIndexChanged);
|
||||
_newWidth = effect.Width;
|
||||
_newHeight = effect.Height;
|
||||
combobox_width.SelectedIndexChanged += combobox_SelectedIndexChanged;
|
||||
combobox_height.SelectedIndexChanged += combobox_SelectedIndexChanged;
|
||||
|
||||
checkbox_aspectratio.Checked = effect.MaintainAspectRatio;
|
||||
}
|
||||
|
||||
private void buttonOK_Click(object sender, EventArgs e) {
|
||||
if (newWidth != effect.Width || newHeight != effect.Height) {
|
||||
effect.Width = (int)newWidth;
|
||||
effect.Height = (int)newHeight;
|
||||
effect.MaintainAspectRatio = checkbox_aspectratio.Checked;
|
||||
if (_newWidth != _effect.Width || _newHeight != _effect.Height) {
|
||||
_effect.Width = (int)_newWidth;
|
||||
_effect.Height = (int)_newHeight;
|
||||
_effect.MaintainAspectRatio = checkbox_aspectratio.Checked;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
|
||||
private bool validate(object sender) {
|
||||
private static bool Validate(object sender) {
|
||||
TextBox textbox = sender as TextBox;
|
||||
if (textbox != null) {
|
||||
double numberEntered;
|
||||
if (!double.TryParse(textbox.Text, out numberEntered)) {
|
||||
textbox.BackColor = Color.Red;
|
||||
return false;
|
||||
} else {
|
||||
textbox.BackColor = Color.White;
|
||||
}
|
||||
textbox.BackColor = Color.White;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void displayWidth() {
|
||||
private void DisplayWidth() {
|
||||
double displayValue;
|
||||
if (value_percent.Equals(combobox_width.SelectedItem)) {
|
||||
displayValue = ((double)newWidth / (double)effect.Width) * 100d;
|
||||
if (_valuePercent.Equals(combobox_width.SelectedItem)) {
|
||||
displayValue = _newWidth / _effect.Width * 100d;
|
||||
} else {
|
||||
displayValue = newWidth;
|
||||
displayValue = _newWidth;
|
||||
}
|
||||
textbox_width.Text = ((int)displayValue).ToString();
|
||||
}
|
||||
|
||||
private void displayHeight() {
|
||||
private void DisplayHeight() {
|
||||
double displayValue;
|
||||
if (value_percent.Equals(combobox_height.SelectedItem)) {
|
||||
displayValue = ((double)newHeight / (double)effect.Height) * 100d;
|
||||
if (_valuePercent.Equals(combobox_height.SelectedItem)) {
|
||||
displayValue = _newHeight / _effect.Height * 100d;
|
||||
} else {
|
||||
displayValue = newHeight;
|
||||
displayValue = _newHeight;
|
||||
}
|
||||
textbox_height.Text = ((int)displayValue).ToString();
|
||||
}
|
||||
|
||||
private void textbox_KeyUp(object sender, KeyEventArgs e) {
|
||||
if (!validate(sender)) {
|
||||
if (!Validate(sender)) {
|
||||
return;
|
||||
}
|
||||
TextBox textbox = sender as TextBox;
|
||||
if (textbox.Text.Length == 0) {
|
||||
if (string.IsNullOrEmpty(textbox?.Text)) {
|
||||
return;
|
||||
}
|
||||
bool isWidth = textbox == textbox_width;
|
||||
if (!checkbox_aspectratio.Checked) {
|
||||
if (isWidth) {
|
||||
newWidth = double.Parse(textbox_width.Text);
|
||||
_newWidth = double.Parse(textbox_width.Text);
|
||||
} else {
|
||||
newHeight = double.Parse(textbox_height.Text);
|
||||
_newHeight = double.Parse(textbox_height.Text);
|
||||
}
|
||||
return;
|
||||
}
|
||||
bool isPercent = false;
|
||||
if (isWidth) {
|
||||
isPercent = value_percent.Equals(combobox_width.SelectedItem);
|
||||
} else {
|
||||
isPercent = value_percent.Equals(combobox_height.SelectedItem);
|
||||
}
|
||||
var isPercent = _valuePercent.Equals(isWidth ? combobox_width.SelectedItem : combobox_height.SelectedItem);
|
||||
double percent;
|
||||
if (isWidth) {
|
||||
if (isPercent) {
|
||||
percent = double.Parse(textbox_width.Text);
|
||||
newWidth = ((double)effect.Width / 100d) * percent;
|
||||
_newWidth = _effect.Width / 100d * percent;
|
||||
} else {
|
||||
newWidth = double.Parse(textbox_width.Text);
|
||||
percent = ((double)double.Parse(textbox_width.Text) / (double)effect.Width) * 100d;
|
||||
_newWidth = double.Parse(textbox_width.Text);
|
||||
percent = double.Parse(textbox_width.Text) / _effect.Width * 100d;
|
||||
}
|
||||
if (checkbox_aspectratio.Checked) {
|
||||
newHeight = ((double)effect.Height / 100d) * percent;
|
||||
displayHeight();
|
||||
_newHeight = _effect.Height / 100d * percent;
|
||||
DisplayHeight();
|
||||
}
|
||||
} else {
|
||||
if (isPercent) {
|
||||
percent = double.Parse(textbox_height.Text);
|
||||
newHeight = ((double)effect.Height / 100d) * percent;
|
||||
_newHeight = _effect.Height / 100d * percent;
|
||||
} else {
|
||||
newHeight = double.Parse(textbox_height.Text);
|
||||
percent = ((double)double.Parse(textbox_height.Text) / (double)effect.Height) * 100d;
|
||||
_newHeight = double.Parse(textbox_height.Text);
|
||||
percent = double.Parse(textbox_height.Text) / _effect.Height * 100d;
|
||||
}
|
||||
if (checkbox_aspectratio.Checked) {
|
||||
newWidth = ((double)effect.Width / 100d) * percent;
|
||||
displayWidth();
|
||||
_newWidth = _effect.Width / 100d * percent;
|
||||
DisplayWidth();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void textbox_Validating(object sender, System.ComponentModel.CancelEventArgs e) {
|
||||
validate(sender);
|
||||
Validate(sender);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -160,11 +153,11 @@ namespace Greenshot.Forms {
|
|||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void combobox_SelectedIndexChanged(object sender, EventArgs e) {
|
||||
if (validate(textbox_width)) {
|
||||
displayWidth();
|
||||
if (Validate(textbox_width)) {
|
||||
DisplayWidth();
|
||||
}
|
||||
if (validate(textbox_height)) {
|
||||
displayHeight();
|
||||
if (Validate(textbox_height)) {
|
||||
DisplayHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
6
Greenshot/Forms/SettingsForm.Designer.cs
generated
6
Greenshot/Forms/SettingsForm.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -506,6 +506,8 @@ namespace Greenshot {
|
|||
this.numericUpDown_daysbetweencheck.Size = new System.Drawing.Size(57, 20);
|
||||
this.numericUpDown_daysbetweencheck.TabIndex = 8;
|
||||
this.numericUpDown_daysbetweencheck.ThousandsSeparator = true;
|
||||
this.numericUpDown_daysbetweencheck.Minimum = 0;
|
||||
this.numericUpDown_daysbetweencheck.Maximum = 365;
|
||||
//
|
||||
// label_checkperiod
|
||||
//
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -43,10 +43,10 @@ namespace Greenshot {
|
|||
/// Description of SettingsForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : BaseForm {
|
||||
private static ILog LOG = LogManager.GetLogger(typeof(SettingsForm));
|
||||
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(SettingsForm));
|
||||
private readonly ToolTip _toolTip = new ToolTip();
|
||||
private bool _inHotkey;
|
||||
private int _daysbetweencheckPreviousValue;
|
||||
|
||||
public SettingsForm() {
|
||||
InitializeComponent();
|
||||
|
@ -59,11 +59,7 @@ namespace Greenshot {
|
|||
base.OnLoad(e);
|
||||
|
||||
// Fix for Vista/XP differences
|
||||
if (Environment.OSVersion.Version.Major >= 6) {
|
||||
trackBarJpegQuality.BackColor = SystemColors.Window;
|
||||
} else {
|
||||
trackBarJpegQuality.BackColor = SystemColors.Control;
|
||||
}
|
||||
trackBarJpegQuality.BackColor = Environment.OSVersion.Version.Major >= 6 ? SystemColors.Window : SystemColors.Control;
|
||||
|
||||
// This makes it possible to still capture the settings screen
|
||||
fullscreen_hotkeyControl.Enter += EnterHotkeyControl;
|
||||
|
@ -76,14 +72,49 @@ namespace Greenshot {
|
|||
ie_hotkeyControl.Leave += LeaveHotkeyControl;
|
||||
lastregion_hotkeyControl.Enter += EnterHotkeyControl;
|
||||
lastregion_hotkeyControl.Leave += LeaveHotkeyControl;
|
||||
// Changes for BUG-2077
|
||||
numericUpDown_daysbetweencheck.ValueChanged += NumericUpDownDaysbetweencheckOnValueChanged;
|
||||
|
||||
_daysbetweencheckPreviousValue = (int) numericUpDown_daysbetweencheck.Value;
|
||||
DisplayPluginTab();
|
||||
UpdateUI();
|
||||
UpdateUi();
|
||||
ExpertSettingsEnableState(false);
|
||||
DisplaySettings();
|
||||
CheckSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This makes sure the check cannot be set to 1-6
|
||||
/// </summary>
|
||||
/// <param name="sender">object</param>
|
||||
/// <param name="eventArgs">EventArgs</param>
|
||||
private void NumericUpDownDaysbetweencheckOnValueChanged(object sender, EventArgs eventArgs)
|
||||
{
|
||||
int currentValue = (int)numericUpDown_daysbetweencheck.Value;
|
||||
|
||||
// Check if we can into the forbidden range
|
||||
if (currentValue > 0 && currentValue < 7)
|
||||
{
|
||||
if (_daysbetweencheckPreviousValue <= currentValue)
|
||||
{
|
||||
numericUpDown_daysbetweencheck.Value = 7;
|
||||
}
|
||||
else
|
||||
{
|
||||
numericUpDown_daysbetweencheck.Value = 0;
|
||||
}
|
||||
}
|
||||
if ((int)numericUpDown_daysbetweencheck.Value < 0)
|
||||
{
|
||||
numericUpDown_daysbetweencheck.Value = 0;
|
||||
}
|
||||
if ((int)numericUpDown_daysbetweencheck.Value > 365)
|
||||
{
|
||||
numericUpDown_daysbetweencheck.Value = 365;
|
||||
}
|
||||
_daysbetweencheckPreviousValue = (int)numericUpDown_daysbetweencheck.Value;
|
||||
}
|
||||
|
||||
private void EnterHotkeyControl(object sender, EventArgs e) {
|
||||
HotkeyControl.UnregisterHotkeys();
|
||||
_inHotkey = true;
|
||||
|
@ -114,10 +145,11 @@ namespace Greenshot {
|
|||
/// with the items from the enumeration
|
||||
/// </summary>
|
||||
/// <param name="comboBox">ComboBox to populate</param>
|
||||
/// <param name="enumeration">Enum to populate with</param>
|
||||
private void PopulateComboBox<ET>(ComboBox comboBox, ET[] availableValues, ET selectedValue) where ET : struct {
|
||||
/// <param name="availableValues"></param>
|
||||
/// <param name="selectedValue"></param>
|
||||
private void PopulateComboBox<TEnum>(ComboBox comboBox, TEnum[] availableValues, TEnum selectedValue) where TEnum : struct {
|
||||
comboBox.Items.Clear();
|
||||
foreach(ET enumValue in availableValues) {
|
||||
foreach(TEnum enumValue in availableValues) {
|
||||
comboBox.Items.Add(Language.Translate(enumValue));
|
||||
}
|
||||
comboBox.SelectedItem = Language.Translate(selectedValue);
|
||||
|
@ -129,13 +161,13 @@ namespace Greenshot {
|
|||
/// </summary>
|
||||
/// <param name="comboBox">Combobox to get the value from</param>
|
||||
/// <returns>The generics value of the combobox</returns>
|
||||
private ET GetSelected<ET>(ComboBox comboBox) {
|
||||
string enumTypeName = typeof(ET).Name;
|
||||
private TEnum GetSelected<TEnum>(ComboBox comboBox) {
|
||||
string enumTypeName = typeof(TEnum).Name;
|
||||
string selectedValue = comboBox.SelectedItem as string;
|
||||
ET[] availableValues = (ET[])Enum.GetValues(typeof(ET));
|
||||
ET returnValue = availableValues[0];
|
||||
foreach(ET enumValue in availableValues) {
|
||||
string translation = Language.GetString(enumTypeName + "." + enumValue.ToString());
|
||||
TEnum[] availableValues = (TEnum[])Enum.GetValues(typeof(TEnum));
|
||||
TEnum returnValue = availableValues[0];
|
||||
foreach(TEnum enumValue in availableValues) {
|
||||
string translation = Language.GetString(enumTypeName + "." + enumValue);
|
||||
if (translation.Equals(selectedValue)) {
|
||||
returnValue = enumValue;
|
||||
break;
|
||||
|
@ -146,7 +178,7 @@ namespace Greenshot {
|
|||
|
||||
private void SetWindowCaptureMode(WindowCaptureMode selectedWindowCaptureMode) {
|
||||
WindowCaptureMode[] availableModes;
|
||||
if (!DWM.isDWMEnabled()) {
|
||||
if (!DWM.IsDwmEnabled()) {
|
||||
// Remove DWM from configuration, as DWM is disabled!
|
||||
if (coreConfiguration.WindowCaptureMode == WindowCaptureMode.Aero || coreConfiguration.WindowCaptureMode == WindowCaptureMode.AeroTransparent) {
|
||||
coreConfiguration.WindowCaptureMode = WindowCaptureMode.GDI;
|
||||
|
@ -195,7 +227,7 @@ namespace Greenshot {
|
|||
/// <summary>
|
||||
/// Update the UI to reflect the language and other text settings
|
||||
/// </summary>
|
||||
private void UpdateUI() {
|
||||
private void UpdateUi() {
|
||||
if (coreConfiguration.HideExpertSettings) {
|
||||
tabcontrol.Controls.Remove(tab_expert);
|
||||
}
|
||||
|
@ -228,16 +260,15 @@ namespace Greenshot {
|
|||
return CheckFilenamePattern() && CheckStorageLocationPath();
|
||||
}
|
||||
|
||||
private bool CheckFilenamePattern() {
|
||||
bool settingsOk = true;
|
||||
private bool CheckFilenamePattern() {
|
||||
string filename = FilenameHelper.GetFilenameFromPattern(textbox_screenshotname.Text, coreConfiguration.OutputFileFormat, null);
|
||||
// we allow dynamically created subfolders, need to check for them, too
|
||||
string[] pathParts = filename.Split(Path.DirectorySeparatorChar);
|
||||
|
||||
string filenamePart = pathParts[pathParts.Length-1];
|
||||
settingsOk = FilenameHelper.IsFilenameValid(filenamePart);
|
||||
var settingsOk = FilenameHelper.IsFilenameValid(filenamePart);
|
||||
|
||||
for (int i = 0; (settingsOk && i<pathParts.Length-1); i++) {
|
||||
for (int i = 0; settingsOk && i<pathParts.Length-1; i++) {
|
||||
settingsOk = FilenameHelper.IsDirectoryNameValid(pathParts[i]);
|
||||
}
|
||||
|
||||
|
@ -247,10 +278,7 @@ namespace Greenshot {
|
|||
}
|
||||
|
||||
private bool CheckStorageLocationPath() {
|
||||
bool settingsOk = true;
|
||||
if(!Directory.Exists(FilenameHelper.FillVariables(textbox_storagelocation.Text, false))) {
|
||||
settingsOk = false;
|
||||
}
|
||||
bool settingsOk = Directory.Exists(FilenameHelper.FillVariables(textbox_storagelocation.Text, false));
|
||||
DisplayTextBoxValidity(textbox_storagelocation, settingsOk);
|
||||
return settingsOk;
|
||||
}
|
||||
|
@ -258,11 +286,7 @@ namespace Greenshot {
|
|||
private void DisplayTextBoxValidity(GreenshotTextBox textbox, bool valid) {
|
||||
if (valid) {
|
||||
// "Added" feature #3547158
|
||||
if (Environment.OSVersion.Version.Major >= 6) {
|
||||
textbox.BackColor = SystemColors.Window;
|
||||
} else {
|
||||
textbox.BackColor = SystemColors.Control;
|
||||
}
|
||||
textbox.BackColor = Environment.OSVersion.Version.Major >= 6 ? SystemColors.Window : SystemColors.Control;
|
||||
} else {
|
||||
textbox.BackColor = Color.Red;
|
||||
}
|
||||
|
@ -294,7 +318,7 @@ namespace Greenshot {
|
|||
private void UpdateClipboardFormatDescriptions() {
|
||||
foreach(ListViewItem item in listview_clipboardformats.Items) {
|
||||
ClipboardFormat cf = (ClipboardFormat) item.Tag;
|
||||
item.Text = Language.Translate(cf);
|
||||
item.Text = Language.Translate(cf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,7 +423,7 @@ namespace Greenshot {
|
|||
|
||||
numericUpDown_daysbetweencheck.Value = coreConfiguration.UpdateCheckInterval;
|
||||
numericUpDown_daysbetweencheck.Enabled = !coreConfiguration.Values["UpdateCheckInterval"].IsFixed;
|
||||
numericUpdownIconSize.Value = (coreConfiguration.IconSize.Width /16) * 16;
|
||||
numericUpdownIconSize.Value = coreConfiguration.IconSize.Width /16 * 16;
|
||||
CheckDestinationSettings();
|
||||
}
|
||||
|
||||
|
@ -444,7 +468,6 @@ namespace Greenshot {
|
|||
coreConfiguration.DWMBackgroundColor = colorButton_window_background.SelectedColor;
|
||||
coreConfiguration.UpdateCheckInterval = (int)numericUpDown_daysbetweencheck.Value;
|
||||
|
||||
Size previousValue = coreConfiguration.IconSize;
|
||||
coreConfiguration.IconSize = new Size((int)numericUpdownIconSize.Value, (int)numericUpdownIconSize.Value);
|
||||
|
||||
try {
|
||||
|
@ -464,15 +487,15 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.Warn("Problem checking registry, ignoring for now: ", e);
|
||||
Log.Warn("Problem checking registry, ignoring for now: ", e);
|
||||
}
|
||||
}
|
||||
|
||||
void Settings_cancelClick(object sender, EventArgs e) {
|
||||
|
||||
private void Settings_cancelClick(object sender, EventArgs e) {
|
||||
DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
|
||||
void Settings_okayClick(object sender, EventArgs e) {
|
||||
|
||||
private void Settings_okayClick(object sender, EventArgs e) {
|
||||
if (CheckSettings()) {
|
||||
HotkeyControl.UnregisterHotkeys();
|
||||
SaveSettings();
|
||||
|
@ -480,14 +503,14 @@ namespace Greenshot {
|
|||
MainForm.RegisterHotkeys();
|
||||
|
||||
// Make sure the current language & settings are reflected in the Main-context menu
|
||||
MainForm.Instance.UpdateUI();
|
||||
MainForm.Instance.UpdateUi();
|
||||
DialogResult = DialogResult.OK;
|
||||
} else {
|
||||
tabcontrol.SelectTab(tab_output);
|
||||
}
|
||||
}
|
||||
|
||||
void BrowseClick(object sender, EventArgs e) {
|
||||
|
||||
private void BrowseClick(object sender, EventArgs e) {
|
||||
// Get the storage location and replace the environment variables
|
||||
folderBrowserDialog1.SelectedPath = FilenameHelper.FillVariables(textbox_storagelocation.Text, false);
|
||||
if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) {
|
||||
|
@ -497,37 +520,37 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TrackBarJpegQualityScroll(object sender, EventArgs e) {
|
||||
|
||||
private void TrackBarJpegQualityScroll(object sender, EventArgs e) {
|
||||
textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString(CultureInfo.InvariantCulture);
|
||||
}
|
||||
|
||||
|
||||
void BtnPatternHelpClick(object sender, EventArgs e) {
|
||||
|
||||
private void BtnPatternHelpClick(object sender, EventArgs e) {
|
||||
string filenamepatternText = Language.GetString(LangKey.settings_message_filenamepattern);
|
||||
// Convert %NUM% to ${NUM} for old language files!
|
||||
filenamepatternText = Regex.Replace(filenamepatternText, "%([a-zA-Z_0-9]+)%", @"${$1}");
|
||||
MessageBox.Show(filenamepatternText, Language.GetString(LangKey.settings_filenamepattern));
|
||||
}
|
||||
|
||||
void Listview_pluginsSelectedIndexChanged(object sender, EventArgs e) {
|
||||
button_pluginconfigure.Enabled = PluginHelper.Instance.isSelectedItemConfigurable(listview_plugins);
|
||||
|
||||
private void Listview_pluginsSelectedIndexChanged(object sender, EventArgs e) {
|
||||
button_pluginconfigure.Enabled = PluginHelper.Instance.IsSelectedItemConfigurable(listview_plugins);
|
||||
}
|
||||
|
||||
void Button_pluginconfigureClick(object sender, EventArgs e) {
|
||||
|
||||
private void Button_pluginconfigureClick(object sender, EventArgs e) {
|
||||
PluginHelper.Instance.ConfigureSelectedItem(listview_plugins);
|
||||
}
|
||||
|
||||
void Combobox_languageSelectedIndexChanged(object sender, EventArgs e) {
|
||||
private void Combobox_languageSelectedIndexChanged(object sender, EventArgs e) {
|
||||
// Get the combobox values BEFORE changing the language
|
||||
//EmailFormat selectedEmailFormat = GetSelected<EmailFormat>(combobox_emailformat);
|
||||
WindowCaptureMode selectedWindowCaptureMode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode);
|
||||
if (combobox_language.SelectedItem != null) {
|
||||
LOG.Debug("Setting language to: " + (string)combobox_language.SelectedValue);
|
||||
Log.Debug("Setting language to: " + (string)combobox_language.SelectedValue);
|
||||
Language.CurrentLanguage = (string)combobox_language.SelectedValue;
|
||||
}
|
||||
// Reflect language changes to the settings form
|
||||
UpdateUI();
|
||||
UpdateUi();
|
||||
|
||||
// Reflect Language changes form
|
||||
ApplyLanguage();
|
||||
|
@ -536,8 +559,8 @@ namespace Greenshot {
|
|||
//SetEmailFormat(selectedEmailFormat);
|
||||
SetWindowCaptureMode(selectedWindowCaptureMode);
|
||||
}
|
||||
|
||||
void Combobox_window_capture_modeSelectedIndexChanged(object sender, EventArgs e) {
|
||||
|
||||
private void Combobox_window_capture_modeSelectedIndexChanged(object sender, EventArgs e) {
|
||||
int windowsVersion = Environment.OSVersion.Version.Major;
|
||||
WindowCaptureMode mode = GetSelected<WindowCaptureMode>(combobox_window_capture_mode);
|
||||
if (windowsVersion >= 6) {
|
||||
|
@ -553,7 +576,7 @@ namespace Greenshot {
|
|||
/// <summary>
|
||||
/// Check the destination settings
|
||||
/// </summary>
|
||||
void CheckDestinationSettings() {
|
||||
private void CheckDestinationSettings() {
|
||||
bool clipboardDestinationChecked = false;
|
||||
bool pickerSelected = checkbox_picker.Checked;
|
||||
bool destinationsEnabled = true;
|
||||
|
@ -588,16 +611,16 @@ namespace Greenshot {
|
|||
}
|
||||
}
|
||||
|
||||
void DestinationsCheckStateChanged(object sender, EventArgs e) {
|
||||
private void DestinationsCheckStateChanged(object sender, EventArgs e) {
|
||||
CheckDestinationSettings();
|
||||
}
|
||||
|
||||
protected override void OnFieldsFilled() {
|
||||
// the color radio button is not actually bound to a setting, but checked when monochrome/grayscale are not checked
|
||||
if(!radioBtnGrayScale.Checked && !radioBtnMonochrome.Checked) {
|
||||
radioBtnColorPrint.Checked = true;
|
||||
}
|
||||
}
|
||||
protected override void OnFieldsFilled() {
|
||||
// the color radio button is not actually bound to a setting, but checked when monochrome/grayscale are not checked
|
||||
if(!radioBtnGrayScale.Checked && !radioBtnMonochrome.Checked) {
|
||||
radioBtnColorPrint.Checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set the enable state of the expert settings
|
||||
|
@ -652,7 +675,7 @@ namespace Greenshot {
|
|||
return 1;
|
||||
}
|
||||
if (firstDestination != null && firstDestination.Priority == secondDestination.Priority) {
|
||||
return firstDestination.Description.CompareTo(secondDestination.Description);
|
||||
return string.Compare(firstDestination.Description, secondDestination.Description, StringComparison.Ordinal);
|
||||
}
|
||||
if (firstDestination != null) {
|
||||
return firstDestination.Priority - secondDestination.Priority;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -31,11 +31,11 @@ namespace Greenshot.Forms {
|
|||
/// <summary>
|
||||
/// the ToolStripMenuSelectList makes it possible to have a single or multi-check menu
|
||||
/// </summary>
|
||||
public class ToolStripMenuSelectList : ToolStripMenuItem {
|
||||
private static CoreConfiguration coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private bool multiCheckAllowed = false;
|
||||
private bool updateInProgress = false;
|
||||
private static Image defaultImage;
|
||||
public sealed class ToolStripMenuSelectList : ToolStripMenuItem {
|
||||
private static readonly CoreConfiguration CoreConfig = IniConfig.GetIniSection<CoreConfiguration>();
|
||||
private readonly bool _multiCheckAllowed;
|
||||
private bool _updateInProgress;
|
||||
private static Image _defaultImage;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when one of the list's child element's Checked state changes.
|
||||
|
@ -49,14 +49,12 @@ namespace Greenshot.Forms {
|
|||
public ToolStripMenuSelectList(object identifier, bool allowMultiCheck) {
|
||||
Identifier = identifier;
|
||||
CheckOnClick = false;
|
||||
multiCheckAllowed = allowMultiCheck;
|
||||
if (defaultImage == null || defaultImage.Size != coreConfiguration.IconSize) {
|
||||
if (defaultImage != null) {
|
||||
defaultImage.Dispose();
|
||||
}
|
||||
defaultImage = ImageHelper.CreateEmpty(coreConfiguration.IconSize.Width, coreConfiguration.IconSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb, Color.Transparent, 96f, 96f);
|
||||
_multiCheckAllowed = allowMultiCheck;
|
||||
if (_defaultImage == null || _defaultImage.Size != CoreConfig.IconSize) {
|
||||
_defaultImage?.Dispose();
|
||||
_defaultImage = ImageHelper.CreateEmpty(CoreConfig.IconSize.Width, CoreConfig.IconSize.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb, Color.Transparent, 96f, 96f);
|
||||
}
|
||||
Image = defaultImage;
|
||||
Image = _defaultImage;
|
||||
}
|
||||
public ToolStripMenuSelectList() : this(null,false) {}
|
||||
public ToolStripMenuSelectList(object identifier) : this(identifier,false) {}
|
||||
|
@ -70,7 +68,7 @@ namespace Greenshot.Forms {
|
|||
IEnumerator items = DropDownItems.GetEnumerator();
|
||||
while (items.MoveNext()) {
|
||||
ToolStripMenuSelectListItem tsmi = (ToolStripMenuSelectListItem)items.Current;
|
||||
if (tsmi.Checked) {
|
||||
if (tsmi != null && tsmi.Checked) {
|
||||
return tsmi;
|
||||
}
|
||||
}
|
||||
|
@ -80,9 +78,9 @@ namespace Greenshot.Forms {
|
|||
IEnumerator items = DropDownItems.GetEnumerator();
|
||||
while (items.MoveNext()) {
|
||||
ToolStripMenuSelectListItem tsmi = (ToolStripMenuSelectListItem)items.Current;
|
||||
if (!multiCheckAllowed && !tsmi.Equals(value)) {
|
||||
if (tsmi != null && !_multiCheckAllowed && !tsmi.Equals(value)) {
|
||||
tsmi.Checked = false;
|
||||
} else if (tsmi.Equals(value)) {
|
||||
} else if (tsmi != null && tsmi.Equals(value)) {
|
||||
tsmi.Checked = true;
|
||||
}
|
||||
}
|
||||
|
@ -98,30 +96,31 @@ namespace Greenshot.Forms {
|
|||
IEnumerator items = DropDownItems.GetEnumerator();
|
||||
while(items.MoveNext()) {
|
||||
ToolStripMenuSelectListItem tsmi = (ToolStripMenuSelectListItem)items.Current;
|
||||
if (tsmi.Checked) {
|
||||
if (tsmi != null && tsmi.Checked) {
|
||||
sel.Add(tsmi);
|
||||
}
|
||||
}
|
||||
return sel.ToArray();
|
||||
}
|
||||
set {
|
||||
if (!multiCheckAllowed) {
|
||||
if (!_multiCheckAllowed) {
|
||||
throw new ArgumentException("Writing to checkedItems is only allowed in multi-check mode. Either set allowMultiCheck to true or use set SelectedItem instead of SelectedItems.");
|
||||
}
|
||||
IEnumerator items = DropDownItems.GetEnumerator();
|
||||
IEnumerator sel = value.GetEnumerator();
|
||||
while (items.MoveNext()) {
|
||||
ToolStripMenuSelectListItem tsmi = (ToolStripMenuSelectListItem)items.Current;
|
||||
while (sel.MoveNext()) {
|
||||
if (tsmi.Equals(sel.Current)) {
|
||||
tsmi.Checked = true;
|
||||
} else {
|
||||
tsmi.Checked = false;
|
||||
}
|
||||
if (!multiCheckAllowed && !tsmi.Equals(sel.Current)) {
|
||||
tsmi.Checked = false;
|
||||
} else if (tsmi.Equals(value)) {
|
||||
tsmi.Checked = true;
|
||||
var toolStripMenuSelectListItem = (ToolStripMenuSelectListItem)items.Current;
|
||||
if (toolStripMenuSelectListItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
while (sel.MoveNext())
|
||||
{
|
||||
toolStripMenuSelectListItem.Checked = toolStripMenuSelectListItem.Equals(sel.Current);
|
||||
if (!_multiCheckAllowed && !toolStripMenuSelectListItem.Equals(sel.Current)) {
|
||||
toolStripMenuSelectListItem.Checked = false;
|
||||
} else if (toolStripMenuSelectListItem.Equals(value)) {
|
||||
toolStripMenuSelectListItem.Checked = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,19 +128,17 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
|
||||
private void ItemCheckStateChanged(object sender, EventArgs e) {
|
||||
if (updateInProgress) {
|
||||
if (_updateInProgress) {
|
||||
return;
|
||||
}
|
||||
ToolStripMenuSelectListItem tsmi = (ToolStripMenuSelectListItem)sender;
|
||||
updateInProgress = true;
|
||||
if (tsmi.Checked && !multiCheckAllowed) {
|
||||
var toolStripMenuSelectListItem = (ToolStripMenuSelectListItem)sender;
|
||||
_updateInProgress = true;
|
||||
if (toolStripMenuSelectListItem.Checked && !_multiCheckAllowed) {
|
||||
UncheckAll();
|
||||
tsmi.Checked = true;
|
||||
}
|
||||
updateInProgress = false;
|
||||
if (CheckedChanged != null) {
|
||||
CheckedChanged(this, new ItemCheckedChangedEventArgs(tsmi));
|
||||
toolStripMenuSelectListItem.Checked = true;
|
||||
}
|
||||
_updateInProgress = false;
|
||||
CheckedChanged?.Invoke(this, new ItemCheckedChangedEventArgs(toolStripMenuSelectListItem));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -151,26 +148,28 @@ namespace Greenshot.Forms {
|
|||
/// <param name="image">the icon to be displayed</param>
|
||||
/// <param name="data">the data to be returned when an item is queried</param>
|
||||
/// <param name="isChecked">whether the item is initially checked</param>
|
||||
public void AddItem(string label, Image image, Object data, bool isChecked) {
|
||||
ToolStripMenuSelectListItem newItem = new ToolStripMenuSelectListItem();
|
||||
newItem.Text = label;
|
||||
public void AddItem(string label, Image image, object data, bool isChecked) {
|
||||
var toolStripMenuSelectListItem = new ToolStripMenuSelectListItem
|
||||
{
|
||||
Text = label
|
||||
};
|
||||
if (image == null) {
|
||||
image = defaultImage;
|
||||
image = _defaultImage;
|
||||
}
|
||||
newItem.DisplayStyle = ToolStripItemDisplayStyle.Text;
|
||||
newItem.Image = image;
|
||||
newItem.CheckOnClick = true;
|
||||
newItem.CheckStateChanged += ItemCheckStateChanged;
|
||||
newItem.Data = data;
|
||||
toolStripMenuSelectListItem.DisplayStyle = ToolStripItemDisplayStyle.Text;
|
||||
toolStripMenuSelectListItem.Image = image;
|
||||
toolStripMenuSelectListItem.CheckOnClick = true;
|
||||
toolStripMenuSelectListItem.CheckStateChanged += ItemCheckStateChanged;
|
||||
toolStripMenuSelectListItem.Data = data;
|
||||
if (isChecked) {
|
||||
if (!multiCheckAllowed) {
|
||||
updateInProgress = true;
|
||||
if (!_multiCheckAllowed) {
|
||||
_updateInProgress = true;
|
||||
UncheckAll();
|
||||
updateInProgress = false;
|
||||
_updateInProgress = false;
|
||||
}
|
||||
newItem.Checked = isChecked;
|
||||
toolStripMenuSelectListItem.Checked = true;
|
||||
}
|
||||
DropDownItems.Add(newItem);
|
||||
DropDownItems.Add(toolStripMenuSelectListItem);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -187,7 +186,7 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
/// <param name="label">the label to be displayed</param>
|
||||
/// <param name="data">the data to be returned when an item is queried</param>
|
||||
public void AddItem(string label, Object data) {
|
||||
public void AddItem(string label, object data) {
|
||||
AddItem(label, null, data, false);
|
||||
}
|
||||
|
||||
|
@ -200,12 +199,11 @@ namespace Greenshot.Forms {
|
|||
}
|
||||
|
||||
|
||||
// <summary>
|
||||
/// <summary>
|
||||
/// adds an item to the select list
|
||||
/// </summary>
|
||||
/// <param name="label">the label to be displayed</param>
|
||||
/// <param name="image">the icon to be displayed</param>
|
||||
/// <param name="selected">whether the item is initially selected</param>
|
||||
/// <param name="isChecked">whether the item is initially checked</param>
|
||||
public void AddItem(string label, Image image, bool isChecked) {
|
||||
AddItem(label, image, null, isChecked);
|
||||
|
@ -217,7 +215,7 @@ namespace Greenshot.Forms {
|
|||
/// <param name="label">the label to be displayed</param>
|
||||
/// <param name="data">the data to be returned when an item is queried</param>
|
||||
/// <param name="isChecked">whether the item is initially checked</param>
|
||||
public void AddItem(string label, Object data, bool isChecked) {
|
||||
public void AddItem(string label, object data, bool isChecked) {
|
||||
AddItem(label, null, data, isChecked);
|
||||
}
|
||||
|
||||
|
@ -235,8 +233,13 @@ namespace Greenshot.Forms {
|
|||
/// </summary>
|
||||
public void UncheckAll() {
|
||||
IEnumerator items = DropDownItems.GetEnumerator();
|
||||
while (items.MoveNext()) {
|
||||
((ToolStripMenuSelectListItem)items.Current).Checked = false;
|
||||
while (items.MoveNext())
|
||||
{
|
||||
var toolStripMenuSelectListItem = (ToolStripMenuSelectListItem)items.Current;
|
||||
if (toolStripMenuSelectListItem != null)
|
||||
{
|
||||
toolStripMenuSelectListItem.Checked = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
4
Greenshot/Forms/TornEdgeSettingsForm.Designer.cs
generated
4
Greenshot/Forms/TornEdgeSettingsForm.Designer.cs
generated
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2015 Thomas Braun, Jens Klingen, Robin Krom
|
||||
* Copyright (C) 2007-2016 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/
|
||||
* 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
|
||||
|
@ -21,50 +21,44 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using Greenshot.Core;
|
||||
using GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Effects;
|
||||
|
||||
namespace Greenshot.Forms {
|
||||
public partial class TornEdgeSettingsForm : BaseForm {
|
||||
private TornEdgeEffect effect;
|
||||
private readonly TornEdgeEffect _effect;
|
||||
public TornEdgeSettingsForm(TornEdgeEffect effect) {
|
||||
this.effect = effect;
|
||||
_effect = effect;
|
||||
InitializeComponent();
|
||||
ShowSettings();
|
||||
}
|
||||
|
||||
private void ShowSettings() {
|
||||
shadowCheckbox.Checked = effect.GenerateShadow;
|
||||
shadowCheckbox.Checked = _effect.GenerateShadow;
|
||||
// Fix to prevent BUG-1753
|
||||
shadowDarkness.Value = Math.Max(shadowDarkness.Minimum, Math.Min(shadowDarkness.Maximum, (int)(effect.Darkness * shadowDarkness.Maximum)));
|
||||
offsetX.Value = effect.ShadowOffset.X;
|
||||
offsetY.Value = effect.ShadowOffset.Y;
|
||||
toothsize.Value = effect.ToothHeight;
|
||||
verticaltoothrange.Value = effect.VerticalToothRange;
|
||||
horizontaltoothrange.Value = effect.HorizontalToothRange;
|
||||
top.Checked = effect.Edges[0];
|
||||
right.Checked = effect.Edges[1];
|
||||
bottom.Checked = effect.Edges[2];
|
||||
left.Checked = effect.Edges[3];
|
||||
shadowDarkness.Value = Math.Max(shadowDarkness.Minimum, Math.Min(shadowDarkness.Maximum, (int)(_effect.Darkness * shadowDarkness.Maximum)));
|
||||
offsetX.Value = _effect.ShadowOffset.X;
|
||||
offsetY.Value = _effect.ShadowOffset.Y;
|
||||
toothsize.Value = _effect.ToothHeight;
|
||||
verticaltoothrange.Value = _effect.VerticalToothRange;
|
||||
horizontaltoothrange.Value = _effect.HorizontalToothRange;
|
||||
top.Checked = _effect.Edges[0];
|
||||
right.Checked = _effect.Edges[1];
|
||||
bottom.Checked = _effect.Edges[2];
|
||||
left.Checked = _effect.Edges[3];
|
||||
}
|
||||
|
||||
private void ButtonOK_Click(object sender, EventArgs e) {
|
||||
effect.Darkness = (float)shadowDarkness.Value / (float)40;
|
||||
effect.ShadowOffset = new Point((int)offsetX.Value, (int)offsetY.Value);
|
||||
effect.ShadowSize = (int)thickness.Value;
|
||||
effect.ToothHeight = (int)toothsize.Value;
|
||||
effect.VerticalToothRange = (int)verticaltoothrange.Value;
|
||||
effect.HorizontalToothRange = (int)horizontaltoothrange.Value;
|
||||
effect.Edges = new bool[] { top.Checked, right.Checked, bottom.Checked, left.Checked };
|
||||
effect.GenerateShadow = shadowCheckbox.Checked;
|
||||
_effect.Darkness = shadowDarkness.Value / (float)40;
|
||||
_effect.ShadowOffset = new Point((int)offsetX.Value, (int)offsetY.Value);
|
||||
_effect.ShadowSize = (int)thickness.Value;
|
||||
_effect.ToothHeight = (int)toothsize.Value;
|
||||
_effect.VerticalToothRange = (int)verticaltoothrange.Value;
|
||||
_effect.HorizontalToothRange = (int)horizontaltoothrange.Value;
|
||||
_effect.Edges = new[] { top.Checked, right.Checked, bottom.Checked, left.Checked };
|
||||
_effect.GenerateShadow = shadowCheckbox.Checked;
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
private void ButtonReset_Click(object sender, EventArgs e) {
|
||||
effect.Reset();
|
||||
ShowSettings();
|
||||
}
|
||||
|
||||
private void ShadowCheckbox_CheckedChanged(object sender, EventArgs e) {
|
||||
thickness.Enabled = shadowCheckbox.Checked;
|
||||
offsetX.Enabled = shadowCheckbox.Checked;
|
||||
|
@ -72,37 +66,37 @@ namespace Greenshot.Forms {
|
|||
shadowDarkness.Enabled = shadowCheckbox.Checked;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void all_CheckedChanged(object sender, EventArgs e) {
|
||||
AnySideChangeChecked(top, all.Checked);
|
||||
AnySideChangeChecked(right, all.Checked);
|
||||
AnySideChangeChecked(bottom, all.Checked);
|
||||
AnySideChangeChecked(left, all.Checked);
|
||||
}
|
||||
private void all_CheckedChanged(object sender, EventArgs e) {
|
||||
AnySideChangeChecked(top, all.Checked);
|
||||
AnySideChangeChecked(right, all.Checked);
|
||||
AnySideChangeChecked(bottom, all.Checked);
|
||||
AnySideChangeChecked(left, all.Checked);
|
||||
}
|
||||
|
||||
private void AnySideCheckedChanged(object sender, EventArgs e) {
|
||||
all.CheckedChanged -= all_CheckedChanged;
|
||||
all.Checked = top.Checked && right.Checked && bottom.Checked && left.Checked;
|
||||
all.CheckedChanged += all_CheckedChanged;
|
||||
}
|
||||
private void AnySideCheckedChanged(object sender, EventArgs e) {
|
||||
all.CheckedChanged -= all_CheckedChanged;
|
||||
all.Checked = top.Checked && right.Checked && bottom.Checked && left.Checked;
|
||||
all.CheckedChanged += all_CheckedChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// changes the Checked property of top/right/bottom/left checkboxes without triggering AnySideCheckedChange
|
||||
/// </summary>
|
||||
/// <param name="cb">Checkbox to change Checked</param>
|
||||
/// <param name="status">true to check</param>
|
||||
private void AnySideChangeChecked(CheckBox cb, bool status) {
|
||||
if (status != cb.Checked) {
|
||||
cb.CheckedChanged -= AnySideCheckedChanged;
|
||||
cb.Checked = status;
|
||||
cb.CheckedChanged += AnySideCheckedChanged;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// changes the Checked property of top/right/bottom/left checkboxes without triggering AnySideCheckedChange
|
||||
/// </summary>
|
||||
/// <param name="cb">Checkbox to change Checked</param>
|
||||
/// <param name="status">true to check</param>
|
||||
private void AnySideChangeChecked(CheckBox cb, bool status) {
|
||||
if (status != cb.Checked) {
|
||||
cb.CheckedChanged -= AnySideCheckedChanged;
|
||||
cb.Checked = status;
|
||||
cb.CheckedChanged += AnySideCheckedChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void TornEdgeSettingsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
private void TornEdgeSettingsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue