"Merged" 0.8 with HEAD, so we can continue developing

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1282 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2011-07-17 12:05:59 +00:00
parent 174f653a5a
commit f3b0878b02
539 changed files with 86855 additions and 0 deletions

View file

@ -0,0 +1,86 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{C6988EE8-2FEE-4349-9F09-F9628A0D8965}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>Library</OutputType>
<RootNamespace>GreenshotOCR</RootNamespace>
<AssemblyName>Greenshot-OCR-Plugin</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Dokumente und Einstellungen\05018085\Anwendungsdaten\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\Greenshot\Lib\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Language.cs" />
<Compile Include="LanguageKeys.cs" />
<Compile Include="ModiInterop.cs" />
<Compile Include="OCRConfiguration.cs" />
<Compile Include="OCRPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SettingsForm.cs" />
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
<None Include="Languages\language_ocrplugin-de-DE.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Languages\language_ocrplugin-en-US.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Languages\language_ocrplugin-nl-NL.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Properties\AssemblyInfo.cs.template" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj">
<Project>{5B924697-4DCD-4F98-85F1-105CB84B7341}</Project>
<Name>GreenshotPlugin</Name>
</ProjectReference>
<Folder Include="Languages" />
</ItemGroup>
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"</PreBuildEvent>
<PostBuildEvent>mkdir "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)"
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"
copy "$(ProjectDir)bin\$(Configuration)\MODI*.dll" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*"
mkdir "$(SolutionDir)bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
copy "$(ProjectDir)bin\$(Configuration)\Languages\*.xml" "$(SolutionDir)bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"</PostBuildEvent>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,47 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Diagnostics;
using System.Globalization;
using System.Resources;
using System.Threading;
using GreenshotPlugin.Core;
namespace GreenshotOCR {
/// <summary>
/// Wrapper for the language container for the Jira plugin.
/// </summary>
public class Language : LanguageContainer, ILanguage {
private static ILanguage uniqueInstance;
private const string LANGUAGE_FILENAME_PATTERN = @"language_ocrplugin-*.xml";
public static ILanguage GetInstance() {
if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer();
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
uniqueInstance.SetLanguage(Thread.CurrentThread.CurrentUICulture.Name);
}
return uniqueInstance;
}
}
}

View file

@ -0,0 +1,29 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace GreenshotOCR {
public enum LangKey {
language,
orient_image,
straighten_image
}
}

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<language description="Deutsch" ietf="de-DE" version="0.8.1">
<resources>
<resource name="language">
Sprache für OCR
</resource>
<resource name="orient_image">
Bild ausrichten
</resource>
<resource name="straighten_image">
Bild glätten
</resource>
</resources>
</language>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<language description="English" ietf="en-US" version="0.8.1">
<resources>
<resource name="language">
Language for OCR
</resource>
<resource name="orient_image">
Orient image
</resource>
<resource name="straighten_image">
Straighten image
</resource>
</resources>
</language>

View file

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<language description="Nederlands" ietf="nl-NL" version="0.8.1">
<resources>
<resource name="language">
Taal voor OCR
</resource>
<resource name="orient_image">
Beeld richten
</resource>
<resource name="straighten_image">
Beeld vereffenen
</resource>
</resources>
</language>

View file

@ -0,0 +1,87 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Collections;
using Greenshot.Interop;
namespace GreenshotOCR {
[ComProgId("MODI.Document")]
public interface ModiDocu : Common {
void Close(bool SaveCall);
IImages Images{
get;
}
void Create(string file);
void OCR(ModiLanguage language, bool Orientimage, bool StraightenImage);
}
public interface Common : IDisposable {
ModiDocu Application { get; }
}
public interface ILayout : Common{
string Text {
get;
}
}
public interface IImage : Common {
ILayout Layout {
get;
}
}
public interface IImages : Common, IEnumerable{
int Count {
get;
}
IImage this [int index] {
get;
}
new IEnumerator GetEnumerator();
}
public enum ModiLanguage {
CHINESE_SIMPLIFIED = 2052,
CHINESE_TRADITIONAL = 1028,
CZECH = 5,
DANISH = 6,
DUTCH = 19,
ENGLISH = 9,
FINNISH = 11,
FRENCH = 12,
GERMAN = 7,
GREEK = 8,
HUNGARIAN = 14,
ITALIAN = 16,
JAPANESE = 17,
KOREAN = 18,
NORWEGIAN = 20,
POLISH = 21,
PORTUGUESE = 22,
RUSSIAN = 25,
SPANISH = 10,
SWEDISH = 29,
TURKISH = 31,
SYSDEFAULT = 2048
}
}

View file

@ -0,0 +1,40 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using GreenshotPlugin.Core;
namespace GreenshotOCR {
/// <summary>
/// Description of CoreConfiguration.
/// </summary>
[IniSection("OCR", Description="Greenshot OCR Plugin configuration")]
public class OCRConfiguration : IniSection {
[IniProperty("Language", Description="Language for OCR", DefaultValue="miLANG_ENGLISH")]
public string Language;
[IniProperty("orientimage", Description="Orient image?", DefaultValue="true")]
public bool Orientimage;
[IniProperty("straightenImage", Description="Straighten image?", DefaultValue="true")]
public bool StraightenImage;
[IniProperty("hotkey", Description="OCR Hotkey", DefaultValue="Alt + Ctrl + PrintScreen")]
public string HotKey;
}
}

View file

@ -0,0 +1,236 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Windows.Forms;
using Greenshot.Interop;
using Greenshot.Plugin;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
//using Microsoft.Win32;
namespace GreenshotOCR {
/// <summary>
/// OCR Plugin Greenshot
/// </summary>
public class OcrPlugin : IGreenshotPlugin {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(OcrPlugin));
private const string CONFIG_FILENAME = "ocr-config.properties";
private IGreenshotPluginHost host;
private ICaptureHost captureHost = null;
private PluginAttribute myAttributes;
private OCRConfiguration config;
private ToolStripMenuItem ocrMenuItem = new ToolStripMenuItem();
private int hotkeyIdentifier = 0;
public OcrPlugin() { }
/// <summary>
/// Implementation of the IGreenshotPlugin.Initialize
/// </summary>
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
/// <param name="pluginAttribute">My own attributes</param>
public void Initialize(IGreenshotPluginHost host, ICaptureHost captureHost, PluginAttribute myAttributes) {
LOG.Debug("Initialize called of " + myAttributes.Name);
this.host = (IGreenshotPluginHost)host;
this.captureHost = captureHost;
this.myAttributes = myAttributes;
if (!HasMODI()) {
LOG.Warn("No MODI found!");
return;
}
// Load configuration
config = IniConfig.GetIniSection<OCRConfiguration>();
if (config.Language != null) {
config.Language = config.Language.Replace("miLANG_","").Replace("_"," ");
}
SetHotkeys();
// Here we can hang ourselves to the main context menu!
ocrMenuItem.Text = "Region OCR";
ocrMenuItem.Click += new System.EventHandler(MainMenuClick);
ContextMenuStrip contextMenu = host.MainMenu;
bool addedItem = false;
// Try to find a separator, so we insert ourselves before
for(int i=0; i < contextMenu.Items.Count; i++) {
if (contextMenu.Items[i].GetType() == typeof(ToolStripSeparator)) {
contextMenu.Items.Insert(i, ocrMenuItem);
addedItem = true;
break;
}
}
// If we didn't insert the item, we just add it...
if (!addedItem) {
contextMenu.Items.Add(ocrMenuItem);
}
}
/// <summary>
/// Implementation of the IGreenshotPlugin.Shutdown
/// </summary>
public void Shutdown() {
LOG.Debug("Shutdown of " + myAttributes.Name);
HotkeyControl.UnregisterHotkey(hotkeyIdentifier);
hotkeyIdentifier = 0;
}
private void SetHotkeys() {
if (hotkeyIdentifier > 0) {
HotkeyControl.UnregisterHotkey(hotkeyIdentifier);
hotkeyIdentifier = 0;
}
hotkeyIdentifier = HotkeyControl.RegisterHotKey(config.HotKey, new HotKeyHandler(MyHotkeyHandler));
if (hotkeyIdentifier > 0) {
ocrMenuItem.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(config.HotKey);
} else {
ocrMenuItem.ShortcutKeyDisplayString = "";
}
}
/// <summary>
/// Implementation of the IPlugin.Configure
/// </summary>
public virtual void Configure() {
if (!HasMODI()) {
MessageBox.Show("Sorry, is seems that Microsoft Office Document Imaging (MODI) is not installed, therefor the OCR Plugin cannot work.");
return;
}
SettingsForm settingsForm = new SettingsForm(Enum.GetNames(typeof(ModiLanguage)), config);
DialogResult result = settingsForm.ShowDialog();
if (result == DialogResult.OK) {
// "Re"set hotkeys
SetHotkeys();
IniConfig.Save();
}
}
private void StartOCRRegion() {
LOG.Debug("Starting OCR!");
captureHost.MakeCapture(CaptureMode.Region, false, new CaptureHandler(DoOCR));
}
private void MyHotkeyHandler() {
StartOCRRegion();
}
/// <summary>
/// Is called when the OCR menu is selected
/// </summary>
/// <param name="sender">ContextMenu</param>
/// <param name="e">EventArgs from ContextMenu</param>
private void MainMenuClick(object sender, EventArgs e) {
StartOCRRegion();
}
/// <summary>
/// Handling of the CaptureTaken "event" from the ICaptureHost
/// We do the OCR here!
/// </summary>
/// <param name="ImageOutputEventArgs">Has the Image and the capture details</param>
private const int MIN_WIDTH = 130;
private const int MIN_HEIGHT = 130;
private void DoOCR(object sender, CaptureTakenEventArgs eventArgs) {
if (eventArgs.Capture.Image == null) {
return;
}
string file = host.GetFilename(OutputFormat.bmp, eventArgs.Capture.CaptureDetails);
string filePath = Path.Combine(Path.GetTempPath(),file);
using (FileStream stream = File.Create(filePath)) {
Image capturedImage = eventArgs.Capture.Image;
if (capturedImage.Width < MIN_WIDTH || capturedImage.Height < MIN_HEIGHT) {
LOG.Debug("Captured image is not big enough for OCR, growing image...");
int newWidth = Math.Max(capturedImage.Width, MIN_WIDTH);
int newHeight = Math.Max(capturedImage.Height, MIN_HEIGHT);
using (Image tmpImage = new Bitmap(newWidth, newHeight, capturedImage.PixelFormat)) {
using (Graphics graphics = Graphics.FromImage(tmpImage)) {
graphics.Clear(Color.White);
graphics.DrawImage(capturedImage, Point.Empty);
}
host.SaveToStream(tmpImage, stream, OutputFormat.bmp, 100);
}
} else {
host.SaveToStream(capturedImage, stream, OutputFormat.bmp, 100);
}
}
LOG.Debug("Saved tmp file to: " + filePath);
string text = "";
try {
using (ModiDocu modiDocument = (ModiDocu)COMWrapper.GetOrCreateInstance(typeof(ModiDocu))) {
modiDocument.Create(filePath);
modiDocument.OCR((ModiLanguage)Enum.Parse(typeof(ModiLanguage), config.Language), config.Orientimage, config.StraightenImage);
IImage modiImage = modiDocument.Images[0];
ILayout layout = modiImage.Layout;
text = layout.Text;
modiDocument.Close(false);
}
} catch (Exception e) {
LOG.Error("Error while calling Microsoft Office Document Imaging (MODI) to OCR: ", e);
} finally {
if (File.Exists(filePath)) {
LOG.Debug("Cleaning up tmp file: " + filePath);
File.Delete(filePath);
}
}
if (text == null || text.Trim().Length == 0) {
return;
}
try {
LOG.DebugFormat("Pasting OCR Text to Clipboard: {0}", text);
// Paste to Clipboard (the Plugin currently doesn't have access to the ClipboardHelper from Greenshot
IDataObject ido = new DataObject();
ido.SetData(DataFormats.Text, true, text);
Clipboard.SetDataObject(ido, true);
} catch (Exception e) {
LOG.Error("Problem pasting text to clipboard: ", e);
}
}
private bool HasMODI() {
try {
using (ModiDocu modiDocument = (ModiDocu)COMWrapper.GetOrCreateInstance(typeof(ModiDocu))) {
modiDocument.Close(false);
}
return true;
} catch(Exception e) {
LOG.Debug("Error trying to initiate MODI:", e);
}
LOG.InfoFormat("No Microsoft Office Document Imaging (MODI) found, disabling OCR");
return false;
}
}
}

View file

@ -0,0 +1,54 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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/>.
*/
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Greenshot.Plugin;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("GreenshotOCR")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("GreenshotOCR")]
[assembly: AssemblyCopyright("Copyright (C) 2007-2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The PluginAttribute describes the "entryType" and if the plugin is configurable
[assembly: PluginAttribute("GreenshotOCR.OcrPlugin", true)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.$WCREV$")]

View file

@ -0,0 +1,164 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace GreenshotOCR
{
partial class SettingsForm
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.comboBox_languages = new System.Windows.Forms.ComboBox();
this.checkBox_orientImage = new System.Windows.Forms.CheckBox();
this.checkBox_straightenImage = new System.Windows.Forms.CheckBox();
this.label_language = new System.Windows.Forms.Label();
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.ocr_hotkeyControl = new GreenshotPlugin.Controls.HotkeyControl();
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// comboBox_languages
//
this.comboBox_languages.FormattingEnabled = true;
this.comboBox_languages.Items.AddRange(new object[] {
"English",
"Deutsch"});
this.comboBox_languages.Location = new System.Drawing.Point(74, 12);
this.comboBox_languages.Name = "comboBox_languages";
this.comboBox_languages.Size = new System.Drawing.Size(153, 21);
this.comboBox_languages.TabIndex = 0;
//
// checkBox_orientImage
//
this.checkBox_orientImage.Location = new System.Drawing.Point(13, 68);
this.checkBox_orientImage.Name = "checkBox_orientImage";
this.checkBox_orientImage.Size = new System.Drawing.Size(104, 24);
this.checkBox_orientImage.TabIndex = 1;
this.checkBox_orientImage.Text = "Orient image";
this.checkBox_orientImage.UseVisualStyleBackColor = true;
//
// checkBox_straightenImage
//
this.checkBox_straightenImage.Location = new System.Drawing.Point(118, 68);
this.checkBox_straightenImage.Name = "checkBox_straightenImage";
this.checkBox_straightenImage.Size = new System.Drawing.Size(109, 24);
this.checkBox_straightenImage.TabIndex = 2;
this.checkBox_straightenImage.Text = "Straighten image";
this.checkBox_straightenImage.UseVisualStyleBackColor = true;
//
// label_language
//
this.label_language.Location = new System.Drawing.Point(13, 15);
this.label_language.Name = "label_language";
this.label_language.Size = new System.Drawing.Size(55, 23);
this.label_language.TabIndex = 3;
this.label_language.Text = "Language";
//
// buttonOK
//
this.buttonOK.Location = new System.Drawing.Point(12, 98);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(104, 23);
this.buttonOK.TabIndex = 4;
this.buttonOK.Text = "OK";
this.buttonOK.UseVisualStyleBackColor = true;
this.buttonOK.Click += new System.EventHandler(this.ButtonOKClick);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(122, 98);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(104, 23);
this.buttonCancel.TabIndex = 5;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick);
//
// ocr_hotkeyControl
//
this.ocr_hotkeyControl.Hotkey = System.Windows.Forms.Keys.None;
this.ocr_hotkeyControl.HotkeyModifiers = System.Windows.Forms.Keys.None;
this.ocr_hotkeyControl.Location = new System.Drawing.Point(74, 39);
this.ocr_hotkeyControl.Name = "ocr_hotkeyControl";
this.ocr_hotkeyControl.Size = new System.Drawing.Size(153, 20);
this.ocr_hotkeyControl.TabIndex = 6;
//
// label1
//
this.label1.ForeColor = System.Drawing.SystemColors.ControlText;
this.label1.Location = new System.Drawing.Point(13, 42);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(55, 23);
this.label1.TabIndex = 7;
this.label1.Text = "Hotkey";
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(244, 135);
this.Controls.Add(this.label1);
this.Controls.Add(this.ocr_hotkeyControl);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.label_language);
this.Controls.Add(this.checkBox_straightenImage);
this.Controls.Add(this.checkBox_orientImage);
this.Controls.Add(this.comboBox_languages);
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.Name = "SettingsForm";
this.Text = "SettingsForm";
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Label label1;
private GreenshotPlugin.Controls.HotkeyControl ocr_hotkeyControl;
private System.Windows.Forms.Label label_language;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.CheckBox checkBox_orientImage;
private System.Windows.Forms.CheckBox checkBox_straightenImage;
private System.Windows.Forms.ComboBox comboBox_languages;
}
}

View file

@ -0,0 +1,87 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
namespace GreenshotOCR {
/// <summary>
/// Description of SettingsForm.
/// </summary>
public partial class SettingsForm : Form {
private ILanguage language = Language.GetInstance();
private OCRConfiguration config;
public SettingsForm(string [] languages, OCRConfiguration config) {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
this.config = config;
InitializeComponent();
language.SynchronizeLanguageToCulture();
initializeComponentText();
comboBox_languages.Items.Clear();
int index=0;
// Preventing Tracker #3234560, although this should not happen...
string languageFromConfig = "ENGLISH";
if (config.Language != null) {
languageFromConfig = config.Language;
}
foreach(string availableLanguage in languages) {
string displayLanguage = availableLanguage.Substring(0, 1).ToUpper() + availableLanguage.Substring(1).ToLower();
comboBox_languages.Items.Add(displayLanguage);
if (availableLanguage.Equals(languageFromConfig, StringComparison.CurrentCultureIgnoreCase)) {
comboBox_languages.SelectedIndex = index;
}
index++;
}
checkBox_orientImage.Checked = config.Orientimage;
checkBox_straightenImage.Checked = config.StraightenImage;
ocr_hotkeyControl.SetHotkey(config.HotKey);
}
private void initializeComponentText() {
this.label_language.Text = language.GetString(LangKey.language);
this.checkBox_orientImage.Text = language.GetString(LangKey.orient_image);
}
void ButtonCancelClick(object sender, EventArgs e) {
DialogResult = DialogResult.Cancel;
}
void ButtonOKClick(object sender, EventArgs e) {
string selectedString = (string) comboBox_languages.SelectedItem;
if (selectedString != null) {
config.Language = selectedString.ToUpper();
}
config.Orientimage = checkBox_orientImage.Checked;
config.StraightenImage = checkBox_straightenImage.Checked;
DialogResult = DialogResult.OK;
}
}
}

View file

@ -0,0 +1,72 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{47F23C86-604E-4CC3-8767-B3D4088F30BB}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>Library</OutputType>
<RootNamespace>Greenshot_RunAtOutput_Plugin</RootNamespace>
<AssemblyName>Greenshot-RunAtOutput-Plugin</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Users\Robin\AppData\Roaming\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\Greenshot\Lib\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="RunAtOutput.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RunAtOutputConfiguration.cs" />
<Compile Include="SettingsForm.cs" />
<Compile Include="SettingsForm.Designer.cs">
<DependentUpon>SettingsForm.cs</DependentUpon>
</Compile>
<None Include="Properties\AssemblyInfo.cs.template" />
</ItemGroup>
<PropertyGroup>
<PreBuildEvent>"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"</PreBuildEvent>
<PostBuildEvent>mkdir "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)"
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"</PostBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj">
<Project>{5B924697-4DCD-4F98-85F1-105CB84B7341}</Project>
<Name>GreenshotPlugin</Name>
</ProjectReference>
</ItemGroup>
</Project>

View file

@ -0,0 +1,53 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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/>.
*/
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Greenshot.Plugin;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Greenshot-RunAtOutput-Plugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Greenshot-RunAtOutput-Plugin")]
[assembly: AssemblyCopyright("Copyright (C) 2007-2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: PluginAttribute("RunAtOutput.RunAtOutputPlugin", true)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.$WCREV$")]

View file

@ -0,0 +1,104 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
namespace RunAtOutput {
/// <summary>
/// An Plugin to run commands after an image was written
/// </summary>
public class RunAtOutputPlugin : IGreenshotPlugin {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(RunAtOutputPlugin));
private IGreenshotPluginHost host;
private ICaptureHost captureHost = null;
private PluginAttribute myAttributes;
private RunAtOutputConfiguration config;
public RunAtOutputPlugin() {
}
/// <summary>
/// Implementation of the IGreenshotPlugin.Initialize
/// </summary>
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
/// <param name="pluginAttribute">My own attributes</param>
public virtual void Initialize(IGreenshotPluginHost pluginHost, ICaptureHost captureHost, PluginAttribute myAttributes) {
LOG.Debug("Initialize called of " + myAttributes.Name);
this.host = (IGreenshotPluginHost)pluginHost;
this.captureHost = captureHost;
this.myAttributes = myAttributes;
this.host.OnImageOutput += new OnImageOutputHandler(ImageOutput);
this.config = IniConfig.GetIniSection<RunAtOutputConfiguration>();
}
public virtual void Shutdown() {
LOG.Debug("Shutdown of " + myAttributes.Name);
this.host.OnImageOutput -= new OnImageOutputHandler(ImageOutput);
}
/// <summary>
/// Implementation of the IPlugin.Configure
/// </summary>
public virtual void Configure() {
LOG.Debug("Configure called");
new SettingsForm().ShowDialog();
}
/// <summary>
/// Handling of the OnImageOutputHandler event from the IGreenshotPlugin
/// </summary>
/// <param name="ImageOutputEventArgs">Has the FullPath to the image</param>
private void ImageOutput(object sender, ImageOutputEventArgs eventArgs) {
LOG.Debug("ImageOutput called with full path: " + eventArgs.FullPath);
foreach(string commando in config.active) {
string commandline = config.commandlines[commando];
string arguments = config.arguments[commando];
if (commandline != null && commandline.Length > 0) {
Process p = new Process();
p.StartInfo.FileName = commandline;
p.StartInfo.Arguments = String.Format(arguments, eventArgs.FullPath);
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
LOG.Info("Starting : " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
p.Start();
string output = p.StandardOutput.ReadToEnd();
if (output != null && output.Trim().Length > 0) {
LOG.Info("Output:\n" + output);
}
LOG.Info("Finished : " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
}
}
}
}
}

View file

@ -0,0 +1,75 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using GreenshotPlugin.Core;
namespace RunAtOutput {
/// <summary>
/// Description of FlickrConfiguration.
/// </summary>
[IniSection("RunAtOutput", Description="Greenshot TitRunAtOutputleFix Plugin configuration")]
public class RunAtOutputConfiguration : IniSection {
[IniProperty("Commands", Description="The commands that are available.")]
public List<string> commands;
//[IniProperty("Matcher", Description="Match filenames or types.")]
//public Dictionary<string, string> matchers;
[IniProperty("Commandline", Description="The commandline for the output command.")]
public Dictionary<string, string> commandlines;
[IniProperty("Argument", Description="The arguments for the output command.")]
public Dictionary<string, string> arguments;
[IniProperty("ActiveCommands", Description="The commands that are active.")]
public List<string> active;
/// <summary>
/// Supply values we can't put as defaults
/// </summary>
/// <param name="property">The property to return a default for</param>
/// <returns>object with the default value for the supplied property</returns>
public override object GetDefault(string property) {
switch(property) {
case "Commands":
List<string> commandDefaults = new List<string>();
commandDefaults.Add("Paint.NET");
return commandDefaults;
case "Commandline":
Dictionary<string, string> commandlineDefaults = new Dictionary<string, string>();
commandlineDefaults.Add("Paint.NET", @"C:\Programme\Paint.NET\PaintDotNet.exe");
return commandlineDefaults;
// case "Matcher":
// Dictionary<string, string> matcherDefaults = new Dictionary<string, string>();
// matcherDefaults.Add("Paint.NET", "*");
// return matcherDefaults;
case "ActiveCommands":
return new List<string>();
case "Argument":
Dictionary<string, string> argumentDefaults = new Dictionary<string, string>();
argumentDefaults.Add("Paint.NET", "\"{0}\"");
return argumentDefaults;
}
return null;
}
}
}

View file

@ -0,0 +1,211 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace RunAtOutput {
partial class SettingsForm {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.textBox_commandline = new System.Windows.Forms.TextBox();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonOk = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.textBox_arguments = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.listView1 = new System.Windows.Forms.ListView();
this.columnHeader1 = new System.Windows.Forms.ColumnHeader();
this.columnHeader2 = new System.Windows.Forms.ColumnHeader();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.label3 = new System.Windows.Forms.Label();
this.textBox_name = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// textBox_commandline
//
this.textBox_commandline.Location = new System.Drawing.Point(229, 245);
this.textBox_commandline.Name = "textBox_commandline";
this.textBox_commandline.Size = new System.Drawing.Size(184, 20);
this.textBox_commandline.TabIndex = 2;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(339, 302);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 7;
this.buttonCancel.Text = "Cancel";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick);
//
// buttonOk
//
this.buttonOk.Location = new System.Drawing.Point(258, 302);
this.buttonOk.Name = "buttonOk";
this.buttonOk.Size = new System.Drawing.Size(75, 23);
this.buttonOk.TabIndex = 6;
this.buttonOk.Text = "OK";
this.buttonOk.UseVisualStyleBackColor = true;
this.buttonOk.Click += new System.EventHandler(this.ButtonOkClick);
//
// label1
//
this.label1.Location = new System.Drawing.Point(153, 248);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(56, 17);
this.label1.TabIndex = 3;
this.label1.Text = "Command";
//
// textBox_arguments
//
this.textBox_arguments.Location = new System.Drawing.Point(229, 271);
this.textBox_arguments.Name = "textBox_arguments";
this.textBox_arguments.Size = new System.Drawing.Size(184, 20);
this.textBox_arguments.TabIndex = 3;
//
// label2
//
this.label2.Location = new System.Drawing.Point(153, 274);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(70, 17);
this.label2.TabIndex = 5;
this.label2.Text = "Arguments";
//
// listView1
//
this.listView1.CheckBoxes = true;
this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.columnHeader1,
this.columnHeader2});
this.listView1.FullRowSelect = true;
this.listView1.Location = new System.Drawing.Point(13, 13);
this.listView1.MultiSelect = false;
this.listView1.Name = "listView1";
this.listView1.Size = new System.Drawing.Size(400, 183);
this.listView1.Sorting = System.Windows.Forms.SortOrder.Ascending;
this.listView1.TabIndex = 0;
this.listView1.UseCompatibleStateImageBehavior = false;
this.listView1.View = System.Windows.Forms.View.Details;
this.listView1.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.ListView1ItemChecked);
this.listView1.SelectedIndexChanged += new System.EventHandler(this.ListView1ItemSelectionChanged);
//
// columnHeader1
//
this.columnHeader1.Text = "Active";
//
// columnHeader2
//
this.columnHeader2.Text = "Name";
this.columnHeader2.Width = 311;
//
// button1
//
this.button1.Location = new System.Drawing.Point(13, 202);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 4;
this.button1.Text = "Add";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.ButtonAddClick);
//
// button2
//
this.button2.Location = new System.Drawing.Point(12, 231);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 5;
this.button2.Text = "Delete";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.ButtonDeleteClick);
//
// label3
//
this.label3.Location = new System.Drawing.Point(154, 222);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(56, 17);
this.label3.TabIndex = 10;
this.label3.Text = "Name";
//
// textBox_name
//
this.textBox_name.Location = new System.Drawing.Point(230, 219);
this.textBox_name.Name = "textBox_name";
this.textBox_name.Size = new System.Drawing.Size(184, 20);
this.textBox_name.TabIndex = 1;
//
// SettingsForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(426, 336);
this.Controls.Add(this.label3);
this.Controls.Add(this.textBox_name);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.listView1);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBox_arguments);
this.Controls.Add(this.label1);
this.Controls.Add(this.buttonOk);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.textBox_commandline);
this.Name = "SettingsForm";
this.Text = "Command Editor";
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.TextBox textBox_name;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.ColumnHeader columnHeader2;
private System.Windows.Forms.ColumnHeader columnHeader1;
private System.Windows.Forms.ListView listView1;
private System.Windows.Forms.TextBox textBox_arguments;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox textBox_commandline;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button buttonOk;
private System.Windows.Forms.Button buttonCancel;
}
}

View file

@ -0,0 +1,110 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Windows.Forms;
using GreenshotPlugin.Core;
namespace RunAtOutput {
/// <summary>
/// Description of SettingsForm.
/// </summary>
public partial class SettingsForm : Form {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm));
private RunAtOutputConfiguration config;
public SettingsForm() {
this.config = IniConfig.GetIniSection<RunAtOutputConfiguration>();
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
UpdateView();
}
void ButtonOkClick(object sender, EventArgs e) {
IniConfig.Save();
DialogResult = DialogResult.OK;
}
void ButtonCancelClick(object sender, EventArgs e) {
DialogResult = DialogResult.Cancel;
}
void ShowSelectedItem() {
foreach ( ListViewItem item in listView1.SelectedItems ) {
string commando = item.Tag as string;
textBox_name.Text = commando;
textBox_commandline.Text = config.commandlines[commando];
textBox_arguments.Text = config.arguments[commando];
}
}
void ButtonAddClick(object sender, EventArgs e) {
config.commands.Add(textBox_name.Text);
config.commandlines.Add(textBox_name.Text, textBox_commandline.Text);
config.arguments.Add(textBox_name.Text, textBox_arguments.Text);
UpdateView();
}
void ButtonDeleteClick(object sender, EventArgs e) {
foreach ( ListViewItem item in listView1.SelectedItems ) {
string commando = item.Tag as string;
config.active.Remove(textBox_name.Text);
config.commands.Remove(textBox_name.Text);
config.commandlines.Remove(textBox_name.Text);
config.arguments.Remove(textBox_name.Text);
}
UpdateView();
}
void UpdateView() {
listView1.Items.Clear();
if (config.commands != null) {
foreach(string commando in config.commands) {
ListViewItem item = new ListViewItem("");
item.SubItems.Add(commando);
if (config.active != null) {
item.Checked = config.active.Contains(commando);
}
item.Tag = commando;
listView1.Items.Add(item);
}
}
}
void ListView1ItemSelectionChanged(object sender, EventArgs e) {
ShowSelectedItem();
}
void ListView1ItemChecked(object sender, ItemCheckedEventArgs e) {
string commando = e.Item.Tag as string;
LOG.Debug("ItemChecked " + commando + " to " + e.Item.Checked);
if (e.Item.Checked && !config.active.Contains(commando)) {
config.active.Add(commando);
}
if (!e.Item.Checked) {
config.active.Remove(commando);
}
}
}
}

View file

@ -0,0 +1,120 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
namespace TitleFix {
/// <summary>
/// An example Plugin so developers can see how they can develop their own plugin
/// </summary>
public class TitleFix : IGreenshotPlugin {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(TitleFix));
private IGreenshotPluginHost host;
private ICaptureHost captureHost = null;
private PluginAttribute myAttributes;
private TitleFixConfiguration config = null;
public TitleFix() {
}
/// <summary>
/// Implementation of the IGreenshotPlugin.Initialize
/// </summary>
/// <param name="host">Use the IGreenshotPluginHost interface to register events</param>
/// <param name="captureHost">Use the ICaptureHost interface to register in the MainContextMenu</param>
/// <param name="pluginAttribute">My own attributes</param>
public virtual void Initialize(IGreenshotPluginHost pluginHost, ICaptureHost captureHost, PluginAttribute myAttributes) {
LOG.Debug("Initialize called of " + myAttributes.Name);
this.host = (IGreenshotPluginHost)pluginHost;
this.captureHost = captureHost;
this.myAttributes = myAttributes;
this.config = IniConfig.GetIniSection<TitleFixConfiguration>();
// check configuration
List<string> corruptKeys = new List<string>();
foreach(string key in config.active) {
if (!config.matchers.ContainsKey(key) || !config.matchers.ContainsKey(key)) {
LOG.Warn("Key " + key + " not found, configuration is broken! Disabling this key!");
corruptKeys.Add(key);
}
}
// Fix configuration if needed
if(corruptKeys.Count > 0) {
foreach(string corruptKey in corruptKeys) {
// Removing any reference to the key
config.active.Remove(corruptKey);
config.matchers.Remove(corruptKey);
config.replacers.Remove(corruptKey);
}
config.IsDirty = true;
}
if(config.IsDirty) {
IniConfig.Save();
}
this.host.OnCaptureTaken += new OnCaptureTakenHandler(CaptureTaken);
}
public virtual void Shutdown() {
LOG.Debug("Shutdown of " + myAttributes.Name);
this.host.OnCaptureTaken -= new OnCaptureTakenHandler(CaptureTaken);
}
/// <summary>
/// Implementation of the IPlugin.Configure
/// </summary>
public virtual void Configure() {
LOG.Debug("Configure called");
}
/// <summary>
/// Implementation of the OnCaptureTaken event
/// </summary>
private void CaptureTaken(object sender, CaptureTakenEventArgs eventArgs) {
string title = eventArgs.Capture.CaptureDetails.Title;
LOG.Debug("Title before: " + title);
if (title != null && title.Length > 0) {
title = title.Trim();
foreach(string titleIdentifier in config.active) {
string regexpString = config.matchers[titleIdentifier];
string replaceString = config.replacers[titleIdentifier];
if (regexpString != null && regexpString.Length > 0) {
Regex regex = new Regex(regexpString);
title = regex.Replace(title, replaceString);
}
}
}
LOG.Debug("Title after: " + title);
eventArgs.Capture.CaptureDetails.Title = title;
}
}
}

View file

@ -0,0 +1,66 @@
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{0A07500E-7404-48D7-8789-7EB2A23E0DD5}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>Library</OutputType>
<RootNamespace>Greenshot_TitleFix_Plugin</RootNamespace>
<AssemblyName>Greenshot-TitleFix-Plugin</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<AppDesignerFolder>Properties</AppDesignerFolder>
<SourceAnalysisOverrideSettingsFile>C:\Dokumente und Einstellungen\05018085\Anwendungsdaten\ICSharpCode/SharpDevelop3.0\Settings.SourceAnalysis</SourceAnalysisOverrideSettingsFile>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
<PlatformTarget>x86</PlatformTarget>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>False</Optimize>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\Greenshot\Lib\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="FixTitle.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TitleFixConfiguration.cs" />
<None Include="Properties\AssemblyInfo.cs.template" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>mkdir "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)"
copy "$(ProjectDir)bin\$(Configuration)\$(TargetFileName)" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\*.gsp"
</PostBuildEvent>
<PreBuildEvent>"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(SolutionDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"</PreBuildEvent>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj">
<Project>{5B924697-4DCD-4F98-85F1-105CB84B7341}</Project>
<Name>GreenshotPlugin</Name>
</ProjectReference>
</ItemGroup>
</Project>

View file

@ -0,0 +1,54 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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/>.
*/
#region Using directives
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using Greenshot.Plugin;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Greenshot-TitleFix-Plugin")]
[assembly: AssemblyDescription("A plugin to fix captured Window Titles")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Greenshot-TitleFix-Plugin")]
[assembly: AssemblyCopyright("Copyright (C) 2007-2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The PluginAttribute describes the "entryType" and if the plugin is configurable
[assembly: PluginAttribute("TitleFix.TitleFix", false)]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all the values or you can use the default the Revision and
// Build Numbers by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.0.$WCREV$")]

View file

@ -0,0 +1,69 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using GreenshotPlugin.Core;
namespace TitleFix {
/// <summary>
/// Description of FlickrConfiguration.
/// </summary>
[IniSection("TitleFix", Description="Greenshot TitleFix Plugin configuration")]
public class TitleFixConfiguration : IniSection {
[IniProperty("ActiveFixes", Description="The fixes that are active.")]
public List<string> active;
[IniProperty("Matcher", Description="The regular expressions to match the title with.")]
public Dictionary<string, string> matchers;
[IniProperty("Replacer", Description="The replacements for the matchers.")]
public Dictionary<string, string> replacers;
/// <summary>
/// Supply values we can't put as defaults
/// </summary>
/// <param name="property">The property to return a default for</param>
/// <returns>object with the default value for the supplied property</returns>
public override object GetDefault(string property) {
switch(property) {
case "ActiveFixes":
List<string> activeDefaults = new List<string>();
activeDefaults.Add("Firefox");
activeDefaults.Add("IE");
activeDefaults.Add("Chrome");
return activeDefaults;
case "Matcher":
Dictionary<string, string> matcherDefaults = new Dictionary<string, string>();
matcherDefaults.Add("Firefox", " - Mozilla Firefox.*");
matcherDefaults.Add("IE", " - Microsoft Internet Explorer.*");
matcherDefaults.Add("Chrome", " - Google Chrome.*");
return matcherDefaults;
case "Replacer":
Dictionary<string, string> replacerDefaults = new Dictionary<string, string>();
replacerDefaults.Add("Firefox", "");
replacerDefaults.Add("IE", "");
replacerDefaults.Add("Chrome", "");
return replacerDefaults;
}
return null;
}
}
}

View file

@ -0,0 +1,51 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("Greenshot")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Greenshot")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// This sets the default COM visibility of types in the assembly to invisible.
// If you need to expose a type to COM, use [ComVisible(true)] on that type.
[assembly: ComVisible(false)]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("0.8.1.$WCREV$")]

View file

@ -0,0 +1,235 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using Greenshot.Drawing;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.UnmanagedHelpers;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
namespace Greenshot.Configuration {
public enum ScreenshotDestinations {Editor=1, FileDefault=2, FileWithDialog=4, Clipboard=8, Printer=16, EMail=32}
/// <summary>
/// AppConfig is used for loading and saving the configuration. All public fields
/// in this class are serialized with the BinaryFormatter and then saved to the
/// config file. After loading the values from file, SetDefaults iterates over
/// all public fields an sets fields set to null to the default value.
/// </summary>
[Serializable]
public class AppConfig {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AppConfig));
private static readonly Regex FIXOLD_REGEXP = new Regex(@"%(?<variable>[\w]+)%", RegexOptions.Compiled);
private const string VAR_PREFIX = "${";
private const string VAR_POSTFIX = "}";
//private static string loc = Assembly.GetExecutingAssembly().Location;
//private static string oldFilename = Path.Combine(loc.Substring(0,loc.LastIndexOf(@"\")),"config.dat");
private const string CONFIG_FILE_NAME = "config.dat";
private static string configfilepath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),@"Greenshot\");
// the configuration part - all public vars are stored in the config file
// don't use "null" and "0" as default value!
#region general application config
public bool? General_IsFirstLaunch = true;
#endregion
#region capture config
public bool? Capture_Mousepointer = true;
public bool? Capture_Windows_Interactive = false;
public int Capture_Wait_Time = 101;
public bool? fixedWaitTime = false;
#endregion
#region user interface config
public string Ui_Language = "";
public bool? Ui_Effects_CameraSound = true;
#endregion
#region output config
public ScreenshotDestinations Output_Destinations = ScreenshotDestinations.Editor;
public string Output_File_Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
public string Output_File_FilenamePattern = "${capturetime}_${title}";
public string Output_File_Format = ImageFormat.Png.ToString();
public bool? Output_File_CopyPathToClipboard = false;
public int Output_File_JpegQuality = 80;
public bool? Output_File_PromptJpegQuality = false;
public int Output_File_IncrementingNumber = 1;
public string Output_FileAs_Fullpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"dummy.png");
public bool? Output_Print_PromptOptions = true;
public bool? Output_Print_AllowRotate = true;
public bool? Output_Print_AllowEnlarge = true;
public bool? Output_Print_AllowShrink = true;
public bool? Output_Print_Center = true;
public bool? Output_Print_Timestamp = true;
#endregion
#region editor config
public WindowPlacement Editor_Placement;
public Color[] Editor_RecentColors = new Color[12];
public Font Editor_Font = null;
#endregion
/// <summary>
/// a private constructor because this is a singleton
/// </summary>
private AppConfig() {
}
/// <summary>
/// Remove the old %VAR% syntax
/// </summary>
/// <param name="oldPattern">String with old syntax %VAR%</param>
/// <returns>The fixed pattern</returns>
private static string FixFallback(string oldPattern) {
return FIXOLD_REGEXP.Replace(oldPattern, new MatchEvaluator(delegate(Match m) { return VAR_PREFIX + m.Groups["variable"].Value + VAR_POSTFIX;}));
}
/// <summary>
/// loads the configuration from the config file
/// </summary>
/// <returns>an instance of AppConfig with all values set from the config file</returns>
private static AppConfig Load() {
AppConfig conf = null;
if (File.Exists(Path.Combine(Application.StartupPath, CONFIG_FILE_NAME))) {
configfilepath = Application.StartupPath;
}
string configfilename = Path.Combine(configfilepath, CONFIG_FILE_NAME);
try {
LOG.DebugFormat("Loading configuration from: {0}", configfilename);
using (FileStream fileStream = File.Open(configfilename, FileMode.Open, FileAccess.Read)) {
BinaryFormatter binaryFormatter = new BinaryFormatter();
conf = (AppConfig) binaryFormatter.Deserialize(fileStream);
}
conf.Output_File_FilenamePattern = FixFallback(conf.Output_File_FilenamePattern);
conf.Output_File_Path = FixFallback(conf.Output_File_Path);
} catch (Exception e) {
LOG.Warn("(ignoring) Problem loading configuration from: " + configfilename, e);
}
return conf;
}
public static void UpgradeToIni() {
bool normalIni = File.Exists(Path.Combine(configfilepath, CONFIG_FILE_NAME));
bool startupIni = File.Exists(Path.Combine(Application.StartupPath, CONFIG_FILE_NAME));
if (startupIni || normalIni) {
AppConfig appConfig = Load();
if (appConfig != null) {
LOG.Info("Migrating old configuration");
CoreConfiguration coreConfiguration = IniConfig.GetIniSection<CoreConfiguration>();
EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
// copy values
try {
coreConfiguration.OutputFileFilenamePattern = appConfig.Output_File_FilenamePattern;
if (appConfig.Output_File_Format != null) {
coreConfiguration.OutputFileFormat = (OutputFormat)Enum.Parse(typeof(OutputFormat), appConfig.Output_File_Format.ToLower());
}
coreConfiguration.OutputFileIncrementingNumber = unchecked((uint)appConfig.Output_File_IncrementingNumber);
coreConfiguration.OutputFileJpegQuality = appConfig.Output_File_JpegQuality;
coreConfiguration.OutputFilePath = appConfig.Output_File_Path;
coreConfiguration.OutputFilePromptJpegQuality = (bool)appConfig.Output_File_PromptJpegQuality;
coreConfiguration.Language = appConfig.Ui_Language;
coreConfiguration.PlayCameraSound = (bool)appConfig.Ui_Effects_CameraSound;
coreConfiguration.CaptureMousepointer = (bool)appConfig.Capture_Mousepointer;
coreConfiguration.OutputFileCopyPathToClipboard = (bool)appConfig.Output_File_CopyPathToClipboard;
coreConfiguration.OutputPrintAllowEnlarge = (bool)appConfig.Output_Print_AllowEnlarge;
coreConfiguration.OutputPrintAllowRotate = (bool)appConfig.Output_Print_AllowRotate;
coreConfiguration.OutputPrintAllowShrink = (bool)appConfig.Output_Print_AllowShrink;
coreConfiguration.OutputPrintCenter = (bool)appConfig.Output_Print_Center;
coreConfiguration.OutputPrintPromptOptions = (bool)appConfig.Output_Print_PromptOptions;
coreConfiguration.OutputPrintTimestamp = (bool)appConfig.Output_Print_Timestamp;
int delay = appConfig.Capture_Wait_Time-1;
if (delay < 0) {
delay = 0;
}
coreConfiguration.CaptureDelay = delay;
if ((appConfig.Output_Destinations & ScreenshotDestinations.Clipboard) == ScreenshotDestinations.Clipboard) {
coreConfiguration.OutputDestinations.Add(Destination.Clipboard);
}
if ((appConfig.Output_Destinations & ScreenshotDestinations.Editor) == ScreenshotDestinations.Editor) {
coreConfiguration.OutputDestinations.Add(Destination.Editor);
}
if ((appConfig.Output_Destinations & ScreenshotDestinations.EMail) == ScreenshotDestinations.EMail) {
coreConfiguration.OutputDestinations.Add(Destination.EMail);
}
if ((appConfig.Output_Destinations & ScreenshotDestinations.Printer) == ScreenshotDestinations.Printer) {
coreConfiguration.OutputDestinations.Add(Destination.Printer);
}
if ((appConfig.Output_Destinations & ScreenshotDestinations.FileDefault) == ScreenshotDestinations.FileDefault) {
coreConfiguration.OutputDestinations.Add(Destination.FileDefault);
}
if ((appConfig.Output_Destinations & ScreenshotDestinations.FileWithDialog) == ScreenshotDestinations.FileWithDialog) {
coreConfiguration.OutputDestinations.Add(Destination.FileWithDialog);
}
IniConfig.Save();
} catch (Exception e) {
LOG.Error(e);
}
}
try {
LOG.Info("Deleting old configuration");
File.Delete(Path.Combine(configfilepath, CONFIG_FILE_NAME));
} catch (Exception e) {
LOG.Error(e);
}
}
}
/// <summary>
/// Checks for the existence of a configuration file.
/// First in greenshot's Applicationdata folder (where it is stored since 0.6),
/// then (if it cannot be found there) in greenshot's program directory (where older
/// versions might have stored it).
/// If the latter is the case, the file is moved to the new location, so that a user does not lose
/// their configuration after upgrading.
/// If there is no file in both locations, a virgin config file is created.
/// </summary>
private static void CheckConfigFile() {
// check if file is in the same location as started from, if this is the case
// we will use this file instead of the ApplicationDate folder
// Done for Feature Request #2741508
if (File.Exists(Path.Combine(Application.StartupPath, CONFIG_FILE_NAME))) {
configfilepath = Application.StartupPath;
}
}
}
}

View file

@ -0,0 +1,135 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using Greenshot.Drawing;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.UnmanagedHelpers;
using GreenshotPlugin.Core;
namespace Greenshot.Configuration {
/// <summary>
/// Description of CoreConfiguration.
/// </summary>
[IniSection("Editor", Description="Greenshot editor configuration")]
public class EditorConfiguration : IniSection {
[IniProperty("RecentColors", Separator="|", Description="Last used colors")]
public List<Color> RecentColors;
[IniProperty("LastFieldValue", Separator="|", Description="Field values, make sure the last used settings are re-used")]
public Dictionary<string, object> LastUsedFieldValues;
[IniProperty("MatchSizeToCapture", Description="Match the editor window size to the capture", DefaultValue="false")]
public bool MatchSizeToCapture;
[IniProperty("WindowPlacementFlags", Description="Placement flags", DefaultValue="0")]
public WindowPlacementFlags WindowPlacementFlags;
[IniProperty("WindowShowCommand", Description="Show command", DefaultValue="Normal")]
public ShowWindowCommand ShowWindowCommand;
[IniProperty("WindowMinPosition", Description="Position of minimized window", DefaultValue="-1,-1")]
public Point WindowMinPosition;
[IniProperty("WindowMaxPosition", Description="Position of maximized window", DefaultValue="-1,-1")]
public Point WindowMaxPosition;
[IniProperty("WindowNormalPosition", Description="Position of normal window", DefaultValue="100,100,400,400")]
public Rectangle WindowNormalPosition;
/// <summary>
/// Supply values we can't put as defaults
/// </summary>
/// <param name="property">The property to return a default for</param>
/// <returns>object with the default value for the supplied property</returns>
public override object GetDefault(string property) {
switch(property) {
case "RecentColors":
return new List<Color>();
}
return null;
}
/// <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>
/// <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) {
string requestingTypeName = requestingType.Name;
string requestedField = requestingTypeName + "." + fieldType.Name;
object fieldValue = preferredDefaultValue;
// Check if the configuration exists
if (LastUsedFieldValues == null) {
LastUsedFieldValues = new Dictionary<string, object>();
}
// Check if settings for the requesting type exist, if not create!
if (LastUsedFieldValues.ContainsKey(requestedField)) {
// Check if a value is set (not null)!
if (LastUsedFieldValues[requestedField] != null) {
fieldValue = LastUsedFieldValues[requestedField];
} else {
// Overwrite null value
LastUsedFieldValues[requestedField] = fieldValue;
}
} else {
LastUsedFieldValues.Add(requestedField, fieldValue);
}
Field returnField = new Field(fieldType, requestingType);
returnField.Value = fieldValue;
return returnField;
}
public void UpdateLastFieldValue(Field field) {
string requestedField = field.Scope + "." + field.FieldType.Name;
// Check if the configuration exists
if (LastUsedFieldValues == null) {
LastUsedFieldValues = new Dictionary<string, object>();
}
// check if settings for the requesting type exist, if not create!
if (LastUsedFieldValues.ContainsKey(requestedField)) {
LastUsedFieldValues[requestedField] = field.myValue;
} else {
LastUsedFieldValues.Add(requestedField, field.myValue);
}
}
public WindowPlacement GetEditorPlacement() {
WindowPlacement placement = WindowPlacement.Default;
placement.NormalPosition = new RECT(WindowNormalPosition);
placement.MaxPosition = new POINT(WindowMaxPosition);
placement.MinPosition = new POINT(WindowMinPosition);
placement.ShowCmd = ShowWindowCommand;
placement.Flags = WindowPlacementFlags;
return placement;
}
public void SetEditorPlacement(WindowPlacement placement) {
WindowNormalPosition = placement.NormalPosition.ToRectangle();
WindowMaxPosition = placement.MaxPosition.ToPoint();
WindowMinPosition = placement.MinPosition.ToPoint();
ShowWindowCommand = placement.ShowCmd;
WindowPlacementFlags = placement.Flags;
}
}
}

View file

@ -0,0 +1,55 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
using GreenshotPlugin.Core;
namespace Greenshot.Configuration {
/// <summary>
/// Wrapper for the language container for the Greenshot base.
/// </summary>
public class Language : LanguageContainer, ILanguage {
private static ILanguage uniqueInstance;
private const string LANGUAGE_FILENAME_PATTERN = @"language-*.xml";
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
public static ILanguage GetInstance() {
if(uniqueInstance == null) {
uniqueInstance = new LanguageContainer();
uniqueInstance.LanguageFilePattern = LANGUAGE_FILENAME_PATTERN;
uniqueInstance.Load();
if (string.IsNullOrEmpty(conf.Language)) {
uniqueInstance.SynchronizeLanguageToCulture();
} else {
uniqueInstance.SetLanguage(conf.Language);
}
}
return uniqueInstance;
}
}
}

View file

@ -0,0 +1,201 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace Greenshot.Configuration {
public enum LangKey {
about_bugs,
about_donations,
about_host,
about_icons,
about_license,
about_title,
about_translation,
application_title,
bugreport_cancel,
bugreport_info,
bugreport_title,
clipboard_error,
clipboard_inuse,
colorpicker_alpha,
colorpicker_apply,
colorpicker_blue,
colorpicker_green,
colorpicker_htmlcolor,
colorpicker_recentcolors,
colorpicker_red,
colorpicker_title,
colorpicker_transparent,
config_unauthorizedaccess_write,
contextmenu_about,
contextmenu_capturearea,
contextmenu_captureclipboard,
contextmenu_capturefullscreen,
contextmenu_capturelastregion,
contextmenu_capturewindow,
contextmenu_donate,
contextmenu_exit,
contextmenu_help,
contextmenu_openfile,
contextmenu_quicksettings,
contextmenu_settings,
contextmenu_captureie,
contextmenu_openrecentcapture,
editor_arrange,
editor_arrowheads,
editor_arrowheads_both,
editor_arrowheads_end,
editor_arrowheads_none,
editor_arrowheads_start,
editor_backcolor,
editor_blur_radius,
editor_bold,
editor_brightness,
editor_cancel,
editor_clipboardfailed,
editor_close,
editor_close_on_save,
editor_close_on_save_title,
editor_confirm,
editor_copyimagetoclipboard,
editor_copypathtoclipboard,
editor_copytoclipboard,
editor_crop,
editor_cursortool,
editor_cuttoclipboard,
editor_deleteelement,
editor_downonelevel,
editor_downtobottom,
editor_drawarrow,
editor_drawellipse,
editor_drawhighlighter,
editor_drawline,
editor_drawrectangle,
editor_drawtextbox,
editor_duplicate,
editor_edit,
editor_email,
editor_file,
editor_fontsize,
editor_forecolor,
editor_highlight_area,
editor_highlight_grayscale,
editor_highlight_mode,
editor_highlight_text,
editor_highlight_magnify,
editor_pixel_size,
editor_imagesaved,
editor_italic,
editor_load_objects,
editor_magnification_factor,
editor_obfuscate,
editor_obfuscate_blur,
editor_obfuscate_mode,
editor_obfuscate_pixelize,
editor_object,
editor_opendirinexplorer,
editor_pastefromclipboard,
editor_preview_quality,
editor_print,
editor_save,
editor_save_objects,
editor_saveas,
editor_selectall,
editor_senttoprinter,
editor_shadow,
editor_storedtoclipboard,
editor_thickness,
editor_title,
editor_uponelevel,
editor_uptotop,
error,
error_multipleinstances,
error_nowriteaccess,
error_openfile,
error_openlink,
error_save,
help_title,
jpegqualitydialog_choosejpegquality,
jpegqualitydialog_dontaskagain,
jpegqualitydialog_title,
print_error,
printoptions_allowcenter,
printoptions_allowenlarge,
printoptions_allowrotate,
printoptions_allowshrink,
printoptions_dontaskagain,
printoptions_timestamp,
printoptions_inverted,
printoptions_title,
quicksettings_destination_file,
settings_alwaysshowjpegqualitydialog,
settings_alwaysshowprintoptionsdialog,
settings_applicationsettings,
settings_autostartshortcut,
settings_capture,
settings_capture_mousepointer,
settings_capture_windows_interactive,
settings_copypathtoclipboard,
settings_destination,
settings_destination_clipboard,
settings_destination_editor,
settings_destination_email,
settings_destination_file,
settings_destination_fileas,
settings_destination_printer,
settings_filenamepattern,
settings_general,
settings_iecapture,
settings_jpegquality,
settings_jpegsettings,
settings_language,
settings_message_filenamepattern,
settings_output,
settings_playsound,
settings_plugins,
settings_preferredfilesettings,
settings_primaryimageformat,
settings_printer,
settings_printoptions,
settings_registerhotkeys,
settings_showflashlight,
settings_storagelocation,
settings_title,
settings_tooltip_filenamepattern,
settings_tooltip_language,
settings_tooltip_primaryimageformat,
settings_tooltip_registerhotkeys,
settings_tooltip_storagelocation,
settings_visualization,
settings_waittime,
settings_windowscapture,
settings_window_capture_mode,
settings_network,
settings_checkperiod,
settings_usedefaultproxy,
tooltip_firststart,
warning,
warning_hotkeys,
hotkeys,
wait_ie_capture,
update_found
}
}

View file

@ -0,0 +1,36 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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.Imaging;
using System.Drawing;
using System.Windows.Forms;
using System;
namespace Greenshot.Configuration {
/// <summary>
/// Greenshot's runtime configuration
/// abstract, all properties are public and static
/// </summary>
public abstract class RuntimeConfig {
public static string[] SupportedLanguages = {"en-US","de-DE","nl-NL"};
public static string BugTrackerUrl = "https://sourceforge.net/tracker/?func=postadd&group_id=191585&atid=937972&summary=%SUMMARY%&details=%DETAILS%";
public static Rectangle LastCapturedRegion = Rectangle.Empty;
}
}

View file

@ -0,0 +1,41 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace Greenshot.Controls {
/// <summary>
/// Description of BindableToolStripButton.
/// </summary>
public class BindableToolStripButton : ToolStripButton, INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
public BindableToolStripButton() :base() {
this.CheckedChanged += new EventHandler(BindableToolStripButton_CheckedChanged);
}
void BindableToolStripButton_CheckedChanged(object sender, EventArgs e) {
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Checked"));
}
}
}

View file

@ -0,0 +1,44 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace Greenshot.Controls {
/// <summary>
/// A simple ToolStripComboBox implementing INotifyPropertyChanged for data binding
/// </summary>
public class BindableToolStripComboBox : ToolStripComboBox, INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
public BindableToolStripComboBox() :base() {
this.SelectedIndexChanged += new EventHandler(BindableToolStripComboBox_SelectedIndexChanged);
}
void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) {
if(PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem"));
}
}
}
}

View file

@ -0,0 +1,68 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace Greenshot.Controls {
/// <summary>
/// A simple ToolStripDropDownButton implementing INotifyPropertyChanged for data binding.
/// Also, when a DropDownItem is selected, the DropDownButton adops its Tag and Image.
/// The selected tag can be accessed via SelectedTag property.
/// </summary>
public class BindableToolStripDropDownButton : ToolStripDropDownButton, INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
public BindableToolStripDropDownButton() {
}
public object SelectedTag {
get { if(Tag==null && DropDownItems.Count>0) Tag=DropDownItems[0].Tag; return Tag; }
set { AdoptFromTag(value); }
}
protected override void OnDropDownItemClicked(ToolStripItemClickedEventArgs e) {
ToolStripItem clickedItem = e.ClickedItem;
if(Tag == null || !Tag.Equals(clickedItem.Tag)) {
Tag = clickedItem.Tag;
Image = clickedItem.Image;
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SelectedTag"));
}
base.OnDropDownItemClicked(e);
}
private void AdoptFromTag(object tag) {
if(Tag == null || !Tag.Equals(tag)) {
Tag = tag;
foreach(ToolStripItem item in DropDownItems) {
if(item.Tag != null && item.Tag.Equals(tag)) {
Image = item.Image;
break;
}
}
Tag = tag;
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("SelectedTag"));
}
}
}
}

View file

@ -0,0 +1,80 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using GreenshotPlugin.Core;
namespace Greenshot.Controls {
/// <summary>
/// Description of ColorButton.
/// </summary>
public class ColorButton : Button {
public event PropertyChangedEventHandler PropertyChanged;
private Color selectedColor = Color.White;
public ColorButton() {
Click += new EventHandler(ColorButtonClick);
}
public Color SelectedColor {
get {return selectedColor;}
set {
selectedColor = value;
Brush brush;
if(value != Color.Transparent) {
brush = new SolidBrush(value);
} else {
brush = new HatchBrush(HatchStyle.Percent50, Color.White, Color.Gray);
}
if (Image != null) {
using (Graphics graphics = Graphics.FromImage(Image)) {
graphics.FillRectangle(brush, new Rectangle(4,17,16,3));
}
}
// cleanup GDI Object
brush.Dispose();
Invalidate();
}
}
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(this.Parent.Parent);
if (colorDialog.DialogResult != DialogResult.Cancel) {
if (!colorDialog.Color.Equals(SelectedColor)) {
SelectedColor = colorDialog.Color;
if(PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs("SelectedColor"));
}
}
}
}
}
}

View file

@ -0,0 +1,62 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
using System.Drawing;
namespace Greenshot.Controls {
/// <summary>
/// ToolStripComboBox containing installed font families,
/// implementing INotifyPropertyChanged for data binding
/// </summary>
public class FontFamilyComboBox : ToolStripComboBox, INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
public FontFamily FontFamily {
get { return (FontFamily)SelectedItem; }
set {
if(!SelectedItem.Equals(value)) {
SelectedItem = value;
}
}
}
public FontFamilyComboBox() : base()
{
ComboBox.DataSource = FontFamily.Families;
ComboBox.DisplayMember = "Name";
this.SelectedIndexChanged += new EventHandler(BindableToolStripComboBox_SelectedIndexChanged);
}
void BindableToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if(PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs("Text"));
PropertyChanged(this, new PropertyChangedEventArgs("FontFamily"));
PropertyChanged(this, new PropertyChangedEventArgs("SelectedIndex"));
PropertyChanged(this, new PropertyChangedEventArgs("SelectedItem"));
}
}
}
}

View file

@ -0,0 +1,34 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
/// <summary>
/// See: http://nickstips.wordpress.com/2010/03/03/c-panel-resets-scroll-position-after-focus-is-lost-and-regained/
/// </summary>
namespace GreenshotPlugin.Controls {
public class NonJumpingPanel : System.Windows.Forms.Panel {
protected override System.Drawing.Point ScrollToControl(System.Windows.Forms.Control activeControl) {
// Returning the current location prevents the panel from
// scrolling to the active control when the panel loses and regains focus
return this.DisplayRectangle.Location;
}
}
}

View file

@ -0,0 +1,79 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
namespace Greenshot.Controls {
public class ToolStripColorButton : ToolStripButton, INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
private Color selectedColor = Color.Transparent;
public ToolStripColorButton() {
Click+= new EventHandler(ColorButtonClick);
}
public Color SelectedColor {
get {return selectedColor;}
set {
selectedColor = value;
Brush brush;
if(value != Color.Transparent) {
brush = new SolidBrush(value);
} else {
brush = new HatchBrush(HatchStyle.Percent50, Color.White, Color.Gray);
}
if (Image != null) {
using (Graphics graphics = Graphics.FromImage(Image)) {
graphics.FillRectangle(brush, new Rectangle(0,13,16,3));
}
}
// cleanup GDI Object
brush.Dispose();
Invalidate();
}
}
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(this.Parent.Parent);
if (colorDialog.DialogResult != DialogResult.Cancel) {
if (!colorDialog.Color.Equals(SelectedColor)) {
SelectedColor = colorDialog.Color;
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs("SelectedColor"));
}
}
}
}
}
}

View file

@ -0,0 +1,81 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
using System.Windows.Forms;
using System.Windows.Forms.Design;
namespace Greenshot.Controls {
[ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)]
public class ToolStripNumericUpDown : ToolStripControlHost, INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public ToolStripNumericUpDown() : base(new NumericUpDown())
{
}
public NumericUpDown NumericUpDown
{
get {return Control as NumericUpDown;}
}
public decimal Value
{
get { return NumericUpDown.Value; }
set { NumericUpDown.Value = value;}
}
public decimal Minimum {
get { return NumericUpDown.Minimum; }
set { NumericUpDown.Minimum = value; }
}
public decimal Maximum {
get { return NumericUpDown.Maximum; }
set { NumericUpDown.Maximum = value; }
}
public decimal Increment {
get { return NumericUpDown.Increment; }
set { NumericUpDown.Increment = value; }
}
public int DecimalPlaces {
get { return NumericUpDown.DecimalPlaces; }
set { NumericUpDown.DecimalPlaces = value; }
}
protected override void OnSubscribeControlEvents(Control control) {
base.OnSubscribeControlEvents(control);
NumericUpDown.ValueChanged += _valueChanged;
}
protected override void OnUnsubscribeControlEvents(Control control) {
base.OnUnsubscribeControlEvents(control);
NumericUpDown.ValueChanged -= _valueChanged;
}
private void _valueChanged(object sender, EventArgs e) {
if(PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs("Value"));
}
}
}

View file

@ -0,0 +1,187 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of LineContainer.
/// </summary>
[Serializable()]
public class ArrowContainer : LineContainer {
public enum ArrowHeadCombination { NONE, START_POINT, END_POINT, BOTH };
private static readonly AdjustableArrowCap ARROW_CAP = new AdjustableArrowCap(4, 6);
public ArrowContainer(Surface parent) : base(parent) {
AddField(GetType(), FieldType.ARROWHEADS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
AddField(GetType(), FieldType.SHADOW, false);
AddField(GetType(), FieldType.ARROWHEADS, Greenshot.Drawing.ArrowContainer.ArrowHeadCombination.END_POINT);
}
public override void Draw(Graphics g, RenderMode rm) {
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
ArrowHeadCombination heads = (ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS);;
if ( shadow && lineThickness > 0 ) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while ( currentStep <= steps ) {
using (Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowCapPen.Width = lineThickness;
if ( heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.START_POINT ) shadowCapPen.CustomStartCap = ARROW_CAP;
if ( heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.END_POINT ) shadowCapPen.CustomEndCap = ARROW_CAP;
g.DrawLine(shadowCapPen,
this.Left + currentStep,
this.Top + currentStep,
this.Left + currentStep + this.Width,
this.Top + currentStep + this.Height);
currentStep++;
alpha = alpha - (basealpha / steps);
}
}
}
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
if ( pen.Width > 0 ) {
if ( heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.START_POINT ) pen.CustomStartCap = ARROW_CAP;
if ( heads == ArrowHeadCombination.BOTH || heads == ArrowHeadCombination.END_POINT ) pen.CustomEndCap = ARROW_CAP;
g.DrawLine(pen, this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);
}
}
}
public override Rectangle DrawingBounds {
get {
int lineThickness = 0;
if (HasField(FieldType.LINE_THICKNESS)) {
lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
}
int arrowCapWidth = 0;
int arrowCapHeight = 0;
if (HasField(FieldType.ARROWHEADS)) {
ArrowHeadCombination heads = (ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS);
if(heads.Equals(ArrowHeadCombination.START_POINT) || heads.Equals(ArrowHeadCombination.END_POINT) || heads.Equals(ArrowHeadCombination.BOTH)) {
arrowCapWidth = (int)ARROW_CAP.Width * lineThickness;
arrowCapHeight = (int)ARROW_CAP.Height * lineThickness;
}
}
int offset = Math.Max(lineThickness/2, Math.Max(arrowCapWidth, arrowCapHeight));
return new Rectangle(Bounds.Left-offset, Bounds.Top-offset, Bounds.Width+offset*2, Bounds.Height+offset*2);
}
}
public override bool ClickableAt(int x, int y) {
bool ret = false;
ret = base.ClickableAt(x, y);
if(!ret) {
// line has not been clicked, check arrow heads
ArrowHeadCombination heads = (ArrowHeadCombination)GetFieldValue(FieldType.ARROWHEADS);
if(!ArrowHeadCombination.NONE.Equals(heads)) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
double arrowCapHalfWidth = ARROW_CAP.Width * lineThickness / 2;
double arrowCapHeight = ARROW_CAP.Height * lineThickness;
// we have to check only if arrow heads are wider than tolerated area of LineContainer
if(arrowCapHalfWidth > MAX_CLICK_DISTANCE_TOLERANCE) {
double mouseToLineDist = DrawingHelper.CalculateLinePointDistance(Left, Top, Left+Width, Top+Height, x, y);
if(mouseToLineDist > -1) { // point next to line at all?
if(heads.Equals(ArrowHeadCombination.END_POINT) || heads.Equals(ArrowHeadCombination.BOTH)) {
// calculate a perpendicular line at arrow tip to hittest arrow head easily
int p1x = Left + Width + Height;
int p1y = Top + Height - Width;
int p2x = Left + Width - Height;
int p2y = Top + Height + Width;
double mouseToPerpDist = DrawingHelper.CalculateLinePointDistance(p1x,p1y,p2x,p2y, x, y);
if(
// point located within rectangular area of width/height of arrowhead?
mouseToLineDist <= arrowCapHalfWidth
&& mouseToPerpDist <= arrowCapHeight
// point located within arrowhead? (nearer to line than to perp * w/h-factor)
&& mouseToLineDist < mouseToPerpDist * arrowCapHalfWidth / arrowCapHeight) {
return true;
}
}
if(heads.Equals(ArrowHeadCombination.START_POINT) || heads.Equals(ArrowHeadCombination.BOTH)) {
// calculate a perpendicular line at arrow tip to hittest arrow head easily
int p1x = Left - Height;
int p1y = Top + Width;
int p2x = Left + Height;
int p2y = Top - Width;
double mouseToPerpDist = DrawingHelper.CalculateLinePointDistance(p1x,p1y,p2x,p2y, x, y);
if(
// point located within rectangular area of width/height of arrowhead?
mouseToLineDist <= arrowCapHalfWidth
&& mouseToPerpDist <= arrowCapHeight
// point located within arrowhead? (nearer to line than to perp * w/h-factor)
&& mouseToLineDist < mouseToPerpDist * arrowCapHalfWidth / arrowCapHeight) {
return true;
}
}
}
}
}
}
return ret;
/*int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
double distance = DrawingHelper.CalculateLinePointDistance(this.Left, this.Top, this.Left + this.Width, this.Top + this.Height, x, y);
if (distance < 0) {
return false;
}
return distance <= Math.Max(lineThickness / 2, 10);*/
}
}
}

View file

@ -0,0 +1,352 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
namespace Greenshot.Drawing {
/// <summary>
/// The BitmapBuffer is exactly what it says, it buffers a Bitmap.
/// And it is possible to Draw on the Bitmap with direct memory access for better performance
/// </summary>
[Serializable()]
public unsafe class BitmapBuffer : IDisposable {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(BitmapBuffer));
private bool clone;
private Bitmap bitmap;
public Bitmap Bitmap {
get {return bitmap;}
}
[NonSerialized]
private BitmapData bmData;
[NonSerialized]
private Rectangle rect;
[NonSerialized]
private byte* pointer;
[NonSerialized]
private int stride; /* bytes per pixel row */
[NonSerialized]
private int aIndex = -1;
[NonSerialized]
private int rIndex = -1;
[NonSerialized]
private int gIndex = -1;
[NonSerialized]
private int bIndex = -1;
[NonSerialized]
private int bytesPerPixel;
[NonSerialized]
private bool bitsLocked = false;
public Size Size {
get {return rect.Size;}
}
public int Length {
get {return rect.Width*rect.Height;}
}
public int Width {
get {return rect.Width;}
}
public int Height {
get {return rect.Height;}
}
/// <summary>
/// Create a BitmapBuffer from a Bitmap
/// </summary>
/// <param name="sourceBmp">Bitmap</param>
public BitmapBuffer(Bitmap bmp) : this(bmp, Rectangle.Empty) {
}
/// <summary>
/// Create a BitmapBuffer from a Bitmap a flag if we need a clone
/// </summary>
/// <param name="sourceBmp">Bitmap</param>
/// <param name="clone">bool specifying if the bitmap needs to be cloned</param>
public BitmapBuffer(Bitmap sourceBmp, bool clone) : this(sourceBmp, Rectangle.Empty, clone) {
}
/// <summary>
/// Create a BitmapBuffer from a Bitmap and a Rectangle specifying what part from the Bitmap to take.
/// </summary>
/// <param name="sourceBmp">Bitmap</param>
/// <param name="applyRect">Rectangle</param>
public BitmapBuffer(Bitmap sourceBmp, Rectangle applyRect) : this(sourceBmp, applyRect, true) {
}
/// <summary>
/// Create a BitmapBuffer from a Bitmap, a Rectangle specifying what part from the Bitmap to take and a flag if we need a clone
/// </summary>
/// <param name="sourceBmp">Bitmap</param>
/// <param name="applyRect">Rectangle</param>
/// <param name="clone">bool specifying if the bitmap needs to be cloned</param>
public BitmapBuffer(Bitmap sourceBmp, Rectangle applyRect, bool clone) {
this.clone = clone;
Rectangle sourceRect = new Rectangle(applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height);
Rectangle bitmapRect = new Rectangle(0,0, sourceBmp.Width, sourceBmp.Height);
if(sourceRect.Equals(Rectangle.Empty)) {
sourceRect = bitmapRect;
} else {
sourceRect.Intersect(bitmapRect);
}
// Does the rect have any pixels?
if (sourceRect.Height <= 0 || sourceRect.Width <= 0) {
return;
}
if (SupportsPixelFormat(sourceBmp)) {
if (clone) {
// Create copy with supported format
this.bitmap = sourceBmp.Clone(sourceRect, sourceBmp.PixelFormat);
} else {
this.bitmap = sourceBmp;
}
} else {
// We can only clone, as we don't support the pixel format!
if (!clone) {
throw new ArgumentException("Not supported pixel format: " + sourceBmp.PixelFormat);
}
// When sourceRect is the whole bitmap there is a GDI+ bug in Clone
// Clone will than return the same PixelFormat as the source
// a quick workaround is using new Bitmap which uses a default of Format32bppArgb
if (sourceRect.Equals(bitmapRect)) {
this.bitmap = new Bitmap(sourceBmp);
} else {
this.bitmap = sourceBmp.Clone(sourceRect, PixelFormat.Format32bppArgb);
}
}
// Set "this" rect to location 0,0
// as the Cloned Bitmap is only the part we want to work with
this.rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
}
/**
* Destructor
*/
~BitmapBuffer() {
Dispose(false);
}
/**
* The public accessible Dispose
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
*/
public void Dispose() {
Dispose(true);
GC.SuppressFinalize(this);
}
// The bulk of the clean-up code is implemented in Dispose(bool)
/**
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
protected virtual void Dispose(bool disposing) {
Unlock();
if (disposing) {
if (bitmap != null && clone) {
bitmap.Dispose();
}
}
bitmap = null;
bmData = null;
pointer = null;
}
/**
* This is called when deserializing the object
*/
public BitmapBuffer(SerializationInfo info, StreamingContext ctxt) {
this.bitmap = (Bitmap)info.GetValue("bitmap", typeof(Bitmap));
this.rect = new Rectangle(0, 0, bitmap.Width, bitmap.Height);
// The rest will be set when Lock is called
}
/**
* This is called when serializing the object
*/
public void GetObjectData(SerializationInfo info, StreamingContext ctxt) {
Unlock();
info.AddValue("bitmap", this.bitmap);
}
/**
* Lock the bitmap so we have direct access to the memory
*/
public void Lock() {
if(rect.Width > 0 && rect.Height > 0) {
bmData = bitmap.LockBits(rect, ImageLockMode.ReadWrite, bitmap.PixelFormat);
bitsLocked = true;
System.IntPtr Scan0 = bmData.Scan0;
pointer = (byte*)(void*)Scan0;
PrepareForPixelFormat();
stride = bmData.Stride;
}
}
/**
* Unlock the System Memory
*/
private void Unlock() {
if(bitsLocked) {
bitmap.UnlockBits(bmData);
bitsLocked = false;
}
}
/**
* Draw the stored bitmap to the destionation bitmap at the supplied point
*/
public void DrawTo(Graphics graphics, Point destination) {
DrawTo(graphics, null, destination);
}
/**
* Draw the stored Bitmap on the Destination bitmap with the specified rectangle
* Be aware that the stored bitmap will be resized to the specified rectangle!!
*/
public void DrawTo(Graphics graphics, Rectangle destinationRect) {
DrawTo(graphics, destinationRect, null);
}
/**
* private helper to draw the bitmap
*/
private void DrawTo(Graphics graphics, Rectangle? destinationRect, Point? destination) {
if (destinationRect.HasValue) {
// Does the rect have any pixels?
if (destinationRect.Value.Height <= 0 || destinationRect.Value.Width <= 0) {
return;
}
}
// Make sure this.bitmap is unlocked
Unlock();
if (destinationRect.HasValue) {
graphics.DrawImage(this.bitmap, destinationRect.Value);
} else if (destination.HasValue) {
graphics.DrawImage(this.bitmap, destination.Value);
}
}
/**
* Retrieve the color at location x,y
* Before the first time this is called the Lock() should be called once!
*/
public Color GetColorAt(int x, int y) {
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
int offset = x*bytesPerPixel+y*stride;
int a = (aIndex==-1) ? 255 : (int)pointer[aIndex+offset];
return Color.FromArgb(a, pointer[rIndex+offset], pointer[gIndex+offset], pointer[bIndex+offset]);
} else {
return Color.Empty;
}
}
/**
* Set the color at location x,y
* Before the first time this is called the Lock() should be called once!
*/
public void SetColorAt(int x, int y, Color color) {
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
int offset = x*bytesPerPixel+y*stride;
if(aIndex!=-1) pointer[aIndex+offset] = color.A;
pointer[rIndex+offset] = color.R;
pointer[gIndex+offset] = color.G;
pointer[bIndex+offset] = color.B;
}
}
/**
* Retrieve the color at location x,y as an array
* Before the first time this is called the Lock() should be called once!
*/
public int[] GetColorArrayAt(int x, int y) {
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
int offset = x*bytesPerPixel+y*stride;
int a = (aIndex==-1) ? 255 : (int)pointer[aIndex+offset];
return new int[]{a, pointer[rIndex+offset], pointer[gIndex+offset], pointer[bIndex+offset]};
} else {
return new int[]{0,0,0,0};
}
}
/**
* Set the color at location x,y as an array
* Before the first time this is called the Lock() should be called once!
*/
public void SetColorArrayAt(int x, int y, int[] colors) {
if(x>=0 && y>=0 && x<rect.Width && y<rect.Height) {
int offset = x*bytesPerPixel+y*stride;
if(aIndex!=-1) pointer[aIndex+offset] = (byte)colors[0];
pointer[rIndex+offset] = (byte)colors[1];
pointer[gIndex+offset] = (byte)colors[2];
pointer[bIndex+offset] = (byte)colors[3];
}
}
/**
* Checks if the supplied Bitmap has a PixelFormat we support
*/
private bool SupportsPixelFormat(Bitmap bitmap) {
return (bitmap.PixelFormat.Equals(PixelFormat.Format32bppArgb) ||
bitmap.PixelFormat.Equals(PixelFormat.Format32bppRgb) ||
bitmap.PixelFormat.Equals(PixelFormat.Format24bppRgb));
}
/**
* Set some internal values for accessing the bitmap according to the PixelFormat
*/
private void PrepareForPixelFormat() {
// aIndex is only set if the pixel format supports "A".
aIndex = -1;
switch(bitmap.PixelFormat) {
case PixelFormat.Format32bppArgb:
bIndex = 0;
gIndex = 1;
rIndex = 2;
aIndex = 3;
bytesPerPixel = 4;
break;
case PixelFormat.Format32bppRgb:
bIndex = 0;
gIndex = 1;
rIndex = 2;
bytesPerPixel = 4;
break;
case PixelFormat.Format24bppRgb:
bIndex = 0;
gIndex = 1;
rIndex = 2;
bytesPerPixel = 3;
break;
default:
throw new FormatException("Bitmap.Pixelformat."+bitmap.PixelFormat+" is currently not supported. Supported: Format32bpp(A)Rgb, Format24bppRgb");
}
}
}
}

View file

@ -0,0 +1,109 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of BitmapContainer.
/// </summary>
[Serializable()]
public class BitmapContainer : DrawableContainer, IBitmapContainer {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(BitmapContainer));
protected Bitmap bitmap;
public BitmapContainer(Surface parent, string filename) : this(parent) {
Load(filename);
}
public BitmapContainer(Surface parent) : base(parent) {
}
public Bitmap Bitmap {
set {
if (bitmap != null) {
bitmap.Dispose();
}
bitmap = (Bitmap)value.Clone();
Width = value.Width;
Height = value.Height;
}
get { return bitmap; }
}
/**
* Destructor
*/
~BitmapContainer() {
Dispose(false);
}
/**
* The public accessible Dispose
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
*/
public new void Dispose() {
Dispose(true);
base.Dispose();
GC.SuppressFinalize(this);
}
// The bulk of the clean-up code is implemented in Dispose(bool)
/**
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (bitmap != null) {
bitmap.Dispose();
}
}
bitmap = null;
}
public void Load(string filename) {
if (File.Exists(filename)) {
using (Bitmap fileBitmap = new Bitmap(filename)) {
Bitmap = fileBitmap;
LOG.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
}
}
}
public override void Draw(Graphics g, RenderMode rm) {
if (bitmap != null) {
g.DrawImage(bitmap, Bounds);
}
}
}
}

View file

@ -0,0 +1,61 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of CropContainer.
/// </summary>
public class CropContainer : DrawableContainer {
public CropContainer(Surface parent) : base(parent) {
AddField(GetType(), FieldType.FLAGS, FieldType.Flag.CONFIRMABLE);
}
public override void Invalidate() {
parent.Invalidate();
}
public override void Draw(Graphics g, RenderMode rm) {
using (Brush cropBrush = new SolidBrush(Color.FromArgb(100, 150, 150, 100))) {
Rectangle r = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
Rectangle selectionRect = new Rectangle(r.Left - 1, r.Top - 1, r.Width + 1, r.Height + 1);
DrawSelectionBorder(g, selectionRect);
// top
g.FillRectangle(cropBrush, new Rectangle(0, 0, parent.Width, r.Top));
// left
g.FillRectangle(cropBrush, new Rectangle(0, r.Top, r.Left, r.Height));
// right
g.FillRectangle(cropBrush, new Rectangle(r.Left + r.Width, r.Top, parent.Width - (r.Left + r.Width), r.Height));
// bottom
g.FillRectangle(cropBrush, new Rectangle(0, r.Top + r.Height, parent.Width, parent.Height - (r.Top + r.Height)));
}
}
}
}

View file

@ -0,0 +1,110 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.IO;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of CursorContainer.
/// </summary>
[Serializable()]
public class CursorContainer : DrawableContainer, ICursorContainer {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(CursorContainer));
protected Cursor cursor;
public CursorContainer(Surface parent) : base(parent) {
}
public CursorContainer(Surface parent, string filename) : base(parent) {
Load(filename);
}
public Cursor Cursor {
set {
if (cursor != null) {
cursor.Dispose();
}
// Clone cursor (is this correct??)
cursor = new Cursor(value.CopyHandle());
Width = value.Size.Width;
Height = value.Size.Height;
}
get { return cursor; }
}
/**
* Destructor
*/
~CursorContainer() {
Dispose(false);
}
/**
* The public accessible Dispose
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
*/
public new void Dispose() {
Dispose(true);
base.Dispose();
GC.SuppressFinalize(this);
}
// The bulk of the clean-up code is implemented in Dispose(bool)
/**
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (cursor != null) {
cursor.Dispose();
}
}
cursor = null;
}
public void Load(string filename) {
if (File.Exists(filename)) {
using (Cursor fileCursor = new Cursor(filename)) {
Cursor = fileCursor;
LOG.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
}
}
}
public override void Draw(Graphics graphics, RenderMode rm) {
if (cursor != null) {
cursor.DrawStretched(graphics, Bounds);
}
}
}
}

View file

@ -0,0 +1,435 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Controls;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
using Greenshot.Helpers;
using Greenshot.Plugin;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// represents a rectangle, ellipse, label or whatever. Can contain filters, too.
/// serializable for clipboard support
/// Subclasses should fulfill INotifyPropertyChanged contract, i.e. call
/// OnPropertyChanged whenever a public property has been changed.
/// </summary>
[Serializable()]
public abstract class DrawableContainer : AbstractFieldHolderWithChildren, INotifyPropertyChanged, IDrawableContainer {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DrawableContainer));
[NonSerialized]
private PropertyChangedEventHandler propertyChanged;
public event PropertyChangedEventHandler PropertyChanged {
add { propertyChanged += value; }
remove{ propertyChanged -= value; }
}
// public List<IFilter> filters = new List<IFilter>();
public List<IFilter> Filters {
get {
List<IFilter> ret = new List<IFilter>();
foreach(IFieldHolder c in Children) {
if(c is IFilter) ret.Add(c as IFilter);
}
return ret;
}
}
[NonSerialized]
protected Surface parent;
public ISurface Parent {
get { return parent; }
set { SwitchParent((Surface)value); }
}
[NonSerialized]
protected Label[] grippers;
private bool layoutSuspended = false;
[NonSerialized]
private bool selected = false;
public bool Selected {
get {return selected;}
set {selected = value; OnPropertyChanged("Selected"); }
}
[NonSerialized]
public EditStatus Status = EditStatus.UNDRAWN;
private int left = 0;
public int Left {
get { return left; }
set { left = value; DoLayout();}
}
private int top = 0;
public int Top {
get { return top; }
set { top = value; DoLayout();}
}
private int width = 0;
public int Width {
get { return width; }
set { width = value; DoLayout();}
}
private int height = 0;
public int Height {
get { return height; }
set { height = value; DoLayout();}
}
public Rectangle Bounds {
get { return GuiRectangle.GetGuiRectangle(left, top, width, height); }
}
public DrawableContainer(Surface parent) {
this.parent = parent;
InitControls();
}
public void Add(IFilter filter) {
AddChild(filter);
}
public void Remove(IFilter filter) {
RemoveChild(filter);
}
private bool accountForShadowChange = false;
public virtual Rectangle DrawingBounds {
get {
foreach(IFilter filter in Filters) {
if (filter.Invert) {
return new Rectangle(Point.Empty, parent.Image.Size);
}
}
// Take a base safetymargin
int lineThickness = 5;
if (HasField(FieldType.LINE_THICKNESS)) {
lineThickness += GetFieldValueAsInt(FieldType.LINE_THICKNESS);
}
int offset = lineThickness/2;
int shadow = 0;
if (accountForShadowChange || (HasField(FieldType.SHADOW) && GetFieldValueAsBool(FieldType.SHADOW))){
accountForShadowChange = false;
shadow += 10;
}
return new Rectangle(Bounds.Left-offset, Bounds.Top-offset, Bounds.Width+lineThickness+shadow, Bounds.Height+lineThickness+shadow);
}
}
public virtual void Invalidate() {
parent.Invalidate(DrawingBounds);
}
public void AlignToParent(HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
if (horizontalAlignment == HorizontalAlignment.Left) {
Left = lineThickness/2;
}
if (horizontalAlignment == HorizontalAlignment.Right) {
Left = parent.Width - this.Width - lineThickness/2;
}
if (horizontalAlignment == HorizontalAlignment.Center) {
Left = (parent.Width / 2) - (this.Width / 2) - lineThickness/2;
}
if (verticalAlignment == VerticalAlignment.TOP) {
Top = lineThickness/2;
}
if (verticalAlignment == VerticalAlignment.BOTTOM) {
Top = parent.Height - this.Height - lineThickness/2;
}
if (verticalAlignment == VerticalAlignment.CENTER) {
Top = (parent.Height / 2) - (this.Height / 2) - lineThickness/2;
}
}
public virtual bool InitContent() { return true; }
public virtual void OnDoubleClick() {}
private void InitControls() {
InitGrippers();
DoLayout();
}
void InitGrippers() {
grippers = new Label[8];
for(int i=0; i<grippers.Length; i++) {
grippers[i] = new Label();
grippers[i].Name = "gripper" + i;
grippers[i].Width = 5;
grippers[i].Height = 5;
grippers[i].BackColor = Color.Black;
grippers[i].MouseDown += new MouseEventHandler(gripperMouseDown);
grippers[i].MouseUp += new MouseEventHandler(gripperMouseUp);
grippers[i].MouseMove += new MouseEventHandler(gripperMouseMove);
grippers[i].Visible = false;
grippers[i].Parent = parent;
}
grippers[1].Cursor = Cursors.SizeNS;
grippers[3].Cursor = Cursors.SizeWE;
grippers[5].Cursor = Cursors.SizeNS;
grippers[7].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();
}
private void DoLayout() {
if (!layoutSuspended) {
int[] xChoords = new int[]{this.Left-2,this.Left+this.Width/2-2,this.Left+this.Width-2};
int[] yChoords = new int[]{this.Top-2,this.Top+this.Height/2-2,this.Top+this.Height-2};
grippers[0].Left = xChoords[0]; grippers[0].Top = yChoords[0];
grippers[1].Left = xChoords[1]; grippers[1].Top = yChoords[0];
grippers[2].Left = xChoords[2]; grippers[2].Top = yChoords[0];
grippers[3].Left = xChoords[2]; grippers[3].Top = yChoords[1];
grippers[4].Left = xChoords[2]; grippers[4].Top = yChoords[2];
grippers[5].Left = xChoords[1]; grippers[5].Top = yChoords[2];
grippers[6].Left = xChoords[0]; grippers[6].Top = yChoords[2];
grippers[7].Left = xChoords[0]; grippers[7].Top = yChoords[1];
if((grippers[0].Left < grippers[4].Left && grippers[0].Top < grippers[4].Top) ||
grippers[0].Left > grippers[4].Left && grippers[0].Top > grippers[4].Top) {
grippers[0].Cursor = Cursors.SizeNWSE;
grippers[2].Cursor = Cursors.SizeNESW;
grippers[4].Cursor = Cursors.SizeNWSE;
grippers[6].Cursor = Cursors.SizeNESW;
} else if((grippers[0].Left > grippers[4].Left && grippers[0].Top < grippers[4].Top) ||
grippers[0].Left < grippers[4].Left && grippers[0].Top > grippers[4].Top) {
grippers[0].Cursor = Cursors.SizeNESW;
grippers[2].Cursor = Cursors.SizeNWSE;
grippers[4].Cursor = Cursors.SizeNESW;
grippers[6].Cursor = Cursors.SizeNWSE;
} else if (grippers[0].Left == grippers[4].Left) {
grippers[0].Cursor = Cursors.SizeNS;
grippers[4].Cursor = Cursors.SizeNS;
} else if (grippers[0].Top == grippers[4].Top) {
grippers[0].Cursor = Cursors.SizeWE;
grippers[4].Cursor = Cursors.SizeWE;
}
}
}
public virtual void Dispose() {
for(int i=0; i<grippers.Length; i++) {
grippers[i].Dispose();
}
FieldAggregator aggProps = parent.FieldAggregator;
aggProps.UnbindElement(this);
}
int mx;
int my;
private void gripperMouseDown(object sender, MouseEventArgs e) {
mx = e.X;
my = e.Y;
Status = EditStatus.RESIZING;
}
private void gripperMouseUp(object sender, MouseEventArgs e) {
Status = EditStatus.IDLE;
Invalidate();
}
private void gripperMouseMove(object sender, MouseEventArgs e) {
if(Status.Equals(EditStatus.RESIZING)) {
Invalidate();
SuspendLayout();
Label gr = (Label)sender;
int gripperIndex = Int16.Parse(gr.Name.Substring(7));
if(gripperIndex <= 2) { // top row
this.Top += e.Y - my;
this.Height -= e.Y - my;
} else if(gripperIndex >= 4 && gripperIndex <= 6) { // bottom row
this.Height += e.Y - my;
}
if(gripperIndex >=2 && gripperIndex <= 4) { // right row
this.Width += e.X - mx;
} else if(gripperIndex >=6 || gripperIndex == 0) { // left row
this.Left += e.X - mx;
this.Width -= e.X - mx;
}
ResumeLayout();
Invalidate();
}
}
private void childLabelMouseMove(object sender, MouseEventArgs e) {
if (Status.Equals(EditStatus.RESIZING)) {
Invalidate();
SuspendLayout();
this.Left += e.X - mx;
this.Top += e.Y - my;
ResumeLayout();
Invalidate();
}
}
public bool hasFilters {
get {
return Filters.Count > 0;
}
}
public abstract void Draw(Graphics graphics, RenderMode renderMode);
public virtual void DrawContent(Graphics graphics, Bitmap bmp, RenderMode renderMode, Rectangle clipRectangle) {
if(Children.Count > 0) {
if(Status != EditStatus.IDLE) {
DrawSelectionBorder(graphics, Bounds);
} else {
if(clipRectangle.Width != 0 && clipRectangle.Height != 0) {
foreach(IFilter filter in Filters) {
if (filter.Invert) {
filter.Apply(graphics, bmp, Bounds, renderMode);
} else {
Rectangle drawingRect = new Rectangle(Bounds.Location, Bounds.Size);
drawingRect.Intersect(clipRectangle);
filter.Apply(graphics, bmp, drawingRect, renderMode);
}
}
}
}
}
Draw(graphics, renderMode);
}
public virtual bool Contains(int x, int y) {
return Bounds.Contains(x , y);
}
public virtual bool ClickableAt(int x, int y) {
Rectangle r = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
r.Inflate(5, 5);
return r.Contains(x, y);
}
protected void DrawSelectionBorder(Graphics g, Rectangle rect) {
using (Pen pen = new Pen(Color.MediumSeaGreen)) {
pen.DashPattern = new float[]{1,2};
pen.Width = 1;
g.DrawRectangle(pen, rect);
}
}
public void ShowGrippers() {
for(int i=0; i<grippers.Length; i++) {
if(grippers[i].Enabled) grippers[i].Show();
else grippers[i].Hide();
}
this.ResumeLayout();
}
public void HideGrippers() {
this.SuspendLayout();
for(int i=0; i<grippers.Length; i++) {
grippers[i].Hide();
}
}
public void MoveBy(int dx, int dy) {
this.SuspendLayout();
this.Left += dx;
this.Top += dy;
this.ResumeLayout();
}
private void SwitchParent(Surface newParent) {
if(parent != null) {
for(int i=0; i<grippers.Length; i++) {
parent.Controls.Remove(grippers[i]);
}
} else if(grippers == null) {
InitControls();
}
parent = newParent;
parent.Controls.AddRange(grippers);
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().Equals(obj.GetType())) {
DrawableContainer other = obj as DrawableContainer;
if(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));
Invalidate();
}
}
/// <summary>
/// Handle the field changed event, this should invalidate the correct bounds (e.g. when shadow comes or goes more pixels!)
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void HandleFieldChanged(object sender, FieldChangedEventArgs e) {
LOG.DebugFormat("Field {0} changed", e.Field.FieldType);
if (e.Field.FieldType == FieldType.SHADOW) {
accountForShadowChange = true;
}
Invalidate();
}
}
}

View file

@ -0,0 +1,344 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Drawing.Fields;
using Greenshot.Plugin;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Dispatches most of a DrawableContainer's public properties and methods to a list of DrawableContainers.
/// </summary>
[Serializable()]
public class DrawableContainerList : List<DrawableContainer> {
public DrawableContainerList() {
}
public EditStatus Status {
get {
return this[Count-1].Status;
}
set {
foreach(DrawableContainer dc in this) dc.Status = value;
}
}
/// <summary>
/// Gets or sets the selection status of the elements.
/// If several elements are in the list, true is only returned when all elements are selected.
/// </summary>
public bool Selected {
get {
bool ret = true;
foreach(DrawableContainer dc in this) {
ret &= dc.Selected;
}
return ret;
}
set {
foreach(DrawableContainer dc in this) {
dc.Selected = value;
}
}
}
/// <summary>
/// Gets or sets the parent control of the elements in the list.
/// If there are several elements, the parent control of the last added is returned.
/// </summary>
public ISurface Parent {
get {
if(Count > 0) {
return this[Count-1].Parent;
}
return null;
}
set {
foreach(DrawableContainer dc in this) {
dc.Parent = value;
}
}
}
/// <summary>
/// Moves all elements in the list by the given amount of pixels.
/// </summary>
/// <param name="dx">pixels to move horizontally</param>
/// <param name="dy">pixels to move vertically</param>
public void MoveBy(int dx, int dy) {
// Track modifications
bool modified = false;
// Invalidate before moving (otherwise the old locations aren't refreshed
this.Invalidate();
foreach(DrawableContainer dc in this) {
dc.Left += dx;
dc.Top += dy;
modified = true;
}
// Invalidate after
this.Invalidate();
// If we moved something, tell the surface it's modified!
if (modified) {
Parent.Modified = true;
}
}
/// <summary>
/// Hides the grippers of all elements in the list.
/// </summary>
public void HideGrippers() {
foreach(DrawableContainer dc in this) {
dc.HideGrippers();
dc.Invalidate();
}
}
/// <summary>
/// Shows the grippers of all elements in the list.
/// </summary>
public void ShowGrippers() {
foreach(DrawableContainer dc in this) {
dc.ShowGrippers();
dc.Invalidate();
}
}
/// <summary>
/// Indicates whether on of the elements is clickable at the given location
/// </summary>
/// <param name="x">x coordinate to be checked</param>
/// <param name="y">y coordinate to be checked</param>
/// <returns>true if one of the elements in the list is clickable at the given location, false otherwise</returns>
public bool ClickableAt(int x, int y) {
bool ret = false;
foreach(DrawableContainer dc in this) {
ret |= dc.ClickableAt(x, y);
}
return ret;
}
/// <summary>
/// retrieves the topmost element being clickable at the given location
/// </summary>
/// <param name="x">x coordinate to be checked</param>
/// <param name="y">y coordinate to be checked</param>
/// <returns>the topmost element from the list being clickable at the given location, null if there is no clickable element</returns>
public DrawableContainer ClickableElementAt(int x, int y) {
for(int i=Count-1; i>=0; i--) {
if(this[i].ClickableAt(x,y)) {
return this[i];
}
}
return null;
}
/// <summary>
/// Dispatches OnDoubleClick to all elements in the list.
/// </summary>
public void OnDoubleClick() {
foreach(DrawableContainer dc in this) {
dc.OnDoubleClick();
}
}
/// <summary>
/// Check if there are any intersecting filters, if so we need to redraw more
/// </summary>
/// <param name="clipRectangle"></param>
/// <returns>true if an filter intersects</returns>
public bool hasIntersectingFilters(Rectangle clipRectangle) {
foreach(DrawableContainer dc in this) {
if (dc.DrawingBounds.IntersectsWith(clipRectangle) && dc.hasFilters && dc.Status == EditStatus.IDLE) {
return true;
}
}
return false;
}
/// <summary>
/// Check if any of the drawableContainers are inside the rectangle
/// </summary>
/// <param name="clipRectangle"></param>
/// <returns></returns>
public bool IntersectsWith(Rectangle clipRectangle) {
foreach(DrawableContainer dc in this) {
if (dc.DrawingBounds.IntersectsWith(clipRectangle)) {
return true;
}
}
return false;
}
/// <summary>
/// Triggers all elements in the list ot be redrawn.
/// </summary>
/// <param name="g">the related Graphics object</param>
/// <param name="renderMode">the rendermode in which the element is to be drawn</param>
public void Draw(Graphics g, Bitmap bitmap, RenderMode renderMode, Rectangle clipRectangle) {
foreach(DrawableContainer dc in this) {
if (dc.DrawingBounds.IntersectsWith(clipRectangle)) {
dc.DrawContent(g, bitmap, renderMode, clipRectangle);
}
}
}
/// <summary>
/// Pass the field changed event to all elements in the list
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void HandleFieldChangedEvent(object sender, FieldChangedEventArgs e) {
foreach(DrawableContainer dc in this) {
dc.HandleFieldChanged(sender, e);
}
}
/// <summary>
/// Invalidate the bounds of all the DC's in this list
/// </summary>
public void Invalidate() {
foreach(DrawableContainer dc in this) {
dc.Invalidate();
}
}
/// <summary>
/// Indicates whether the given list of elements can be pulled up,
/// i.e. whether there is at least one unselected element higher in hierarchy
/// </summary>
/// <param name="elements">list of elements to pull up</param>
/// <returns>true if the elements could be pulled up</returns>
public bool CanPullUp(DrawableContainerList elements) {
if (elements.Count == 0 || elements.Count == this.Count) {
return false;
}
foreach(DrawableContainer element in elements) {
if (this.IndexOf(element) < this.Count - elements.Count) {
return true;
}
}
return false;
}
/// <summary>
/// Pulls one or several elements up one level in hierarchy (z-index).
/// </summary>
/// <param name="elements">list of elements to pull up</param>
public void PullElementsUp(DrawableContainerList elements) {
for(int i=this.Count-1; i>=0; i--) {
DrawableContainer dc = this[i];
if (elements.Contains(dc)) {
if (Count > (i+1) && !elements.Contains(this[i+1])) {
SwapElements(i,i+1);
}
}
}
}
/// <summary>
/// Pulls one or several elements up to the topmost level(s) in hierarchy (z-index).
/// </summary>
/// <param name="elements">of elements to pull to top</param>
public void PullElementsToTop(DrawableContainerList elements) {
DrawableContainer[] dcs = this.ToArray();
for(int i=0; i<dcs.Length; i++) {
DrawableContainer dc = dcs[i];
if (elements.Contains(dc)) {
this.Remove(dc);
this.Add(dc);
Parent.Modified = true;
}
}
}
/// <summary>
/// Indicates whether the given list of elements can be pushed down,
/// i.e. whether there is at least one unselected element lower in hierarchy
/// </summary>
/// <param name="elements">list of elements to push down</param>
/// <returns>true if the elements could be pushed down</returns>
public bool CanPushDown(DrawableContainerList elements) {
if (elements.Count == 0 || elements.Count == this.Count) {
return false;
}
foreach(DrawableContainer element in elements) {
if (this.IndexOf(element) >= elements.Count) {
return true;
}
}
return false;
}
/// <summary>
/// Pushes one or several elements down one level in hierarchy (z-index).
/// </summary>
/// <param name="elements">list of elements to push down</param>
public void PushElementsDown(DrawableContainerList elements) {
for(int i=0; i<Count; i++) {
DrawableContainer dc = this[i];
if(elements.Contains(dc)) {
if((i>0) && !elements.Contains(this[i-1])) {
SwapElements(i,i-1);
}
}
}
}
/// <summary>
/// Pushes one or several elements down to the bottommost level(s) in hierarchy (z-index).
/// </summary>
/// <param name="elements">of elements to push to bottom</param>
public void PushElementsToBottom(DrawableContainerList elements) {
DrawableContainer[] dcs = this.ToArray();
for(int i=dcs.Length-1; i>=0; i--) {
DrawableContainer dc = dcs[i];
if(elements.Contains(dc)) {
this.Remove(dc);
this.Insert(0, dc);
Parent.Modified = true;
}
}
}
/// <summary>
/// swaps two elements in hierarchy (z-index),
/// checks both indices to be in range
/// </summary>
/// <param name="index1">index of the 1st element</param>
/// <param name="index2">index of the 2nd element</param>
private void SwapElements(int index1, int index2) {
if(index1 >= 0 && index1 < Count && index2 >= 0 && index2 < Count && index1 != index2) {
DrawableContainer dc = this[index1];
this[index1] = this[index2];
this[index2] = dc;
Parent.Modified = true;
}
}
}
}

View file

@ -0,0 +1,91 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of EllipseContainer.
/// </summary>
[Serializable()]
public class EllipseContainer : DrawableContainer {
public EllipseContainer(Surface parent) : base(parent) {
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
AddField(GetType(), FieldType.SHADOW, false);
}
public override void Draw(Graphics graphics, RenderMode renderMode) {
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
// draw shadow before anything else
if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowPen.Width = lineVisible ? lineThickness : 1;
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + currentStep, Top + currentStep, Width, Height);
graphics.DrawEllipse(shadowPen, shadowRect);
currentStep++;
alpha = alpha - basealpha / steps;
}
}
}
//draw the original shape
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
using (Brush brush = new SolidBrush(fillColor)) {
graphics.FillEllipse(brush, rect);
}
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
if (pen.Width > 0) {
graphics.DrawEllipse(pen, rect);
}
}
}
public override bool Contains(int x, int y) {
double xDistanceFromCenter = x - (Left+Width/2);
double yDistanceFromCenter = y - (Top+Height/2);
// ellipse: x^2/a^2 + y^2/b^2 = 1
return Math.Pow(xDistanceFromCenter,2)/Math.Pow(Width/2,2) + Math.Pow(yDistanceFromCenter,2)/Math.Pow(Height/2,2) < 1;
}
}
}

View file

@ -0,0 +1,159 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Runtime.Serialization;
using Greenshot.Configuration;
using Greenshot.Helpers;
using GreenshotPlugin.Core;
namespace Greenshot.Drawing.Fields {
/// <summary>
/// Basic IFieldHolder implementation, providing access to a set of fields
/// </summary>
[Serializable()]
public abstract class AbstractFieldHolder : IFieldHolder {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(AbstractFieldHolder));
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
/// <summary>
/// called when a field's value has changed
/// </summary>
[NonSerialized]
private FieldChangedEventHandler fieldChanged;
public event FieldChangedEventHandler FieldChanged {
add { fieldChanged += value; }
remove{ fieldChanged -= value; }
}
// we keep to Coolections 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() {}
[OnDeserializedAttribute()]
private void OnDeserialized(StreamingContext context) {
fieldsByType = new Dictionary<FieldType, Field>();
// listen to changing properties
foreach(Field field in fields) {
field.PropertyChanged += delegate { if(fieldChanged != null) fieldChanged(this, new FieldChangedEventArgs(field)); };
fieldsByType[field.FieldType] = field;
}
}
public void AddField(Type requestingType, FieldType fieldType, object fieldValue) {
AddField(editorConfiguration.CreateField(requestingType, fieldType, fieldValue));
}
public virtual void AddField(Field field) {
if(fieldsByType != null && 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)); };
}
public List<Field> GetFields() {
return fields;
}
public Field GetField(FieldType fieldType) {
try {
return fieldsByType[fieldType];
} catch(KeyNotFoundException e) {
throw new ArgumentException("Field '"+fieldType+"' does not exist in " + GetType(), e);
}
}
public object GetFieldValue(FieldType fieldType) {
return GetField(fieldType).Value;
}
#region convenience methods to save us some casts outside
public string GetFieldValueAsString(FieldType fieldType) {
return (string)GetFieldValue(fieldType);
}
public int GetFieldValueAsInt(FieldType fieldType) {
return (int)GetFieldValue(fieldType);
}
public decimal GetFieldValueAsDecimal(FieldType fieldType) {
return (decimal)GetFieldValue(fieldType);
}
public double GetFieldValueAsDouble(FieldType fieldType) {
return (double)GetFieldValue(fieldType);
}
public float GetFieldValueAsFloat(FieldType fieldType) {
return (float)GetFieldValue(fieldType);
}
public bool GetFieldValueAsBool(FieldType fieldType) {
return (bool)GetFieldValue(fieldType);
}
public Color GetFieldValueAsColor(FieldType fieldType) {
return (Color)GetFieldValue(fieldType);
}
#endregion
public bool HasField(FieldType fieldType) {
return fieldsByType.ContainsKey(fieldType);
}
public bool HasFieldValue(FieldType 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);
}
}
protected void OnFieldChanged(object sender, FieldChangedEventArgs e){
if(fieldChanged != null) fieldChanged(sender, e);
}
}
}

View file

@ -0,0 +1,126 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Reflection;
using System.Runtime.Serialization;
using Greenshot.Helpers;
namespace Greenshot.Drawing.Fields {
/// <summary>
/// Basic IFieldHolderWithChildren implementation. Similar to IFieldHolder,
/// but has a List<IFieldHolder> of children.
/// Field values are passed to and from children as well.
/// </summary>
[Serializable()]
public abstract class AbstractFieldHolderWithChildren : AbstractFieldHolder {
FieldChangedEventHandler fieldChangedEventHandler;
[NonSerialized]
private EventHandler childrenChanged;
public event EventHandler ChildrenChanged {
add { childrenChanged += value; }
remove { childrenChanged -= value; }
}
public List<IFieldHolder> Children = new List<IFieldHolder>();
public AbstractFieldHolderWithChildren() {
fieldChangedEventHandler = new FieldChangedEventHandler(OnFieldChanged);
}
[OnDeserializedAttribute()]
private void OnDeserialized(StreamingContext context) {
// listen to changing properties
foreach(IFieldHolder fieldHolder in Children) {
fieldHolder.FieldChanged += fieldChangedEventHandler;
}
if(childrenChanged != null) childrenChanged(this, EventArgs.Empty);
}
public void AddChild(IFieldHolder fieldHolder) {
Children.Add(fieldHolder);
fieldHolder.FieldChanged += fieldChangedEventHandler;
if(childrenChanged != null) childrenChanged(this, EventArgs.Empty);
}
public void RemoveChild(IFieldHolder fieldHolder) {
Children.Remove(fieldHolder);
fieldHolder.FieldChanged -= fieldChangedEventHandler;
if(childrenChanged != null) childrenChanged(this, EventArgs.Empty);
}
public new List<Field> GetFields() {
List<Field> ret = new List<Field>();
ret.AddRange(base.GetFields());
foreach(IFieldHolder fh in Children) {
ret.AddRange(fh.GetFields());
}
return ret;
}
public new Field GetField(FieldType fieldType) {
Field ret = null;
if(base.HasField(fieldType)) {
ret = base.GetField(fieldType);
} else {
foreach(IFieldHolder fh in Children) {
if(fh.HasField(fieldType)) {
ret = fh.GetField(fieldType);
break;
}
}
}
if(ret == null) {
throw new ArgumentException("Field '"+fieldType+"' does not exist in " + GetType());
}
return ret;
}
public new bool HasField(FieldType fieldType) {
bool ret = base.HasField(fieldType);
if(!ret) {
foreach(IFieldHolder fh in Children) {
if(fh.HasField(fieldType)) {
ret = true;
break;
}
}
}
return ret;
}
public new bool HasFieldValue(FieldType fieldType) {
Field 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;
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Basic IBindingConverter implementation
/// </summary>
public abstract class AbstractBindingConverter<T1,T2> : IBindingConverter
{
public AbstractBindingConverter() {}
public object convert(object o) {
if(o == null) {
return null;
} else if(o is T1) {
return convert((T1)o);
} else if(o is T2) {
return convert((T2)o);
} else {
throw new ArgumentException("Cannot handle argument of type "+o.GetType());
}
}
protected abstract T2 convert(T1 o);
protected abstract T1 convert(T2 o);
}
}

View file

@ -0,0 +1,168 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
using System.Reflection;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Bidirectional binding of properties of two INotifyPropertyChanged instances.
/// This implementation synchronizes null values, too. If you do not want this
/// behavior (e.g. when binding to a
/// </summary>
public class BidirectionalBinding
{
private INotifyPropertyChanged object1;
private INotifyPropertyChanged object2;
private string property1;
private string property2;
private bool updatingObject1 = false;
private bool updatingObject2 = false;
private IBindingConverter converter;
private 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>
public BidirectionalBinding(INotifyPropertyChanged object1, string property1, INotifyPropertyChanged object2, string property2)
{
this.object1 = object1;
this.object2 = object2;
this.property1 = property1;
this.property2 = property2;
this.object1.PropertyChanged += new PropertyChangedEventHandler(Property1Changed);
this.object2.PropertyChanged += new PropertyChangedEventHandler(Property2Changed);
}
/// <summary>
/// Bind properties of two objects bidirectionally, converting the values using a converter
/// </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="converter">taking care of converting the synchronzied value to the correct target format and back</param>
public BidirectionalBinding(INotifyPropertyChanged object1, string property1, INotifyPropertyChanged object2, string property2, IBindingConverter converter) : this(object1, property1, object2, property2)
{
this.converter = converter;
}
/// <summary>
/// Bind properties of two objects bidirectionally, converting the values using a converter.
/// Synchronization can be intercepted by adding a validator.
/// </summary>
/// <param name="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="validator">validator to intercept synchronisation if the value does not match certain criteria</param>
public BidirectionalBinding(INotifyPropertyChanged object1, string property1, INotifyPropertyChanged object2, string property2, IBindingValidator validator) : this(object1, property1, object2, property2)
{
this.validator = validator;
}
/// <summary>
/// Bind properties of two objects bidirectionally, converting the values using a converter.
/// Synchronization can be intercepted by adding a validator.
/// </summary>
/// <param name="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="converter">taking care of converting the synchronzied value to the correct target format and back</param>
/// <param name="validator">validator to intercept synchronisation if the value does not match certain criteria</param>
public BidirectionalBinding(INotifyPropertyChanged object1, string property1, INotifyPropertyChanged object2, string property2, IBindingConverter converter, IBindingValidator validator) : this(object1, property1, object2, property2, converter)
{
this.validator = validator;
}
public void Property1Changed(object sender, PropertyChangedEventArgs e)
{
if(!updatingObject1 && e.PropertyName.Equals(property1))
{
updatingObject2 = true;
synchronize(object1, property1, object2, property2);
updatingObject2 = false;
}
}
public void Property2Changed(object sender, PropertyChangedEventArgs e)
{
if(!updatingObject2 && e.PropertyName.Equals(property2))
{
updatingObject1 = true;
synchronize(object2, property2, object1, property1);
updatingObject1 = false;
}
}
private void synchronize(INotifyPropertyChanged sourceObject, string sourceProperty, INotifyPropertyChanged targetObject, string targetProperty)
{
PropertyInfo targetPropertyInfo = resolvePropertyInfo(targetObject, targetProperty);
PropertyInfo sourcePropertyInfo = resolvePropertyInfo(sourceObject, sourceProperty);
if(sourcePropertyInfo != null && targetPropertyInfo != null && targetPropertyInfo.CanWrite)
{
object bValue = sourcePropertyInfo.GetValue(sourceObject, null);
if(converter != null && bValue != null) bValue = converter.convert(bValue);
try {
if(validator == null || validator.validate(bValue)) {
targetPropertyInfo.SetValue(targetObject, bValue, null);
}
} catch (Exception e) {
throw new MemberAccessException("Could not set property '"+targetProperty+"' to '"+bValue+"' ["+((bValue!=null)?bValue.GetType().Name:"")+"] on "+targetObject+". Probably other type than expected, IBindingCoverter to the rescue.", e);
}
}
}
private PropertyInfo resolvePropertyInfo(object obj, string property) {
PropertyInfo ret = null;
string[] properties = property.Split(".".ToCharArray());
for(int i=0; i<properties.Length; i++) {
string prop = properties[i];
ret = obj.GetType().GetProperty(prop);
if(ret != null && ret.CanRead && i<prop.Length-1) {
obj = ret.GetValue(obj, null);
}
}
return ret;
}
public IBindingConverter Converter {
get { return converter; }
set { converter = value; }
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Converts decimal to double (%) and vice versa, e.g. 95f <---> 0.95d
/// </summary>
public class DecimalDoublePercentageConverter : AbstractBindingConverter<double, decimal>
{
private static DecimalDoublePercentageConverter uniqueInstance;
private DecimalDoublePercentageConverter() {}
protected override decimal convert(double o) {
return Convert.ToDecimal(o)*100;
}
protected override double convert(decimal o) {
return Convert.ToDouble(o)/100;
}
public static DecimalDoublePercentageConverter GetInstance() {
if(uniqueInstance == null) uniqueInstance = new DecimalDoublePercentageConverter();
return uniqueInstance;
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Converts decimal to float and vice versa.
/// </summary>
public class DecimalFloatConverter : AbstractBindingConverter<float, decimal>
{
private static DecimalFloatConverter uniqueInstance;
private DecimalFloatConverter() {}
protected override decimal convert(float o) {
return Convert.ToDecimal(o);
}
protected override float convert(decimal o) {
return Convert.ToInt16(o);
}
public static DecimalFloatConverter GetInstance() {
if(uniqueInstance == null) uniqueInstance = new DecimalFloatConverter();
return uniqueInstance;
}
}
}

View file

@ -0,0 +1,47 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Converts decimal to int and vice versa.
/// </summary>
public class DecimalIntConverter : AbstractBindingConverter<int, decimal>
{
private static DecimalIntConverter uniqueInstance;
private DecimalIntConverter() {}
protected override decimal convert(int o) {
return Convert.ToDecimal(o);
}
protected override int convert(decimal o) {
return Convert.ToInt16(o);
}
public static DecimalIntConverter GetInstance() {
if(uniqueInstance == null) uniqueInstance = new DecimalIntConverter();
return uniqueInstance;
}
}
}

View file

@ -0,0 +1,34 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Interface for a bidirectional converter, for use with BidirectionalBinding.
/// convert(object) implementation must deal with both directions.
/// see DecimalIntConverter
/// </summary>
public interface IBindingConverter {
object convert(object o);
}
}

View file

@ -0,0 +1,35 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Interface for a bidirectional validator, for use with BidirectionalBinding.
/// Useful if you do not want to synchronize values which would be illegal on
/// one of the bound objects (e.g. null value on some form components)
/// see NotNullValidator
/// </summary>
public interface IBindingValidator {
bool validate(object o);
}
}

View file

@ -0,0 +1,42 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
namespace Greenshot.Drawing.Fields.Binding {
/// <summary>
/// Validates a value not to be null.
/// </summary>
public class NotNullValidator : IBindingValidator {
private static NotNullValidator uniqueInstance;
private NotNullValidator() {
}
public bool validate(object o) {
return o != null;
}
public static NotNullValidator GetInstance() {
if(uniqueInstance == null) uniqueInstance = new NotNullValidator();
return uniqueInstance;
}
}
}

View file

@ -0,0 +1,122 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.ComponentModel;
namespace Greenshot.Drawing.Fields {
/// <summary>
/// Represents a single field of a drawable element, i.e.
/// line thickness of a rectangle.
/// </summary>
[Serializable]
public class Field : INotifyPropertyChanged {
[field:NonSerialized]
public event PropertyChangedEventHandler PropertyChanged;
public object myValue;
public object Value {
get { return myValue; }
set { if(!object.Equals(myValue,value)) {
myValue = value;
if(PropertyChanged!=null) PropertyChanged(this, new PropertyChangedEventArgs("Value")); }
}
}
public FieldType FieldType;
public string Scope;
/// <summary>
/// Constructs a new Field instance, usually you should be using FieldFactory
/// to create Fields.
/// </summary>
/// <param name="fieldType">FieldType of the Field to be created</param>
/// <param name="scope">The scope to which the value of this Field is relevant.
/// Depending on the scope the Field's value may be shared for other elements
/// containing the same FieldType for defaulting to the last used value.
/// When scope is set to a Type (e.g. typeof(RectangleContainer)), its value
/// should not be reused for FieldHolders of another Type (e.g. typeof(EllipseContainer))
/// </param>
public Field(FieldType fieldType, Type scope) {
FieldType = fieldType;
Scope = scope.Name;
}
public Field(FieldType fieldType, string scope) {
FieldType = fieldType;
Scope = scope;
}
public Field(FieldType fieldType) {
FieldType = fieldType;
}
/// <summary>
/// Returns true if this field holds a value other than null.
/// </summary>
public bool HasValue {
get{ return 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 override int GetHashCode() {
int hashCode = 0;
unchecked {
hashCode += 1000000009 * FieldType.GetHashCode();
if (Scope != null)
hashCode += 1000000021 * Scope.GetHashCode();
}
return hashCode;
}
public override bool Equals(object obj) {
Field other = obj as Field;
if (other == null) {
return false;
}
return this.FieldType == other.FieldType && object.Equals(this.Scope, other.Scope);
}
public override string ToString() {
return string.Format("[Field FieldType={1} Value={0} Scope={2}]", this.myValue, this.FieldType, this.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) {
this.Field = field;
}
}
}

View file

@ -0,0 +1,173 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using Greenshot.Configuration;
using Greenshot.Drawing.Filters;
using Greenshot.Helpers;
using GreenshotPlugin.Core;
namespace Greenshot.Drawing.Fields {
/// <summary>
/// Represents the current set of properties for the editor.
/// When one of EditorProperties' properties is updated, the change will be promoted
/// to all bound elements.
/// * If an element is selected:
/// This class represents the element's properties
/// * I n>1 elements are selected:
/// This class represents the properties of all elements.
/// Properties that do not apply for ALL selected elements are null (or 0 respectively)
/// If the property values of the selected elements differ, the value of the last bound element wins.
/// </summary>
public class FieldAggregator : AbstractFieldHolder {
private List<DrawableContainer> boundContainers;
private bool internalUpdateRunning = false;
enum Status {IDLE, BINDING, UPDATING};
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(FieldAggregator));
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
public FieldAggregator() {
foreach(FieldType fieldType in FieldType.Values) {
Field field = new Field(fieldType, GetType());
AddField(field);
}
boundContainers = new List<DrawableContainer>();
}
public override void AddField(Field field) {
base.AddField(field);
field.PropertyChanged += new PropertyChangedEventHandler(OwnPropertyChanged);
}
public void BindElements(DrawableContainerList dcs) {
foreach(DrawableContainer dc in dcs) {
BindElement(dc);
}
}
public void BindElement(DrawableContainer dc) {
if(!boundContainers.Contains(dc)) {
boundContainers.Add(dc);
dc.ChildrenChanged += delegate { UpdateFromBoundElements(); };
UpdateFromBoundElements();
}
}
public void BindAndUpdateElement(DrawableContainer dc) {
UpdateElement(dc);
BindElement(dc);
}
public void UpdateElement(DrawableContainer dc) {
internalUpdateRunning = true;
foreach(Field field in GetFields()) {
if(dc.HasField(field.FieldType) && field.HasValue) {
//if(LOG.IsDebugEnabled) LOG.Debug(" "+field+ ": "+field.Value);
dc.SetFieldValue(field.FieldType, field.Value);
}
}
internalUpdateRunning = false;
}
public void UnbindElement(DrawableContainer dc) {
if(boundContainers.Contains(dc)) {
boundContainers.Remove(dc);
UpdateFromBoundElements();
}
}
public void Clear() {
ClearFields();
boundContainers.Clear();
UpdateFromBoundElements();
}
/// <summary>
/// sets all field values to null, however does not remove fields
/// </summary>
private void ClearFields() {
internalUpdateRunning = true;
//if(LOG.IsDebugEnabled) LOG.Debug("Clearing fields internally");
foreach(Field field in GetFields()) {
field.Value = null;
}
internalUpdateRunning = false;
}
/// <summary>
/// Updates this instance using the respective fields from the bound elements.
/// Fields that do not apply to every bound element are set to null, or 0 respectively.
/// All other fields will be set to the field value of the least bound element.
/// </summary>
private void UpdateFromBoundElements() {
ClearFields();
internalUpdateRunning = true;
foreach(Field field in FindCommonFields()) {
SetFieldValue(field.FieldType, field.Value);
}
internalUpdateRunning = false;
}
private List<Field> FindCommonFields() {
List<Field> ret = null;
if(boundContainers.Count > 0) {
// take all fields from the least selected container...
ret = boundContainers[boundContainers.Count-1].GetFields();
for(int i=0;i<boundContainers.Count-1; i++) {
DrawableContainer dc = boundContainers[i];
List<Field> fieldsToRemove = new List<Field>();
foreach(Field f in ret) {
// ... throw out those that do not apply to one of the other containers
if(!dc.HasField(f.FieldType)) {
fieldsToRemove.Add(f);
}
}
foreach(Field f in fieldsToRemove) {
ret.Remove(f);
}
}
}
if(ret == null) ret = new List<Field>();
return ret;
}
public void OwnPropertyChanged(object sender, PropertyChangedEventArgs ea) {
Field field = (Field) sender;
if(!internalUpdateRunning && field.Value!=null) {
foreach(DrawableContainer dc in boundContainers) {
if(dc.HasField(field.FieldType)) {
Field dcf = dc.GetField(field.FieldType);
dcf.Value = field.Value;
// update last used from DC field, so that scope is honored
editorConfiguration.UpdateLastFieldValue(dcf);
}
}
}
}
}
}

View file

@ -0,0 +1,115 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
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 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 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[]{
ARROWHEADS,
BLUR_RADIUS,
BRIGHTNESS,
FILL_COLOR,
FONT_BOLD,
FONT_FAMILY,
FONT_ITALIC,
FONT_SIZE,
HIGHLIGHT_COLOR,
LINE_COLOR,
LINE_THICKNESS,
MAGNIFICATION_FACTOR,
PIXEL_SIZE,
PREVIEW_QUALITY,
SHADOW,
PREPARED_FILTER_OBFUSCATE,
PREPARED_FILTER_HIGHLIGHT,
FLAGS
};
[Flags]
public enum Flag {
NONE = 0,
CONFIRMABLE = 1
}
public string Name;
private FieldType(string name) {
Name = name;
}
public override string ToString() {
return this.Name;
}
public override int GetHashCode()
{
int hashCode = 0;
unchecked {
if (Name != null)
hashCode += 1000000009 * Name.GetHashCode();
}
return hashCode;
}
public override bool Equals(object obj)
{
FieldType other = obj as FieldType;
if (other == null)
return false;
return object.Equals(this.Name,other.Name);
}
public static bool operator ==(FieldType a, FieldType b) {
return object.Equals(a,b);
}
public static bool operator !=(FieldType a, FieldType b) {
return !object.Equals(a,b);
}
}
}

View file

@ -0,0 +1,53 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
namespace Greenshot.Drawing.Fields {
/// <summary>
/// Any element holding Fields must provide access to it.
/// AbstractFieldHolder is the basic implementation.
/// If you need the fieldHolder to have child fieldHolders,
/// you should consider using IFieldHolderWithChildren.
/// </summary>
public interface IFieldHolder {
event FieldChangedEventHandler FieldChanged;
void AddField(Field field);
void RemoveField(Field field);
List<Field> GetFields();
Field GetField(FieldType fieldType);
bool HasField(FieldType fieldType);
void SetFieldValue(FieldType fieldType, object value);
}
/// <summary>
/// Extended fieldHolder which has fieldHolder children.
/// Implementations should pass field values to and from
/// their children.
/// AbstractFieldHolderWithChildren is the basic implementation.
/// </summary>
public interface IFieldHolderWithChildren : IFieldHolder {
void AddChild(IFieldHolder fieldHolder);
void RemoveChild(IFieldHolder fieldHolder);
}
}

View file

@ -0,0 +1,90 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// empty container for filter-only elements
/// </summary>
[Serializable()]
public abstract class FilterContainer : DrawableContainer {
public enum PreparedFilterMode {OBFUSCATE, HIGHLIGHT};
public enum PreparedFilter {BLUR, PIXELIZE, TEXT_HIGHTLIGHT, AREA_HIGHLIGHT, GRAYSCALE, MAGNIFICATION};
public PreparedFilter Filter {
get { return (PreparedFilter)GetFieldValue(FieldType.PREPARED_FILTER_HIGHLIGHT); }
}
public FilterContainer(Surface parent) : base(parent) {
AddField(GetType(), FieldType.LINE_THICKNESS, 0);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.SHADOW, false);
}
public override void Draw(Graphics g, RenderMode rm) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
if (shadow && lineVisible) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowPen.Width = lineVisible ? lineThickness : 1;
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(
this.Left + currentStep,
this.Top + currentStep,
this.Width,
this.Height);
g.DrawRectangle(shadowPen, shadowRect);
currentStep++;
alpha = alpha - (basealpha / steps);
}
}
}
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
if(pen.Width > 0) {
g.DrawRectangle(pen, rect);
}
}
}
}
}

View file

@ -0,0 +1,117 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.Serialization;
using Greenshot.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()]
public abstract class AbstractFilter : AbstractFieldHolder, IFilter {
[NonSerialized]
private PropertyChangedEventHandler propertyChanged;
public event PropertyChangedEventHandler PropertyChanged {
add { propertyChanged += value; }
remove{ propertyChanged -= value; }
}
private bool invert = false;
public bool Invert {
get { return invert; }
set { invert=value; OnPropertyChanged("Invert"); }
}
protected BitmapBuffer bbb;
protected Rectangle applyRect;
protected DrawableContainer parent;
public DrawableContainer Parent {
get {return parent;}
set {parent = value;}
}
public AbstractFilter(DrawableContainer parent) {
this.parent = parent;
}
public DrawableContainer GetParent() {
return parent;
}
/**
* This method fixes the problem that we can't apply a filter outside the target bitmap,
* therefor the filtered-bitmap will be shifted if we try to draw it outside the target bitmap.
* It will also account for the Invert flag.
*/
protected Rectangle IntersectRectangle(Size applySize, Rectangle rect) {
Rectangle myRect;
if (Invert) {
myRect = new Rectangle(0, 0, applySize.Width, applySize.Height);
} else {
Rectangle applyRect = new Rectangle(0,0, applySize.Width, applySize.Height);
myRect = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
myRect.Intersect(applyRect);
}
return myRect;
}
public virtual void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
applyRect = IntersectRectangle(applyBitmap.Size, rect);
if (applyRect.Width == 0 || applyRect.Height == 0) {
// nothing to do
return;
}
bbb = new BitmapBuffer(applyBitmap, applyRect);
try {
bbb.Lock();
for(int y=0;y<bbb.Height; y++) {
for(int x=0;x<bbb.Width; x++) {
if(parent.Contains(applyRect.Left+x, applyRect.Top+y) ^ Invert) {
IteratePixel(x, y);
}
}
}
} finally {
bbb.DrawTo(graphics, applyRect.Location);
bbb.Dispose();
bbb = null;
}
}
protected virtual void IteratePixel(int x, int y) {}
protected void OnPropertyChanged(string propertyName) {
if(propertyChanged != null) propertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}

View file

@ -0,0 +1,241 @@
/// <summary>
/// Parts of this class were taken from BlurEffect.cs of Paint.NET 3.0.1,
/// which was released under MIT license.
/// http://www.getpaint.net
/// Some of this code has been adapted for integration with Greenshot.
/// See Paint.NET copyright notice below.
/// </summary>
/////////////////////////////////////////////////////////////////////////////////
// Paint.NET //
// Copyright (C) Rick Brewster, Tom Jackson, and past contributors. //
// Portions Copyright (C) Microsoft Corporation. All Rights Reserved. //
// See src/Resources/Files/License.txt for full licensing and attribution //
// details. //
// . //
/////////////////////////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class BlurFilter : AbstractFilter {
public double previewQuality;
public double PreviewQuality {
get { return previewQuality; }
set { previewQuality = value; OnPropertyChanged("PreviewQuality"); }
}
public BlurFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.BLUR_RADIUS, 3);
AddField(GetType(), FieldType.PREVIEW_QUALITY, 1.0d);
}
public static int[] CreateGaussianBlurRow(int amount) {
int size = 1 + (amount * 2);
int[] weights = new int[size];
for (int i = 0; i <= amount; ++i)
{
// 1 + aa - aa + 2ai - ii
weights[i] = 16 * (i + 1);
weights[weights.Length - i - 1] = weights[i];
}
return weights;
}
public unsafe override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
applyRect = IntersectRectangle(applyBitmap.Size, rect);
if (applyRect.Height <= 0 || applyRect.Width <= 0) {
return;
}
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
double previewQuality = GetFieldValueAsDouble(FieldType.PREVIEW_QUALITY);
// do nothing when nothing can be done!
if (blurRadius < 1) {
return;
}
using (BitmapBuffer bbbDest = new BitmapBuffer(applyBitmap, applyRect)) {
bbbDest.Lock();
using (BitmapBuffer bbbSrc = new BitmapBuffer(applyBitmap, applyRect)) {
bbbSrc.Lock();
Random rand = new Random();
int r = blurRadius;
int[] w = CreateGaussianBlurRow(r);
int wlen = w.Length;
for (int y = 0; y < applyRect.Height; ++y) {
long* waSums = stackalloc long[wlen];
long* wcSums = stackalloc long[wlen];
long* aSums = stackalloc long[wlen];
long* bSums = stackalloc long[wlen];
long* gSums = stackalloc long[wlen];
long* rSums = stackalloc long[wlen];
long waSum = 0;
long wcSum = 0;
long aSum = 0;
long bSum = 0;
long gSum = 0;
long rSum = 0;
for (int wx = 0; wx < wlen; ++wx) {
int srcX = wx - r;
waSums[wx] = 0;
wcSums[wx] = 0;
aSums[wx] = 0;
bSums[wx] = 0;
gSums[wx] = 0;
rSums[wx] = 0;
if (srcX >= 0 && srcX < bbbDest.Width) {
for (int wy = 0; wy < wlen; ++wy) {
int srcY = y + wy - r;
if (srcY >= 0 && srcY < bbbDest.Height) {
int[] colors = bbbSrc.GetColorArrayAt(srcX, srcY);
int wp = w[wy];
waSums[wx] += wp;
wp *= colors[0] + (colors[0] >> 7);
wcSums[wx] += wp;
wp >>= 8;
aSums[wx] += wp * colors[0];
bSums[wx] += wp * colors[3];
gSums[wx] += wp * colors[2];
rSums[wx] += wp * colors[1];
}
}
int wwx = w[wx];
waSum += wwx * waSums[wx];
wcSum += wwx * wcSums[wx];
aSum += wwx * aSums[wx];
bSum += wwx * bSums[wx];
gSum += wwx * gSums[wx];
rSum += wwx * rSums[wx];
}
}
wcSum >>= 8;
if (waSum == 0 || wcSum == 0) {
SetColorAt(bbbDest, 0, y, new int[]{0,0,0,0});
} else {
int alpha = (int)(aSum / waSum);
int blue = (int)(bSum / wcSum);
int green = (int)(gSum / wcSum);
int red = (int)(rSum / wcSum);
SetColorAt(bbbDest, 0, y, new int[]{alpha, red, green, blue});
}
for (int x = 1; x < applyRect.Width; ++x) {
for (int i = 0; i < wlen - 1; ++i) {
waSums[i] = waSums[i + 1];
wcSums[i] = wcSums[i + 1];
aSums[i] = aSums[i + 1];
bSums[i] = bSums[i + 1];
gSums[i] = gSums[i + 1];
rSums[i] = rSums[i + 1];
}
waSum = 0;
wcSum = 0;
aSum = 0;
bSum = 0;
gSum = 0;
rSum = 0;
int wx;
for (wx = 0; wx < wlen - 1; ++wx) {
long wwx = (long)w[wx];
waSum += wwx * waSums[wx];
wcSum += wwx * wcSums[wx];
aSum += wwx * aSums[wx];
bSum += wwx * bSums[wx];
gSum += wwx * gSums[wx];
rSum += wwx * rSums[wx];
}
wx = wlen - 1;
waSums[wx] = 0;
wcSums[wx] = 0;
aSums[wx] = 0;
bSums[wx] = 0;
gSums[wx] = 0;
rSums[wx] = 0;
int srcX = x + wx - r;
if (srcX >= 0 && srcX < applyRect.Width) {
for (int wy = 0; wy < wlen; ++wy) {
int srcY = y + wy - r;
// only when in EDIT mode, ignore some pixels depending on preview quality
if ((renderMode==RenderMode.EXPORT || rand.NextDouble()<previewQuality) && srcY >= 0 && srcY < applyRect.Height) {
int[] colors = bbbSrc.GetColorArrayAt(srcX, srcY);
int wp = w[wy];
waSums[wx] += wp;
wp *= colors[0] + (colors[0] >> 7);
wcSums[wx] += wp;
wp >>= 8;
aSums[wx] += wp * (long)colors[0];
bSums[wx] += wp * (long)colors[3];
gSums[wx] += wp * (long)colors[2];
rSums[wx] += wp * (long)colors[1];
}
}
int wr = w[wx];
waSum += (long)wr * waSums[wx];
wcSum += (long)wr * wcSums[wx];
aSum += (long)wr * aSums[wx];
bSum += (long)wr * bSums[wx];
gSum += (long)wr * gSums[wx];
rSum += (long)wr * rSums[wx];
}
wcSum >>= 8;
if (waSum == 0 || wcSum == 0) {
SetColorAt(bbbDest, x, y, new int[]{0,0,0,0});
} else {
int alpha = (int)(aSum / waSum);
int blue = (int)(bSum / wcSum);
int green = (int)(gSum / wcSum);
int red = (int)(rSum / wcSum);
SetColorAt(bbbDest, x, y, new int[]{alpha, red, green, blue});
}
}
}
}
bbbDest.DrawTo(graphics, applyRect.Location);
}
}
private void SetColorAt(BitmapBuffer bbb, int x, int y, int[] colors) {
if(parent.Contains(applyRect.Left+x, applyRect.Top+y) ^ Invert) {
bbb.SetColorArrayAt(x, y, colors);
}
}
}
}

View file

@ -0,0 +1,56 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class BrightnessFilter : AbstractFilter {
private double brightness;
public BrightnessFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.BRIGHTNESS, 0.9d);
}
protected override void IteratePixel(int x, int y) {
Color color = bbb.GetColorAt(x, y);
int r = Convert.ToInt16(color.R*brightness);
int g = Convert.ToInt16(color.G*brightness);
int b = Convert.ToInt16(color.B*brightness);
r = (r>255) ? 255 : r;
g = (g>255) ? 255 : g;
b = (b>255) ? 255 : b;
bbb.SetColorAt(x, y, Color.FromArgb(color.A, r, g, b));
}
public override void Apply(Graphics graphics, Bitmap bmp, Rectangle rect, RenderMode renderMode) {
brightness = GetFieldValueAsDouble(FieldType.BRIGHTNESS);
base.Apply(graphics, bmp, rect, renderMode);
}
}
}

View file

@ -0,0 +1,231 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class FastSmoothFilter : AbstractFilter {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(FastSmoothFilter));
public FastSmoothFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.BLUR_RADIUS, 3);
}
public unsafe override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle applyRect, RenderMode renderMode) {
Rectangle sourceRect = new Rectangle(applyRect.X, applyRect.Y, applyRect.Width, applyRect.Height);
Rectangle bitmapRect = new Rectangle(0,0, applyBitmap.Width, applyBitmap.Height);
if(sourceRect.Equals(Rectangle.Empty)) {
sourceRect = bitmapRect;
} else {
sourceRect.Intersect(bitmapRect);
}
// Does the rect have any pixels?
if (sourceRect.Height <= 0 || sourceRect.Width <= 0) {
return;
}
int blurRadius = GetFieldValueAsInt(FieldType.BLUR_RADIUS);
// Calculate new sourceRect to include the matrix size if possible
int leftOffset = Math.Min(sourceRect.X, blurRadius);
int rightOffset = Math.Min(applyBitmap.Width - (sourceRect.X + sourceRect.Width), blurRadius);
int topOffset = Math.Min(sourceRect.Y, blurRadius);
int bottomOffset = Math.Min(applyBitmap.Height - (sourceRect.Y + sourceRect.Height), blurRadius);
LOG.Debug(String.Format("Offsets: {0},{1},{2},{3}", leftOffset, rightOffset, topOffset, bottomOffset));
LOG.Debug(String.Format("SourceRect before: {0},{1},{2},{3}", sourceRect.X, sourceRect.Width, sourceRect.Y, sourceRect.Height));
sourceRect.X -= leftOffset;
sourceRect.Width += leftOffset + rightOffset;
sourceRect.Y -= topOffset;
sourceRect.Height += topOffset + bottomOffset;
LOG.Debug(String.Format("SourceRect after: {0},{1},{2},{3}", sourceRect.X, sourceRect.Width, sourceRect.Y, sourceRect.Height));
// Make a copy of the applyBitmap for reading
using (Bitmap sourceBitmap = applyBitmap.Clone(sourceRect, applyBitmap.PixelFormat)) {
ApplySmooth(sourceBitmap, applyBitmap, sourceRect, blurRadius);
}
}
public static bool ApplySmooth(Bitmap sourceBitmap, Bitmap destinationBitmap, Rectangle destRectangle, int blurRadius) {
if (blurRadius < 1) {
return false;
}
BitmapData destbitmapData = destinationBitmap.LockBits(destRectangle, ImageLockMode.WriteOnly, destinationBitmap.PixelFormat);
BitmapData srcBitmapData = sourceBitmap.LockBits(new Rectangle(0, 0, sourceBitmap.Width, sourceBitmap.Height),
ImageLockMode.ReadOnly,
sourceBitmap.PixelFormat);
int destStride = destbitmapData.Stride;
int srcStride = srcBitmapData.Stride;
IntPtr destScan0 = destbitmapData.Scan0;
IntPtr srcScan0 = srcBitmapData.Scan0;
int bIndex;
int gIndex;
int rIndex;
//int aIndex;
int bytesPerPixel;
switch(destinationBitmap.PixelFormat) {
case PixelFormat.Format32bppArgb:
// GDI+ lies to us - the return format is BGR, NOT RGB.
bIndex = 0;
gIndex = 1;
rIndex = 2;
//aIndex = 3;
bytesPerPixel = 4;
break;
case PixelFormat.Format32bppRgb:
// GDI+ lies to us - the return format is BGR, NOT RGB.
bIndex = 0;
gIndex = 1;
rIndex = 2;
bytesPerPixel = 4;
break;
case PixelFormat.Format24bppRgb:
// GDI+ lies to us - the return format is BGR, NOT RGB.
bIndex = 0;
gIndex = 1;
rIndex = 2;
bytesPerPixel = 3;
break;
default:
throw new FormatException("Bitmap.Pixelformat."+destinationBitmap.PixelFormat+" is currently not supported. Supported: Format32bpp(A)Rgb, Format24bppRgb");
}
long ticks = DateTime.Now.Ticks;
unsafe {
int width = destRectangle.Width - (blurRadius*2);
int height = destRectangle.Height - (blurRadius*2);
int diameter = (2 * blurRadius) + 1;
int mid = ((diameter-1)/2) + 1;
int midPixel = mid * bytesPerPixel;
int midLine = (mid - 1) * destStride;
int writeRPixelOffset = midLine + midPixel + rIndex;
int writeGPixelOffset = midLine + midPixel + gIndex;
int writeBPixelOffset = midLine + midPixel + bIndex;
int readRPixelOffset = diameter * bytesPerPixel + rIndex;
int readGPixelOffset = diameter * bytesPerPixel + gIndex;
int readBPixelOffset = diameter * bytesPerPixel + bIndex;
int destOffset = destStride - (width*bytesPerPixel);
int srcOffset = srcStride - (width*bytesPerPixel);
int factor = diameter * diameter;
byte *destBitmapPointer = (byte *)(void *)destScan0;
byte *srcBitmapPointer = (byte *)(void *)srcScan0;
int pixel, lineOffset;
int rTotal, gTotal, bTotal;
int [,]r = new int[diameter,diameter];
int [,]g = new int[diameter,diameter];
int [,]b = new int[diameter,diameter];
for (int y=0; y < height; y++) {
// Reset totals
rTotal = gTotal = bTotal = 0;
// Intial load: Do the complete radius, fill the arrays with their values
lineOffset = 0; // Offset relative to the srcBitmapPointer
// Vertical loop
for (int v = 0; v < diameter; v++) {
// Start at beginning of the current line
int index = lineOffset;
// Horizontal loop
for (int currentRow = 0; currentRow < diameter; currentRow++) {
// Get & add values
rTotal += r[v,currentRow] = srcBitmapPointer[index + rIndex];
gTotal += g[v,currentRow] = srcBitmapPointer[index + gIndex];
bTotal += b[v,currentRow] = srcBitmapPointer[index + bIndex];
// Move 1px to the right
index += bytesPerPixel;
}
// Move to next line
lineOffset += srcStride;
}
// Now loop the complete line from left to right
for (int x=0; x < width; x++ ) {
// Draw Pixel with calculated values
pixel = rTotal / factor;
if (pixel < 0) pixel = 0;
if (pixel > 255) pixel = 255;
destBitmapPointer[writeRPixelOffset]= (byte)pixel;
pixel = gTotal / factor;
if (pixel < 0) pixel = 0;
if (pixel > 255) pixel = 255;
destBitmapPointer[writeGPixelOffset]= (byte)pixel;
pixel = bTotal / factor;
if (pixel < 0) pixel = 0;
if (pixel > 255) pixel = 255;
destBitmapPointer[writeBPixelOffset]= (byte)pixel;
// Update values with next "row"
int oldRow = x % diameter;
srcBitmapPointer += bytesPerPixel;
lineOffset = 0;
// Vertical Loop, subtract the stored value and add the new value
for (int v = 0; v < diameter; v++) {
// Subtrace the first value, so we can add the new later
rTotal -= r[v, oldRow];
gTotal -= g[v, oldRow];
bTotal -= b[v, oldRow];
// Get & add the next values
rTotal += r[v, oldRow] = srcBitmapPointer[readRPixelOffset + lineOffset];
gTotal += g[v, oldRow] = srcBitmapPointer[readGPixelOffset + lineOffset];
bTotal += b[v, oldRow] = srcBitmapPointer[readBPixelOffset + lineOffset];
// Goto next line
lineOffset += srcStride;
}
destBitmapPointer += bytesPerPixel;
}
srcBitmapPointer += srcOffset;
destBitmapPointer += destOffset;
}
}
LOG.Info("Ticks = " + (DateTime.Now.Ticks - ticks));
destinationBitmap.UnlockBits(destbitmapData);
sourceBitmap.UnlockBits(srcBitmapData);
return true;
}
/**
* Checks if the supplied Bitmap has a PixelFormat we support
*/
private bool SupportsPixelFormat(Bitmap bitmap) {
return (bitmap.PixelFormat.Equals(PixelFormat.Format32bppArgb) ||
bitmap.PixelFormat.Equals(PixelFormat.Format32bppRgb) ||
bitmap.PixelFormat.Equals(PixelFormat.Format24bppRgb));
}
}
}

View file

@ -0,0 +1,44 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing.Filters {
/// <summary>
/// Description of GrayscaleFilter.
/// </summary>
[Serializable()]
public class GrayscaleFilter : AbstractFilter {
public GrayscaleFilter(DrawableContainer parent) : base(parent) {
}
protected override void IteratePixel(int x, int y) {
Color color = bbb.GetColorAt(x, y);
int luma = (int)((0.3*color.R) + (0.59*color.G) + (0.11*color.B));
color = Color.FromArgb(luma, luma, luma);
bbb.SetColorAt(x, y, color);
}
}
}

View file

@ -0,0 +1,51 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class HighlightFilter : AbstractFilter {
[NonSerialized]
private Color highlightColor;
public HighlightFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.FILL_COLOR, Color.Yellow);
}
protected override void IteratePixel(int x, int y) {
Color color = bbb.GetColorAt(x, y);
color = Color.FromArgb(color.A, Math.Min(highlightColor.R,color.R), Math.Min(highlightColor.G,color.G), Math.Min(highlightColor.B,color.B));
bbb.SetColorAt(x, y, color);
}
public override void Apply(Graphics graphics, Bitmap bmp, Rectangle rect, RenderMode renderMode) {
highlightColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
base.Apply(graphics, bmp, rect, renderMode);
}
}
}

View file

@ -0,0 +1,37 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using Greenshot.Drawing;
using Greenshot.Drawing.Fields;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing.Filters {
public interface IFilter : INotifyPropertyChanged, IFieldHolder {
DrawableContainer Parent {get; set; }
void Apply(Graphics graphics, Bitmap bmp, Rectangle rect, RenderMode renderMode);
DrawableContainer GetParent();
bool Invert {get; set;}
}
}

View file

@ -0,0 +1,65 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class MagnifierFilter : AbstractFilter {
private BitmapBuffer bbbSrc;
private int magnificationFactor;
public MagnifierFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.MAGNIFICATION_FACTOR, 2);
}
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
magnificationFactor = GetFieldValueAsInt(FieldType.MAGNIFICATION_FACTOR);
applyRect = IntersectRectangle(applyBitmap.Size, rect);
bbbSrc = new BitmapBuffer(applyBitmap, applyRect);
try {
bbbSrc.Lock();
base.Apply(graphics, applyBitmap, applyRect, renderMode);
} finally {
bbbSrc.Dispose();
bbbSrc = null;
}
}
protected override void IteratePixel(int x, int y) {
int halfWidth = bbb.Size.Width/2;
int halfHeight = bbb.Size.Height/2;
int yDistanceFromCenter = halfHeight-y;
int xDistanceFromCenter = halfWidth-x;
Color color = bbbSrc.GetColorAt(halfWidth-xDistanceFromCenter/magnificationFactor,halfHeight-yDistanceFromCenter/magnificationFactor);
bbb.SetColorAt(x, y, color);
}
}
}

View file

@ -0,0 +1,87 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.Serialization;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing.Filters {
[Serializable()]
public class PixelizationFilter : AbstractFilter {
public PixelizationFilter(DrawableContainer parent) : base(parent) {
AddField(GetType(), FieldType.PIXEL_SIZE, 5);
}
public static void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, int pixelSize) {
if(pixelSize <= 1 || rect.Width == 0 || rect.Height == 0) {
// Nothing to do
return;
}
if(rect.Width < pixelSize) pixelSize = rect.Width;
if(rect.Height < pixelSize) pixelSize = rect.Height;
using (BitmapBuffer bbbDest = new BitmapBuffer(applyBitmap, rect)) {
bbbDest.Lock();
using(BitmapBuffer bbbSrc = new BitmapBuffer(applyBitmap, rect)) {
bbbSrc.Lock();
List<Color> colors = new List<Color>();
int halbPixelSize = pixelSize/2;
for(int y=-halbPixelSize;y<bbbSrc.Height+halbPixelSize; y=y+pixelSize) {
for(int x=-halbPixelSize;x<=bbbSrc.Width+halbPixelSize; x=x+pixelSize) {
colors.Clear();
for(int yy=y;yy<y+pixelSize;yy++) {
if (yy >=0 && yy < bbbSrc.Height) {
for(int xx=x;xx<x+pixelSize;xx++) {
colors.Add(bbbSrc.GetColorAt(xx,yy));
}
}
}
Color currentAvgColor = Colors.Mix(colors);
for(int yy=y;yy<=y+pixelSize;yy++) {
if (yy >=0 && yy < bbbSrc.Height) {
for(int xx=x;xx<=x+pixelSize;xx++) {
bbbDest.SetColorAt(xx, yy, currentAvgColor);
}
}
}
}
}
}
bbbDest.DrawTo(graphics, rect.Location);
}
}
public override void Apply(Graphics graphics, Bitmap applyBitmap, Rectangle rect, RenderMode renderMode) {
int pixelSize = GetFieldValueAsInt(FieldType.PIXEL_SIZE);
applyRect = IntersectRectangle(applyBitmap.Size, rect);
Apply(graphics, applyBitmap, applyRect, pixelSize);
}
}
}

View file

@ -0,0 +1,88 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
namespace Greenshot.Drawing {
/// <summary>
/// Description of ObfuscateContainer.
/// </summary>
[Serializable()]
public class HighlightContainer : FilterContainer {
public HighlightContainer(Surface parent) : base(parent) {
AddField(GetType(), FieldType.LINE_THICKNESS, 0);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.SHADOW, false);
AddField(GetType(), FieldType.PREPARED_FILTER_HIGHLIGHT, FilterContainer.PreparedFilter.TEXT_HIGHTLIGHT);
init();
}
[OnDeserializedAttribute()]
private void OnDeserialized(StreamingContext context) {
init();
}
private void init() {
FieldChanged += HighlightContainer_OnFieldChanged;
ConfigurePreparedFilters();
}
protected void HighlightContainer_OnFieldChanged(object sender, FieldChangedEventArgs e) {
if(sender.Equals(this)) {
if (e.Field.FieldType == FieldType.PREPARED_FILTER_HIGHLIGHT) {
ConfigurePreparedFilters();
}
}
}
private void ConfigurePreparedFilters() {
PreparedFilter preset = (PreparedFilter)GetFieldValue(FieldType.PREPARED_FILTER_HIGHLIGHT);
while(Filters.Count>0) {
Remove(Filters[0]);
}
switch(preset) {
case PreparedFilter.TEXT_HIGHTLIGHT:
Add(new HighlightFilter(this));
break;
case PreparedFilter.AREA_HIGHLIGHT:
AbstractFilter bf = new BrightnessFilter(this);
bf.Invert = true;
Add(bf);
bf = new BlurFilter(this);
bf.Invert = true;
Add(bf);
break;
case PreparedFilter.GRAYSCALE:
AbstractFilter f = new GrayscaleFilter(this);
f.Invert = true;
Add(f);
break;
case PreparedFilter.MAGNIFICATION:
Add(new MagnifierFilter(this));
break;
}
}
}
}

View file

@ -0,0 +1,108 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.IO;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of IconContainer.
/// </summary>
[Serializable()]
public class IconContainer : DrawableContainer, IIconContainer {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(IconContainer));
protected Icon icon;
public IconContainer(Surface parent) : base(parent) {
}
public IconContainer(Surface parent, string filename) : base(parent) {
Load(filename);
}
public Icon Icon {
set {
if (icon != null) {
icon.Dispose();
}
icon = (Icon)value.Clone();
Width = value.Width;
Height = value.Height;
}
get { return icon; }
}
/**
* Destructor
*/
~IconContainer() {
Dispose(false);
}
/**
* The public accessible Dispose
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
*/
public new void Dispose() {
Dispose(true);
base.Dispose();
GC.SuppressFinalize(this);
}
// The bulk of the clean-up code is implemented in Dispose(bool)
/**
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (icon != null) {
icon.Dispose();
}
}
icon = null;
}
public void Load(string filename) {
if (File.Exists(filename)) {
using (Icon fileIcon = new Icon(filename)) {
Icon = fileIcon;
LOG.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
}
}
}
public override void Draw(Graphics graphics, RenderMode rm) {
if (icon != null) {
graphics.DrawIcon(icon, Bounds);
}
}
}
}

View file

@ -0,0 +1,106 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of LineContainer.
/// </summary>
[Serializable()]
public class LineContainer : DrawableContainer {
public static readonly int MAX_CLICK_DISTANCE_TOLERANCE = 10;
public LineContainer(Surface parent) : base(parent) {
Init();
AddField(GetType(), FieldType.LINE_THICKNESS, 1);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.SHADOW, false);
}
private void Init() {
grippers[1].Enabled = false;
grippers[2].Enabled = false;
grippers[3].Enabled = false;
grippers[5].Enabled = false;
grippers[6].Enabled = false;
grippers[7].Enabled = false;
}
public override void Draw(Graphics g, RenderMode rm) {
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
if ( shadow && lineThickness > 0 ) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while (currentStep <= steps) {
using (Pen shadowCapPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowCapPen.Width = lineThickness;
g.DrawLine(shadowCapPen,
this.Left + currentStep,
this.Top + currentStep,
this.Left + currentStep + this.Width,
this.Top + currentStep + this.Height);
currentStep++;
alpha = alpha - (basealpha / steps);
}
}
}
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
if(pen.Width > 0) {
g.DrawLine(pen, this.Left, this.Top, this.Left + this.Width, this.Top + this.Height);
}
}
}
public override bool ClickableAt(int x, int y) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
double distance = DrawingHelper.CalculateLinePointDistance(this.Left, this.Top, this.Left + this.Width, this.Top + this.Height, x, y);
if (distance < 0) {
return false;
}
return distance <= Math.Max(lineThickness / 2, MAX_CLICK_DISTANCE_TOLERANCE);
}
}
}

View file

@ -0,0 +1,123 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Description of MetafileContainer.
/// </summary>
[Serializable()]
public class MetafileContainer : DrawableContainer, IMetafileContainer {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(MetafileContainer));
protected Metafile metafile;
public MetafileContainer(Surface parent) : base(parent) {
}
public MetafileContainer(Surface parent, string filename) : base(parent) {
Load(filename);
}
public Metafile Metafile {
set {
if (metafile != null) {
metafile.Dispose();
}
metafile = (Metafile)value.Clone();
Height = Math.Abs(value.Height);
if (Height == 0 ) {
Height = 100;
}
Width = Math.Abs(value.Width);
if (Width == 0 ) {
Width = 100;
}
while (Height > parent.Height) {
Height = Height / 4;
Width = Width / 4;
}
while (Width > parent.Width) {
Height = Height / 4;
Width = Width / 4;
}
}
get { return metafile; }
}
/**
* Destructor
*/
~MetafileContainer() {
Dispose(false);
}
/**
* The public accessible Dispose
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
*/
public new void Dispose() {
Dispose(true);
base.Dispose();
GC.SuppressFinalize(this);
}
// The bulk of the clean-up code is implemented in Dispose(bool)
/**
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
protected virtual void Dispose(bool disposing) {
if (disposing) {
if (metafile != null) {
metafile.Dispose();
}
}
metafile = null;
}
public void Load(string filename) {
if (File.Exists(filename)) {
using (Metafile fileMetafile = new Metafile(filename)) {
Metafile = fileMetafile;
LOG.Debug("Loaded file: " + filename + " with resolution: " + Height + "," + Width);
}
}
}
public override void Draw(Graphics graphics, RenderMode rm) {
if (metafile != null) {
graphics.DrawImage(metafile, Bounds);
}
}
}
}

View file

@ -0,0 +1,70 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Runtime.Serialization;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
namespace Greenshot.Drawing {
/// <summary>
/// Description of ObfuscateContainer.
/// </summary>
[Serializable()]
public class ObfuscateContainer : FilterContainer {
public ObfuscateContainer(Surface parent) : base(parent) {
AddField(GetType(), FieldType.PREPARED_FILTER_OBFUSCATE, FilterContainer.PreparedFilter.PIXELIZE);
init();
}
[OnDeserializedAttribute()]
private void OnDeserialized(StreamingContext context) {
init();
}
private void init() {
FieldChanged += ObfuscateContainer_OnFieldChanged;
ConfigurePreparedFilters();
}
protected void ObfuscateContainer_OnFieldChanged(object sender, FieldChangedEventArgs e) {
if(sender.Equals(this)) {
if(e.Field.FieldType == FieldType.PREPARED_FILTER_OBFUSCATE) {
ConfigurePreparedFilters();
}
}
}
private void ConfigurePreparedFilters() {
PreparedFilter preset = (PreparedFilter)GetFieldValue(FieldType.PREPARED_FILTER_OBFUSCATE);
while(Filters.Count>0) {
Remove(Filters[0]);
}
switch(preset) {
case PreparedFilter.BLUR:
Add(new BlurFilter(this));
break;
case PreparedFilter.PIXELIZE:
Add(new PixelizationFilter(this));
break;
}
}
}
}

View file

@ -0,0 +1,89 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Represents a rectangular shape on the Surface
/// </summary>
[Serializable()]
public class RectangleContainer : DrawableContainer {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(RectangleContainer));
public RectangleContainer(Surface parent) : base(parent) {
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
AddField(GetType(), FieldType.SHADOW, false);
}
public override void Draw(Graphics g, RenderMode rm) {
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
bool lineVisible = (lineThickness > 0 && Colors.IsVisible(lineColor));
if (shadow && (lineVisible || Colors.IsVisible(fillColor))) {
//draw shadow first
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = lineVisible ? 1 : 0;
while (currentStep <= steps) {
using (Pen shadowPen = new Pen(Color.FromArgb(alpha, 100, 100, 100))) {
shadowPen.Width = lineVisible ? lineThickness : 1;
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(
this.Left + currentStep,
this.Top + currentStep,
this.Width,
this.Height);
g.DrawRectangle(shadowPen, shadowRect);
currentStep++;
alpha = alpha - (basealpha / steps);
}
}
}
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
using (Brush brush = new SolidBrush(fillColor)) {
g.FillRectangle(brush, rect);
}
if (lineThickness > 0) {
using (Pen pen = new Pen(lineColor)) {
pen.Width = lineThickness;
g.DrawRectangle(pen, rect);
}
}
}
}
}

View file

@ -0,0 +1,130 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Drawing.Drawing2D;
namespace Greenshot.Drawing {
public abstract class RoundedRectangle {
public enum RectangleCorners {
None = 0, TopLeft = 1, TopRight = 2,
BottomLeft = 4, BottomRight = 8,
All = TopLeft | TopRight | BottomLeft | BottomRight
}
public static GraphicsPath Create2(int x, int y, int width, int height, int radius) {
GraphicsPath gp = new GraphicsPath();
gp.AddLine(x + radius, y, x + width - (radius * 2), y); // Line
gp.AddArc(x + width - (radius * 2), y, radius * 2, radius * 2, 270, 90); // Corner
gp.AddLine(x + width, y + radius, x + width, y + height - (radius * 2)); // Line
gp.AddArc(x + width - (radius * 2), y + height - (radius * 2), radius * 2, radius * 2, 0, 90); // Corner
gp.AddLine(x + width - (radius * 2), y + height, x + radius, y + height); // Line
gp.AddArc(x, y + height - (radius * 2), radius * 2, radius * 2, 90, 90); // Corner
gp.AddLine(x, y + height - (radius * 2), x, y + radius); // Line
gp.AddArc(x, y, radius * 2, radius * 2, 180, 90); // Corner
gp.CloseFigure();
return gp;
}
public static GraphicsPath Create(int x, int y, int width, int height, int radius, RectangleCorners corners) {
int xw = x + width;
int yh = y + height;
int xwr = xw - radius;
int yhr = yh - radius;
int xr = x + radius;
int yr = y + radius;
int r2 = radius * 2;
int xwr2 = xw - r2;
int yhr2 = yh - r2;
GraphicsPath p = new GraphicsPath();
p.StartFigure();
//Top Left Corner
if ((RectangleCorners.TopLeft & corners) == RectangleCorners.TopLeft) {
p.AddArc(x, y, r2, r2, 180, 90);
} else {
p.AddLine(x, yr, x, y);
p.AddLine(x, y, xr, y);
}
//Top Edge
p.AddLine(xr, y, xwr, y);
//Top Right Corner
if ((RectangleCorners.TopRight & corners) == RectangleCorners.TopRight) {
p.AddArc(xwr2, y, r2, r2, 270, 90);
} else {
p.AddLine(xwr, y, xw, y);
p.AddLine(xw, y, xw, yr);
}
//Right Edge
p.AddLine(xw, yr, xw, yhr);
//Bottom Right Corner
if ((RectangleCorners.BottomRight & corners) == RectangleCorners.BottomRight) {
p.AddArc(xwr2, yhr2, r2, r2, 0, 90);
} else {
p.AddLine(xw, yhr, xw, yh);
p.AddLine(xw, yh, xwr, yh);
}
//Bottom Edge
p.AddLine(xwr, yh, xr, yh);
//Bottom Left Corner
if ((RectangleCorners.BottomLeft & corners) == RectangleCorners.BottomLeft) {
p.AddArc(x, yhr2, r2, r2, 90, 90);
} else {
p.AddLine(xr, yh, x, yh);
p.AddLine(x, yh, x, yhr);
}
//Left Edge
p.AddLine(x, yhr, x, yr);
p.CloseFigure();
return p;
}
public static GraphicsPath Create(Rectangle rect, int radius, RectangleCorners corners) {
return Create(rect.X, rect.Y, rect.Width, rect.Height, radius, corners);
}
public static GraphicsPath Create(int x, int y, int width, int height, int radius) {
return Create(x, y, width, height, radius, RectangleCorners.All);
}
public static GraphicsPath Create(Rectangle rect, int radius) {
return Create(rect.X, rect.Y, rect.Width, rect.Height, radius);
}
public static GraphicsPath Create(int x, int y, int width, int height) {
return Create(x, y, width, height, 5);
}
public static GraphicsPath Create(Rectangle rect) {
return Create(rect.X, rect.Y, rect.Width, rect.Height);
}
}
}

View file

@ -0,0 +1,913 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Filters;
using Greenshot.Helpers;
using Greenshot.Plugin;
using Greenshot.Plugin.Drawing;
using GreenshotPlugin.Core;
namespace Greenshot.Drawing {
public delegate void SurfaceElementEventHandler(object source, DrawableContainerList element);
public delegate void SurfaceDrawingModeEventHandler(object source, DrawingModes drawingMode);
public enum DrawingModes { None, Rect, Ellipse, Text, Line, Arrow, Crop, Highlight, Obfuscate, Bitmap }
/// <summary>
/// Description of Surface.
/// </summary>
public class Surface : PictureBox, ISurface {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(Surface));
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
public event SurfaceElementEventHandler MovingElementChanged;
public event SurfaceDrawingModeEventHandler DrawingModeChanged;
public FieldAggregator FieldAggregator = new FieldAggregator();
private ICaptureDetails captureDetails = null;
private Bitmap buffer = null;
Point mouseStart = Point.Empty;
private bool mouseDown = false;
private bool draggingInProgress = false;
private DrawableContainer mouseDownElement = null;
private DrawableContainerList elements = new DrawableContainerList();
private DrawableContainerList selectedElements = new DrawableContainerList();
private DrawableContainer drawingElement = null;
private DrawableContainer undrawnElement = null;
private DrawableContainer cropContainer = null;
private TextureBrush transparencyBackgroundBrush;
public TextureBrush TransparencyBackgroundBrush {
get {
return transparencyBackgroundBrush;
}
set {
transparencyBackgroundBrush = value;
}
}
public bool KeysLocked = false;
private bool modified = false;
public bool Modified {
get {
return modified;
}
set {
modified = value;
}
}
private DrawingModes drawingMode = DrawingModes.None;
public DrawingModes DrawingMode {
get {return drawingMode;}
set {
drawingMode = value;
DrawingModeChanged.Invoke(this, drawingMode);
DeselectAllElements();
CreateUndrawnElement();
}
}
public ICaptureDetails CaptureDetails {
get {return captureDetails;}
set {captureDetails = value;}
}
public Surface() : base(){
LOG.Debug("Creating a surface!");
this.SizeMode = PictureBoxSizeMode.AutoSize;
this.MouseDown += new MouseEventHandler(SurfaceMouseDown);
this.MouseUp += new MouseEventHandler(SurfaceMouseUp);
this.MouseMove += new MouseEventHandler(SurfaceMouseMove);
this.MouseDoubleClick += new MouseEventHandler(SurfaceDoubleClick);
this.Paint += new PaintEventHandler(SurfacePaint);
this.AllowDrop = true;
this.DragDrop += new DragEventHandler(OnDragDrop);
this.DragEnter += new DragEventHandler(OnDragEnter);
// bind selected & elements to this, otherwise they can't inform of modifications
selectedElements.Parent = this;
elements.Parent = this;
}
/// <summary>
/// Private method, the current image is disposed the new one will stay.
/// </summary>
/// <param name="image"></param>
private void SetImage(Image image) {
// Dispose
if (Image != null) {
Image.Dispose();
}
// Set new values
Image = image;
modified = true;
}
public Surface(Image image) : this() {
LOG.Debug("Got image with dimensions " + image.Width + "," + image.Height + " bpp: " + image.PixelFormat);
SetImage(image);
}
public Surface(ICapture capture) : this(capture.Image) {
// Make sure the image is NOT disposed, we took the reference directly into ourselves
((Capture)capture).NullImage();
if (capture.Cursor != null && capture.CursorVisible) {
SelectElement(AddIconContainer(capture.Cursor, capture.CursorLocation.X, capture.CursorLocation.Y));
}
captureDetails = capture.CaptureDetails;
}
public void SaveElementsToStream(Stream streamWrite) {
try {
BinaryFormatter binaryWrite = new BinaryFormatter();
binaryWrite.Serialize(streamWrite, elements);
} catch (Exception e) {
LOG.Error("Error serializing elements to stream.", e);
}
}
public void LoadElementsFromStream(Stream streamRead) {
try {
BinaryFormatter binaryRead = new BinaryFormatter();
DrawableContainerList loadedElements = (DrawableContainerList) binaryRead.Deserialize(streamRead);
if (loadedElements != null) {
loadedElements.Parent = this;
DeselectAllElements();
AddElements(loadedElements);
SelectElements(loadedElements);
FieldAggregator.BindElements(loadedElements);
}
} catch (Exception e) {
LOG.Error("Error serializing elements from stream.", e);
}
}
private void CreateUndrawnElement() {
if(undrawnElement != null) {
FieldAggregator.UnbindElement(undrawnElement);
}
switch (DrawingMode) {
case DrawingModes.Rect:
undrawnElement = new RectangleContainer(this);
break;
case DrawingModes.Ellipse:
undrawnElement = new EllipseContainer(this);
break;
case DrawingModes.Text:
undrawnElement = new TextContainer(this);
break;
case DrawingModes.Line:
undrawnElement = new LineContainer(this);
break;
case DrawingModes.Arrow:
undrawnElement = new ArrowContainer(this);
break;
case DrawingModes.Highlight:
undrawnElement = new HighlightContainer(this);
break;
case DrawingModes.Obfuscate:
undrawnElement = new ObfuscateContainer(this);
break;
case DrawingModes.Crop:
cropContainer = new CropContainer(this);
undrawnElement = cropContainer;
break;
case DrawingModes.Bitmap:
undrawnElement = new BitmapContainer(this);
break;
case DrawingModes.None:
undrawnElement = null;
break;
}
if (undrawnElement != null) {
FieldAggregator.BindElement(undrawnElement);
}
}
#region Plugin interface implementations
public IBitmapContainer AddBitmapContainer(Bitmap bitmap, int x, int y) {
BitmapContainer bitmapContainer = new BitmapContainer(this);
bitmapContainer.Bitmap = bitmap;
bitmapContainer.Left = x;
bitmapContainer.Top = y;
AddElement(bitmapContainer);
return bitmapContainer;
}
public IBitmapContainer AddBitmapContainer(string filename, int x, int y) {
BitmapContainer bitmapContainer = new BitmapContainer(this);
bitmapContainer.Load(filename);
bitmapContainer.Left = x;
bitmapContainer.Top = y;
AddElement(bitmapContainer);
return bitmapContainer;
}
public IIconContainer AddIconContainer(Icon icon, int x, int y) {
IconContainer iconContainer = new IconContainer(this);
iconContainer.Icon = icon;
iconContainer.Left = x;
iconContainer.Top = y;
AddElement(iconContainer);
return iconContainer;
}
public IIconContainer AddIconContainer(string filename, int x, int y) {
IconContainer iconContainer = new IconContainer(this);
iconContainer.Load(filename);
iconContainer.Left = x;
iconContainer.Top = y;
AddElement(iconContainer);
return iconContainer;
}
public ICursorContainer AddCursorContainer(Cursor cursor, int x, int y) {
CursorContainer cursorContainer = new CursorContainer(this);
cursorContainer.Cursor = cursor;
cursorContainer.Left = x;
cursorContainer.Top = y;
AddElement(cursorContainer);
return cursorContainer;
}
public ICursorContainer AddCursorContainer(string filename, int x, int y) {
CursorContainer cursorContainer = new CursorContainer(this);
cursorContainer.Load(filename);
cursorContainer.Left = x;
cursorContainer.Top = y;
AddElement(cursorContainer);
return cursorContainer;
}
public IMetafileContainer AddMetafileContainer(string filename, int x, int y) {
MetafileContainer metafileContainer = new MetafileContainer(this);
metafileContainer.Load(filename);
metafileContainer.Left = x;
metafileContainer.Top = y;
AddElement(metafileContainer);
return metafileContainer;
}
public IMetafileContainer AddMetafileContainer(Metafile metafile, int x, int y) {
MetafileContainer metafileContainer = new MetafileContainer(this);
metafileContainer.Metafile = metafile;
metafileContainer.Left = x;
metafileContainer.Top = y;
AddElement(metafileContainer);
return metafileContainer;
}
public ITextContainer AddTextContainer(string text, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment, FontFamily family, float size, bool italic, bool bold, bool shadow, int borderSize, Color color, Color fillColor) {
TextContainer textContainer = new TextContainer(this);
textContainer.Text = text;
textContainer.SetFieldValue(FieldType.FONT_FAMILY, family.Name);
textContainer.SetFieldValue(FieldType.FONT_BOLD, bold);
textContainer.SetFieldValue(FieldType.FONT_ITALIC, italic);
textContainer.SetFieldValue(FieldType.FONT_SIZE, size);
textContainer.SetFieldValue(FieldType.FILL_COLOR, fillColor);
textContainer.SetFieldValue(FieldType.LINE_COLOR, color);
textContainer.SetFieldValue(FieldType.LINE_THICKNESS, borderSize);
textContainer.SetFieldValue(FieldType.SHADOW, shadow);
// Make sure the Text fits
textContainer.FitToText();
// Align to Surface
textContainer.AlignToParent(horizontalAlignment, verticalAlignment);
//AggregatedProperties.UpdateElement(textContainer);
AddElement(textContainer);
return textContainer;
}
#endregion
#region DragDrop
private List<string> GetFilenames(DragEventArgs e) {
List<string> filenames = new List<string>();
string[] dropFileNames = (string[])e.Data.GetData(DataFormats.FileDrop);
if (dropFileNames != null && dropFileNames.Length > 0) {
foreach(string filename in dropFileNames) {
LOG.Debug("Found filename: " + filename);
string ext=Path.GetExtension(filename).ToLower();
if ((ext==".jpg") || (ext==".gif") || (ext==".png") || (ext==".bmp") || (ext==".wmf")) {
filenames.Add(filename);
}
}
}
return filenames;
}
private void OnDragEnter(object sender, DragEventArgs e) {
if(LOG.IsDebugEnabled) {
LOG.Debug("DragEnter got following formats: ");
foreach(string format in e.Data.GetFormats()) {
LOG.Debug(format);
}
}
if (draggingInProgress || (e.AllowedEffect & DragDropEffects.Copy) != DragDropEffects.Copy) {
e.Effect=DragDropEffects.None;
} else {
List<string> filenames = GetFilenames(e);
//|| e.Data.GetDataPresent(DataFormats.EnhancedMetafile, true)
if ( (filenames != null && filenames.Count > 0) || e.Data.GetDataPresent(DataFormats.Bitmap, true) || e.Data.GetDataPresent(DataFormats.EnhancedMetafile, true)) {
e.Effect=DragDropEffects.Copy;
} else {
e.Effect=DragDropEffects.None;
}
}
}
private void OnDragDrop(object sender, DragEventArgs e) {
List<string> filenames = GetFilenames(e);
Point mouse = this.PointToClient(new Point(e.X, e.Y));
if ((filenames != null && filenames.Count > 0)) {
foreach(string filename in filenames) {
if (filename != null && filename.Trim().Length > 0) {
LOG.Debug("Drop - filename: " + filename);
if (filename.ToLower().EndsWith("wmf")) {
AddMetafileContainer(filename, mouse.X, mouse.Y);
} else {
AddBitmapContainer(filename, mouse.X, mouse.Y);
}
mouse.Offset(10, 10);
}
}
} else if (e.Data.GetDataPresent(DataFormats.Bitmap)) {
AddBitmapContainer((Bitmap)e.Data.GetData(DataFormats.Bitmap, true), mouse.X, mouse.Y);
} else if (e.Data.GetDataPresent(DataFormats.EnhancedMetafile)) {
AddMetafileContainer((Metafile)e.Data.GetData(DataFormats.EnhancedMetafile, true), mouse.X, mouse.Y);
}
}
// private void QueryContinueDragDrop(object sender, QueryContinueDragEventArgs e) {
// LOG.Debug("QueryContinueDrag: " + e.Action);
// if (e.EscapePressed) {
// e.Action = DragAction.Cancel;
// }
// }
//
// private void GiveFeedbackDragDrop(object sender, GiveFeedbackEventArgs e) {
// e.UseDefaultCursors = true;
// }
#endregion
bool ApplyCrop(Rectangle cropRectangle) {
cropRectangle = Helpers.GuiRectangle.GetGuiRectangle(cropRectangle.Left, cropRectangle.Top, cropRectangle.Width, cropRectangle.Height);
if (cropRectangle.Left < 0) cropRectangle = new Rectangle(0, cropRectangle.Top, cropRectangle.Width + cropRectangle.Left, cropRectangle.Height);
if (cropRectangle.Top < 0) cropRectangle = new Rectangle(cropRectangle.Left, 0, cropRectangle.Width, cropRectangle.Height + cropRectangle.Top);
if (cropRectangle.Left + cropRectangle.Width > Width) cropRectangle = new Rectangle(cropRectangle.Left, cropRectangle.Top, Width - cropRectangle.Left, cropRectangle.Height);
if (cropRectangle.Top + cropRectangle.Height > Height) cropRectangle = new Rectangle(cropRectangle.Left, cropRectangle.Top, cropRectangle.Width, Height - cropRectangle.Top);
if (cropRectangle.Height > 0 && cropRectangle.Width > 0) {
// we should not forget to Dispose the images!!
Bitmap tmpImage = ((Bitmap)Image).Clone(cropRectangle, Image.PixelFormat);
tmpImage.SetResolution(Image.HorizontalResolution, Image.VerticalResolution);
SetImage(tmpImage);
elements.MoveBy(-cropRectangle.Left, -cropRectangle.Top);
Invalidate();
return true;
}
return false;
}
private Point GetMouseCoordinates(MouseEventArgs e) {
//Point mouseLocation = new Point(e.X - AutoScrollPosition.X, e.Y - AutoScrollPosition.Y);
Point mouseLocation = new Point(e.X, e.Y);
return mouseLocation;
}
void SurfaceMouseDown(object sender, MouseEventArgs e) {
mouseStart = GetMouseCoordinates(e);
mouseDown = true;
if (cropContainer != null && ((undrawnElement == null) || (undrawnElement != null && DrawingMode != DrawingModes.Crop))) {
RemoveElement(cropContainer);
cropContainer = null;
drawingElement = null;
}
if(drawingElement == null && DrawingMode != DrawingModes.None) {
if (undrawnElement == null) {
DeselectAllElements();
if(undrawnElement == null) {
CreateUndrawnElement();
}
}
drawingElement = undrawnElement;
drawingElement.Status = EditStatus.DRAWING;
undrawnElement = null;
// if a new element has been drawn, set location and register it
if (drawingElement != null) {
drawingElement.PropertyChanged += ElementPropertyChanged;
drawingElement.Left = mouseStart.X;
drawingElement.Top = mouseStart.Y;
AddElement(drawingElement);
drawingElement.Selected = true;
}
} else {
// check whether an existing element was clicked
// we save mouse down element separately from selectedElements (checked on mouse up),
// since it could be moved around before it is actually selected
mouseDownElement = elements.ClickableElementAt(mouseStart.X, mouseStart.Y);
if(mouseDownElement != null) {
mouseDownElement.Status = EditStatus.MOVING;
}
}
}
void SurfaceMouseUp(object sender, MouseEventArgs e) {
Point currentMouse = GetMouseCoordinates(e);
elements.Status = EditStatus.IDLE;
if (mouseDownElement != null) {
mouseDownElement.Status = EditStatus.IDLE;
}
mouseDown = false;
mouseDownElement = null;
if (DrawingMode == DrawingModes.None) {
// check whether an existing element was clicked
DrawableContainer element = elements.ClickableElementAt(currentMouse.X, currentMouse.Y);
bool shiftModifier = (Control.ModifierKeys & Keys.Shift) == Keys.Shift;
if (element != null) {
element.Invalidate();
bool alreadySelected = selectedElements.Contains(element);
if (shiftModifier) {
if (alreadySelected) {
DeselectElement(element);
} else {
SelectElement(element);
}
} else {
if (!alreadySelected) {
DeselectAllElements();
SelectElement(element);
}
}
} else if(!shiftModifier) {
DeselectAllElements();
}
}
if (selectedElements.Count > 0) {
selectedElements.ShowGrippers();
selectedElements.Selected = true;
}
if (drawingElement != null) {
drawingElement.Invalidate();
if (!drawingElement.InitContent()) {
elements.Remove(drawingElement);
drawingElement.Invalidate();
} else {
if (Math.Abs(drawingElement.Width) < 5 && Math.Abs(drawingElement.Height) < 5) {
drawingElement.Width = 25;
drawingElement.Height = 25;
}
SelectElement(drawingElement);
drawingElement.Selected = true;
}
drawingElement = null;
}
}
void SurfaceMouseMove(object sender, MouseEventArgs e) {
Point currentMouse = GetMouseCoordinates(e);
if (DrawingMode != DrawingModes.None) {
Cursor = Cursors.Cross;
} else {
Cursor = Cursors.Default;
}
if(mouseDown) {
if(mouseDownElement != null) { // an element is currently dragged
mouseDownElement.Invalidate();
selectedElements.HideGrippers();
if(mouseDownElement.Selected) {
// dragged element has been selected before -> move all
selectedElements.MoveBy(currentMouse.X - mouseStart.X, currentMouse.Y - mouseStart.Y);
} else {
// dragged element is not among selected elements -> just move dragged one
mouseDownElement.MoveBy(currentMouse.X - mouseStart.X, currentMouse.Y - mouseStart.Y);
}
mouseStart = currentMouse;
mouseDownElement.Invalidate();
modified = true;
} else if(drawingElement != null) {
// an element is currently drawn
drawingElement.Invalidate();
drawingElement.Width = currentMouse.X - drawingElement.Left;
drawingElement.Height = currentMouse.Y - drawingElement.Top;
drawingElement.Invalidate();
modified = true;
}
}
}
void SurfaceDoubleClick(object sender, MouseEventArgs e) {
selectedElements.OnDoubleClick();
selectedElements.Invalidate();
}
private Image GetImage(RenderMode renderMode) {
Image clone = new Bitmap(Image);
// This actually generates a copy of the original image with a dpi equal to the default...
// otherwise we would have a problem drawing the image to the surface... :(
using (Graphics graphics = Graphics.FromImage(clone)) {
graphics.DrawImage(Image, Point.Empty);
elements.Draw(graphics, (Bitmap)clone, renderMode, new Rectangle(Point.Empty, clone.Size));
}
return clone;
}
public Image GetImageForExport() {
return GetImage(RenderMode.EXPORT);
}
/// <summary>
/// This is the event handler for the Paint Event, try to draw as little as possible!
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void SurfacePaint(object sender, PaintEventArgs e) {
Graphics targetGraphics = e.Graphics;
Rectangle clipRectangle = e.ClipRectangle;
if (elements.hasIntersectingFilters(clipRectangle)) {
if (buffer != null) {
if (buffer.Width != Image.Width || buffer.Height != Image.Height || buffer.PixelFormat != Image.PixelFormat) {
buffer.Dispose();
buffer = null;
}
}
if (buffer == null) {
buffer = new Bitmap(Image.Width, Image.Height, Image.PixelFormat);
}
// Elements might need the bitmap, so we copy the part we need
using (Graphics graphics = Graphics.FromImage(buffer)) {
graphics.DrawImage(Image, clipRectangle, clipRectangle, GraphicsUnit.Pixel);
graphics.SetClip(targetGraphics);
elements.Draw(graphics, buffer, RenderMode.EDIT, clipRectangle);
}
targetGraphics.DrawImage(buffer, clipRectangle, clipRectangle, GraphicsUnit.Pixel);
} else {
// Only "simple" elements need to be redrawn, as the image is already drawn before getting the event we don't need the next line:
//targetGraphics.DrawImage(Image, clipRectangle, clipRectangle, GraphicsUnit.Pixel);
elements.Draw(targetGraphics, null, RenderMode.EDIT, clipRectangle);
}
}
// Draw a checkboard when capturing with transparency
protected override void OnPaintBackground(PaintEventArgs e) {
// check if we need to draw the checkerboard
if (Image.PixelFormat == PixelFormat.Format32bppArgb && transparencyBackgroundBrush != null) {
Graphics targetGraphics = e.Graphics;
Rectangle clipRectangle = e.ClipRectangle;
targetGraphics.FillRectangle(transparencyBackgroundBrush, clipRectangle);
} else {
Graphics targetGraphics = e.Graphics;
targetGraphics.Clear(this.BackColor);
//base.OnPaintBackground(e);
}
}
public void AddElement(DrawableContainer element) {
elements.Add(element);
element.FieldChanged += element_FieldChanged;
element.PropertyChanged += ElementPropertyChanged;
if(element.Status == EditStatus.UNDRAWN) {
element.Status = EditStatus.IDLE;
}
element.Invalidate();
modified = true;
}
public void RemoveElement(DrawableContainer element) {
DeselectElement(element);
elements.Remove(element);
element.FieldChanged -= element_FieldChanged;
element.PropertyChanged -= ElementPropertyChanged;
element.Dispose();
element.Invalidate();
modified = true;
}
public void AddElements(DrawableContainerList elementsToAdd) {
elements.AddRange(elementsToAdd);
foreach(DrawableContainer element in elementsToAdd) {
element.FieldChanged += element_FieldChanged;
element.PropertyChanged += ElementPropertyChanged;
if (element.Status == EditStatus.UNDRAWN) {
element.Status = EditStatus.IDLE;
}
element.Invalidate();
}
modified = true;
}
public bool HasSelectedElements() {
return (selectedElements != null && selectedElements.Count > 0);
}
public void RemoveSelectedElements() {
if (HasSelectedElements()) {
// As RemoveElement will remove the element from the selectedElements list we need to copy the element
// to another list.
List<DrawableContainer> elementsToRemove = new List<DrawableContainer>();
foreach (DrawableContainer element in selectedElements) {
// Collect to remove later
elementsToRemove.Add(element);
}
// Remove now
foreach(DrawableContainer element in elementsToRemove) {
RemoveElement(element);
}
selectedElements.Clear();
MovingElementChanged(this, selectedElements);
}
}
public void CutSelectedElements() {
if (HasSelectedElements()) {
ClipboardHelper.SetClipboardData(typeof(DrawableContainerList), selectedElements);
RemoveSelectedElements();
}
}
public void CopySelectedElements() {
if (HasSelectedElements()) {
ClipboardHelper.SetClipboardData(typeof(DrawableContainerList), selectedElements);
}
}
public void ConfirmSelectedConfirmableElements(bool confirm){
// create new collection so that we can iterate safely (selectedElements might change due with confirm/cancel)
List<DrawableContainer> selectedDCs = new List<DrawableContainer>(selectedElements);
foreach(DrawableContainer dc in selectedDCs){
if(dc.Equals(cropContainer)){
DrawingMode = DrawingModes.None;
RemoveElement(cropContainer);
if(confirm) {
ApplyCrop(cropContainer.Bounds);
}
cropContainer.Dispose();
}
}
}
public void PasteElementFromClipboard() {
List<string> formats = ClipboardHelper.GetFormats();
if (formats == null || formats.Count == 0) {
return;
}
if (LOG.IsDebugEnabled) {
LOG.Debug("List of clipboard formats available for pasting:");
foreach(string format in formats) {
LOG.Debug("\tgot format: " + format);
}
}
if (formats.Contains(typeof(DrawableContainerList).FullName)) {
DrawableContainerList dcs = (DrawableContainerList)ClipboardHelper.GetClipboardData(typeof(DrawableContainerList));
if (dcs != null) {
dcs.Parent = this;
dcs.MoveBy(10,10);
AddElements(dcs);
FieldAggregator.BindElements(dcs);
DeselectAllElements();
SelectElements(dcs);
}
} else if (Clipboard.ContainsImage()) {
using (Image image = Clipboard.GetImage()) {
if (image != null) {
DeselectAllElements();
IBitmapContainer bitmapContainer = AddBitmapContainer(image as Bitmap, 0, 0);
SelectElement(bitmapContainer);
}
}
} else if (Clipboard.ContainsText()) {
string text = Clipboard.GetText();
if (text != null) {
DeselectAllElements();
ITextContainer textContainer = AddTextContainer(text, HorizontalAlignment.Center, VerticalAlignment.CENTER,
FontFamily.GenericSansSerif, 12f, false, false, false, 2, Color.Black, Color.Transparent);
SelectElement(textContainer);
}
}
}
public void DuplicateSelectedElements() {
if(LOG.IsDebugEnabled) LOG.Debug("Duplicating "+selectedElements.Count+" selected elements");
DrawableContainerList dcs = (DrawableContainerList)Objects.DeepClone(selectedElements);
dcs.Parent = this;
dcs.MoveBy(10,10);
AddElements(dcs);
DeselectAllElements();
SelectElements(dcs);
}
public void DeselectElement(IDrawableContainer container) {
DrawableContainer element = container as DrawableContainer;
element.HideGrippers();
element.Selected = false;
selectedElements.Remove(element);
FieldAggregator.UnbindElement(element);
if (MovingElementChanged != null) {
MovingElementChanged(this, selectedElements);
}
}
public void DeselectAllElements() {
if (HasSelectedElements()) {
while(selectedElements.Count > 0) {
DrawableContainer element = selectedElements[0];
element.Invalidate();
element.HideGrippers();
element.Selected = false;
selectedElements.Remove(element);
FieldAggregator.UnbindElement(element);
}
if (MovingElementChanged != null) {
MovingElementChanged(this, selectedElements);
}
}
}
public void SelectElement(IDrawableContainer container) {
DrawableContainer element = container as DrawableContainer;
if(!selectedElements.Contains(element)) {
selectedElements.Add(element);
element.ShowGrippers();
element.Selected = true;
FieldAggregator.BindElement(element);
if (MovingElementChanged != null) {
MovingElementChanged(this, selectedElements);
}
element.Invalidate();
}
}
public void SelectAllElements() {
SelectElements(elements);
}
public void SelectElements(DrawableContainerList elements) {
foreach(DrawableContainer element in elements) {
SelectElement(element);
}
}
public void ProcessCmdKey(Keys k) {
if (selectedElements.Count > 0) {
int px = (k == Keys.Shift) ? 10 : 1;
switch (k) {
case Keys.Left:
selectedElements.MoveBy(-1,0);
break;
case Keys.Left | Keys.Shift:
selectedElements.MoveBy(-10,0);
break;
case Keys.Up:
selectedElements.MoveBy(0,-1);
break;
case Keys.Up | Keys.Shift:
selectedElements.MoveBy(0,-10);
break;
case Keys.Right:
selectedElements.MoveBy(1,0);
break;
case Keys.Right | Keys.Shift:
selectedElements.MoveBy(10,0);
break;
case Keys.Down:
selectedElements.MoveBy(0,1);
break;
case Keys.Down | Keys.Shift:
selectedElements.MoveBy(0,10);
break;
case Keys.PageUp:
PullElementsUp();
break;
case Keys.PageDown:
PushElementsDown();
break;
case Keys.Home:
PullElementsToTop();
break;
case Keys.End:
PushElementsToBottom();
break;
case Keys.Enter:
ConfirmSelectedConfirmableElements(true);
break;
case Keys.Escape:
ConfirmSelectedConfirmableElements(false);
break;
/*case Keys.Delete:
RemoveSelectedElements();
break;*/
default:
return;
}
}
}
/// <summary>
/// pulls selected elements up one level in hierarchy
/// </summary>
public void PullElementsUp() {
elements.PullElementsUp(selectedElements);
elements.Invalidate();
}
/// <summary>
/// pushes selected elements up to top in hierarchy
/// </summary>
public void PullElementsToTop() {
elements.PullElementsToTop(selectedElements);
elements.Invalidate();
}
/// <summary>
/// pushes selected elements down one level in hierarchy
/// </summary>
public void PushElementsDown() {
elements.PushElementsDown(selectedElements);
elements.Invalidate();
}
/// <summary>
/// pushes selected elements down to bottom in hierarchy
/// </summary>
public void PushElementsToBottom() {
elements.PushElementsToBottom(selectedElements);
elements.Invalidate();
}
/// <summary>
/// indicates whether the selected elements could be pulled up in hierarchy
/// </summary>
/// <returns>true if selected elements could be pulled up, false otherwise</returns>
public bool CanPullSelectionUp() {
return elements.CanPullUp(selectedElements);
}
/// <summary>
/// indicates whether the selected elements could be pushed down in hierarchy
/// </summary>
/// <returns>true if selected elements could be pushed down, false otherwise</returns>
public bool CanPushSelectionDown() {
return elements.CanPushDown(selectedElements);
}
public new void Dispose() {
LOG.Debug("Disposing a surface!");
if (buffer != null) {
buffer.Dispose();
buffer = null;
}
if (transparencyBackgroundBrush != null) {
transparencyBackgroundBrush.Dispose();
transparencyBackgroundBrush = null;
}
base.Dispose();
}
public void ElementPropertyChanged(object sender, PropertyChangedEventArgs e) {
//Invalidate();
}
public void element_FieldChanged(object sender, FieldChangedEventArgs e) {
selectedElements.HandleFieldChangedEvent(sender, e);
}
}
}

View file

@ -0,0 +1,297 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;
using System.Runtime.Serialization;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing.Fields;
using Greenshot.Helpers;
using Greenshot.Plugin.Drawing;
namespace Greenshot.Drawing {
/// <summary>
/// Represents a textbox (extends RectangleContainer for border/background support
/// </summary>
[Serializable()]
public class TextContainer : RectangleContainer, ITextContainer {
private bool fontInvalidated = true;
private Font font;
private string text;
public string Text {
get { return text; }
set {
if((text == null && value != null) || !text.Equals(value)) {
text = value;
OnPropertyChanged("Text");
}
}
}
[NonSerialized]
private TextBox textBox;
public TextContainer(Surface parent) : base(parent) {
Init();
AddField(GetType(), FieldType.LINE_THICKNESS, 1);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.SHADOW, false);
AddField(GetType(), FieldType.FONT_ITALIC, false);
AddField(GetType(), FieldType.FONT_BOLD, false);
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
AddField(GetType(), FieldType.FONT_FAMILY, FontFamily.GenericSansSerif.Name);
AddField(GetType(), FieldType.FONT_SIZE, 11f);
}
[OnDeserializedAttribute()]
private void OnDeserialized(StreamingContext context) {
Init();
UpdateFont();
}
/**
* Destructor
*/
~TextContainer() {
Dispose(false);
}
/**
* The public accessible Dispose
* Will call the GarbageCollector to SuppressFinalize, preventing being cleaned twice
*/
public override void Dispose() {
Dispose(true);
base.Dispose();
GC.SuppressFinalize(this);
}
/**
* This Dispose is called from the Dispose and the Destructor.
* When disposing==true all non-managed resources should be freed too!
*/
protected virtual void Dispose(bool disposing) {
if (disposing) {
if(textBox != null) textBox.Dispose();
if(font != null) font.Dispose();
}
textBox = null;
font = null;
}
private void Init() {
CreateTextBox();
this.PropertyChanged += new PropertyChangedEventHandler(TextContainer_PropertyChanged);
this.FieldChanged += new FieldChangedEventHandler(TextContainer_FieldChanged);
}
public void FitToText() {
UpdateFont();
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(e.PropertyName.Equals("Selected")) {
if(!Selected && textBox.Visible) HideTextBox();
else if(Selected && Status==EditStatus.DRAWING) {
ShowTextBox();
}
//else if(!textBox.Visible) ShowTextBox();
}
if(textBox.Visible) {
UpdateTextBoxPosition();
UpdateTextBoxFormat();
textBox.Invalidate();
}
}
void TextContainer_FieldChanged(object sender, FieldChangedEventArgs e)
{
if(textBox.Visible) {
UpdateTextBoxFormat();
textBox.Invalidate();
} else {
UpdateFont();
//Invalidate();
}
font.Dispose();
font = null;
fontInvalidated = true;
}
public override void OnDoubleClick() {
ShowTextBox();
}
private void CreateTextBox() {
textBox = new TextBox();
textBox.ImeMode = ImeMode.On;
textBox.Multiline = true;
textBox.AcceptsTab = true;
textBox.AcceptsReturn = true;
textBox.DataBindings.Add("Text", this, "Text", false, DataSourceUpdateMode.OnPropertyChanged);
textBox.LostFocus += new EventHandler(textBox_LostFocus);
textBox.KeyDown += new KeyEventHandler(textBox_KeyDown);
textBox.BorderStyle = BorderStyle.FixedSingle;
textBox.Visible = false;
}
private void ShowTextBox() {
parent.KeysLocked = true;
parent.Controls.Add(textBox);
textBox.Show();
textBox.Focus();
}
private void HideTextBox() {
parent.Focus();
textBox.Hide();
parent.KeysLocked = false;
parent.Controls.Remove(textBox);
}
private void UpdateFont() {
string fontFamily = GetFieldValueAsString(FieldType.FONT_FAMILY);
bool fontBold = GetFieldValueAsBool(FieldType.FONT_BOLD);
bool fontItalic = GetFieldValueAsBool(FieldType.FONT_ITALIC);
float fontSize = GetFieldValueAsFloat(FieldType.FONT_SIZE);
if (fontInvalidated && fontFamily != null && fontSize != 0) {
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);
}
fontInvalidated = false;
}
}
private void UpdateTextBoxPosition() {
textBox.Left = this.Left;
textBox.Top = this.Top;
textBox.Width = this.Width;
textBox.Height = this.Height;
}
private void UpdateTextBoxFormat() {
UpdateFont();
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
textBox.ForeColor = lineColor;
textBox.Font = font;
}
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)) {
HideTextBox();
e.SuppressKeyPress = true;
}
}
void textBox_LostFocus(object sender, EventArgs e) {
HideTextBox();
}
public override void Draw(Graphics g, RenderMode rm) {
base.Draw(g, rm);
UpdateFont();
Rectangle rect = GuiRectangle.GetGuiRectangle(this.Left, this.Top, this.Width, this.Height);
if (Selected && rm == RenderMode.EDIT) {
DrawSelectionBorder(g, rect);
}
if (text == null || text.Length == 0 ) {
return;
}
// we only draw the shadow if there is no background
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
int textOffset = (lineThickness>0) ? (int)Math.Ceiling(lineThickness/2d) : 0;
// draw shadow before anything else
if ( shadow && (fillColor == Color.Transparent || fillColor == Color.Empty)) {
int basealpha = 100;
int alpha = basealpha;
int steps = 5;
int currentStep = 1;
while (currentStep <= steps) {
int offset = currentStep;
Rectangle shadowRect = GuiRectangle.GetGuiRectangle(Left + offset, Top + offset, Width, Height);
if(lineThickness > 0) {
shadowRect.Inflate(-textOffset, -textOffset);
}
using (Brush fontBrush = new SolidBrush(Color.FromArgb(alpha, 100, 100, 100))) {
g.DrawString(text, font, fontBrush, shadowRect);
currentStep++;
alpha = alpha - basealpha / steps;
}
}
}
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Rectangle fontRect = rect;
if(lineThickness > 0) {
fontRect.Inflate(-textOffset,-textOffset);
}
using (Brush fontBrush = new SolidBrush(lineColor)) {
g.DrawString(text, font, fontBrush, fontRect);
}
}
}
}

254
Greenshot/Forms/AboutForm.Designer.cs generated Normal file
View file

@ -0,0 +1,254 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Windows.Forms;
using Greenshot.Configuration;
namespace Greenshot {
partial class AboutForm {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.lblTitle = new System.Windows.Forms.Label();
this.lblLicense = new System.Windows.Forms.Label();
this.lblHost = new System.Windows.Forms.Label();
this.linkLblLicense = new System.Windows.Forms.LinkLabel();
this.linkLblHost = new System.Windows.Forms.LinkLabel();
this.linkLblBugs = new System.Windows.Forms.LinkLabel();
this.lblBugs = new System.Windows.Forms.Label();
this.linkLblDonations = new System.Windows.Forms.LinkLabel();
this.lblDonations = new System.Windows.Forms.Label();
this.linkLblIcons = new System.Windows.Forms.LinkLabel();
this.lblIcons = new System.Windows.Forms.Label();
this.linkLabel1 = new System.Windows.Forms.LinkLabel();
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.lblTranslation = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// lblTitle
//
this.lblTitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lblTitle.Location = new System.Drawing.Point(108, 12);
this.lblTitle.Name = "lblTitle";
this.lblTitle.Size = new System.Drawing.Size(227, 19);
this.lblTitle.TabIndex = 2;
this.lblTitle.Text = "Greenshot x.x.xxx";
//
// lblLicense
//
this.lblLicense.Location = new System.Drawing.Point(109, 34);
this.lblLicense.Name = "lblLicense";
this.lblLicense.Size = new System.Drawing.Size(369, 68);
this.lblLicense.TabIndex = 3;
this.lblLicense.Text = "Copyright (C) 2007 Thomas Braun, Jens Klingen, Robin Krom";
//
// lblHost
//
this.lblHost.Location = new System.Drawing.Point(12, 109);
this.lblHost.Name = "lblHost";
this.lblHost.Size = new System.Drawing.Size(466, 23);
this.lblHost.TabIndex = 4;
this.lblHost.Text = "Greenshot is hosted by sourceforge.net at";
//
// linkLblLicense
//
this.linkLblLicense.Location = new System.Drawing.Point(109, 85);
this.linkLblLicense.Name = "linkLblLicense";
this.linkLblLicense.Size = new System.Drawing.Size(369, 23);
this.linkLblLicense.TabIndex = 5;
this.linkLblLicense.TabStop = true;
this.linkLblLicense.Text = "http://www.gnu.org/licenses/gpl.html";
this.linkLblLicense.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// linkLblHost
//
this.linkLblHost.Location = new System.Drawing.Point(13, 124);
this.linkLblHost.Name = "linkLblHost";
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.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// linkLblBugs
//
this.linkLblBugs.Location = new System.Drawing.Point(13, 162);
this.linkLblBugs.Name = "linkLblBugs";
this.linkLblBugs.Size = new System.Drawing.Size(465, 23);
this.linkLblBugs.TabIndex = 8;
this.linkLblBugs.TabStop = true;
this.linkLblBugs.Text = "http://sourceforge.net/tracker/?group_id=191585&atid=937972";
this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// lblBugs
//
this.lblBugs.Location = new System.Drawing.Point(12, 147);
this.lblBugs.Name = "lblBugs";
this.lblBugs.Size = new System.Drawing.Size(466, 23);
this.lblBugs.TabIndex = 7;
this.lblBugs.Text = "Please report bugs to";
//
// linkLblDonations
//
this.linkLblDonations.Location = new System.Drawing.Point(13, 201);
this.linkLblDonations.Name = "linkLblDonations";
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.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// lblDonations
//
this.lblDonations.Location = new System.Drawing.Point(12, 186);
this.lblDonations.Name = "lblDonations";
this.lblDonations.Size = new System.Drawing.Size(466, 23);
this.lblDonations.TabIndex = 9;
this.lblDonations.Text = "If you like Greenshot, you might consider donating a dime or two at";
//
// linkLblIcons
//
this.linkLblIcons.Location = new System.Drawing.Point(13, 239);
this.linkLblIcons.Name = "linkLblIcons";
this.linkLblIcons.Size = new System.Drawing.Size(279, 23);
this.linkLblIcons.TabIndex = 12;
this.linkLblIcons.TabStop = true;
this.linkLblIcons.Text = "http://p.yusukekamiyamane.com";
this.linkLblIcons.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// lblIcons
//
this.lblIcons.Location = new System.Drawing.Point(12, 224);
this.lblIcons.Name = "lblIcons";
this.lblIcons.Size = new System.Drawing.Size(466, 23);
this.lblIcons.TabIndex = 11;
this.lblIcons.Text = "Greenshot uses icons from / derived from Mark James\' splendid Silk Icon Set on";
//
// linkLabel1
//
this.linkLabel1.Location = new System.Drawing.Point(304, 8);
this.linkLabel1.Name = "linkLabel1";
this.linkLabel1.Size = new System.Drawing.Size(203, 23);
this.linkLabel1.TabIndex = 13;
this.linkLabel1.TabStop = true;
this.linkLabel1.Text = "http://getgreenshot.org";
this.linkLabel1.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelClicked);
//
// pictureBox1
//
this.pictureBox1.Image = GreenshotPlugin.Core.GreenshotResources.getGreenshotImage();
this.pictureBox1.Location = new System.Drawing.Point(12, 12);
this.pictureBox1.Name = "pictureBox1";
this.pictureBox1.Size = new System.Drawing.Size(90, 90);
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBox1.TabIndex = 14;
this.pictureBox1.TabStop = false;
//
// lblTranslation
//
this.lblTranslation.Location = new System.Drawing.Point(12, 262);
this.lblTranslation.Name = "lblTranslation";
this.lblTranslation.Size = new System.Drawing.Size(466, 23);
this.lblTranslation.TabIndex = 15;
this.lblTranslation.Text = "English translation by YOUR_NAME";
//
// AboutForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(519, 293);
this.Controls.Add(this.lblTranslation);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.linkLabel1);
this.Controls.Add(this.linkLblIcons);
this.Controls.Add(this.lblIcons);
this.Controls.Add(this.linkLblDonations);
this.Controls.Add(this.lblDonations);
this.Controls.Add(this.linkLblBugs);
this.Controls.Add(this.lblBugs);
this.Controls.Add(this.linkLblHost);
this.Controls.Add(this.linkLblLicense);
this.Controls.Add(this.lblHost);
this.Controls.Add(this.lblLicense);
this.Controls.Add(this.lblTitle);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AboutForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "AboutForm";
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Label lblTranslation;
private System.Windows.Forms.LinkLabel linkLabel1;
private System.Windows.Forms.Label lblHost;
private System.Windows.Forms.LinkLabel linkLblHost;
private System.Windows.Forms.Label lblDonations;
private System.Windows.Forms.LinkLabel linkLblDonations;
private System.Windows.Forms.Label lblBugs;
private System.Windows.Forms.LinkLabel linkLblBugs;
private System.Windows.Forms.LinkLabel linkLblLicense;
private System.Windows.Forms.LinkLabel linkLblIcons;
private System.Windows.Forms.Label lblIcons;
private System.Windows.Forms.Label lblLicense;
private System.Windows.Forms.Label lblTitle;
private System.Windows.Forms.PictureBox pictureBox1;
void LinkLabelClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) {
openLink((LinkLabel)sender);
}
private void openLink(LinkLabel link) {
try {
link.LinkVisited = true;
System.Diagnostics.Process.Start(link.Text);
} catch (Exception) {
MessageBox.Show(lang.GetString(LangKey.error_openlink),lang.GetString(LangKey.error));
}
}
}
}

View file

@ -0,0 +1,71 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
namespace Greenshot {
/// <summary>
/// Description of AboutForm.
/// </summary>
public partial class AboutForm : Form {
private ILanguage lang;
public AboutForm() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
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;
lang = Language.GetInstance();
updateUI();
}
void updateUI() {
this.Text = lang.GetString(LangKey.about_title);
this.lblLicense.Text = lang.GetString(LangKey.about_license);
this.lblHost.Text = lang.GetString(LangKey.about_host);
this.lblBugs.Text = lang.GetString(LangKey.about_bugs);
this.lblDonations.Text = lang.GetString(LangKey.about_donations);
this.lblIcons.Text = lang.GetString(LangKey.about_icons);
this.lblTranslation.Text = lang.GetString(LangKey.about_translation);
}
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) {
try {
if (msg.WParam.ToInt32() == (int)Keys.Escape) {
this.Close();
} else {
return base.ProcessCmdKey(ref msg, keyData);
}
} catch (Exception) {
}
return base.ProcessCmdKey(ref msg,keyData);
}
}
}

117
Greenshot/Forms/BugReportForm.Designer.cs generated Normal file
View file

@ -0,0 +1,117 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Forms {
partial class BugReportForm {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.labelBugReportInfo = new System.Windows.Forms.Label();
this.textBoxDescription = new System.Windows.Forms.TextBox();
this.btnClose = new System.Windows.Forms.Button();
this.linkLblBugs = new System.Windows.Forms.LinkLabel();
this.SuspendLayout();
//
// labelBugReportInfo
//
this.labelBugReportInfo.Location = new System.Drawing.Point(12, 9);
this.labelBugReportInfo.Name = "labelBugReportInfo";
this.labelBugReportInfo.Size = new System.Drawing.Size(481, 141);
this.labelBugReportInfo.TabIndex = 0;
this.labelBugReportInfo.Text = "Sorry, an unexpected error occured.";
//
// textBoxDescription
//
this.textBoxDescription.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.textBoxDescription.Location = new System.Drawing.Point(12, 179);
this.textBoxDescription.Multiline = true;
this.textBoxDescription.Name = "textBoxDescription";
this.textBoxDescription.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.textBoxDescription.Size = new System.Drawing.Size(504, 232);
this.textBoxDescription.TabIndex = 1;
//
// btnClose
//
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.btnClose.Location = new System.Drawing.Point(377, 417);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(139, 23);
this.btnClose.TabIndex = 2;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
//
// linkLblBugs
//
this.linkLblBugs.Location = new System.Drawing.Point(12, 153);
this.linkLblBugs.Name = "linkLblBugs";
this.linkLblBugs.Size = new System.Drawing.Size(465, 23);
this.linkLblBugs.TabIndex = 9;
this.linkLblBugs.TabStop = true;
this.linkLblBugs.Text = "http://sourceforge.net/tracker/?group_id=191585&atid=937972";
this.linkLblBugs.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLblBugsLinkClicked);
//
// BugReportForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.CancelButton = this.btnClose;
this.ClientSize = new System.Drawing.Size(528, 452);
this.Controls.Add(this.linkLblBugs);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.textBoxDescription);
this.Controls.Add(this.labelBugReportInfo);
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.Name = "BugReportForm";
this.Text = "Error";
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.LinkLabel linkLblBugs;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.TextBox textBoxDescription;
private System.Windows.Forms.Label labelBugReportInfo;
}
}

View file

@ -0,0 +1,68 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Net;
using System.Web;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Helpers;
using GreenshotPlugin.Core;
namespace Greenshot.Forms {
public partial class BugReportForm : Form {
private ILanguage lang;
private BugReportForm() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
lang = Language.GetInstance();
UpdateUI();
WindowDetails.ToForeground(this.Handle);
}
public BugReportForm(string bugText) : this() {
this.textBoxDescription.Text = bugText;
}
void UpdateUI() {
this.Text = lang.GetString(LangKey.bugreport_title);
this.labelBugReportInfo.Text = lang.GetString(LangKey.bugreport_info);
this.btnClose.Text = lang.GetString(LangKey.bugreport_cancel);
}
void LinkLblBugsLinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) {
openLink((LinkLabel)sender);
}
private void openLink(LinkLabel link) {
try {
link.LinkVisited = true;
System.Diagnostics.Process.Start(link.Text);
} catch (Exception) {
MessageBox.Show(lang.GetString(LangKey.error_openlink),lang.GetString(LangKey.error));
}
}
}
}

85
Greenshot/Forms/CaptureForm.Designer.cs generated Normal file
View file

@ -0,0 +1,85 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Forms {
partial class CaptureForm {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.Windows.Forms.PictureBox pictureBox;
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.pictureBox = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).BeginInit();
this.SuspendLayout();
//
// pictureBox
//
this.pictureBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.pictureBox.Location = new System.Drawing.Point(0, 0);
this.pictureBox.Name = "pictureBox";
this.pictureBox.Size = new System.Drawing.Size(0, 0);
this.pictureBox.TabIndex = 1;
this.pictureBox.TabStop = false;
this.pictureBox.MouseMove += new System.Windows.Forms.MouseEventHandler(this.PictureBoxMouseMove);
this.pictureBox.MouseDown += new System.Windows.Forms.MouseEventHandler(this.PictureBoxMouseDown);
this.pictureBox.Paint += new System.Windows.Forms.PaintEventHandler(this.PictureBoxPaint);
this.pictureBox.MouseUp += new System.Windows.Forms.MouseEventHandler(this.PictureBoxMouseUp);
//
// CaptureForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(0, 0);
this.Controls.Add(this.pictureBox);
this.Cursor = System.Windows.Forms.Cursors.Cross;
this.DoubleBuffered = true;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "CaptureForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.TopMost = true;
this.VisibleChanged += new System.EventHandler(this.CaptureFormVisibleChanged);
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.CaptureFormKeyDown);
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.Visible = false;
this.ResumeLayout(false);
}
}
}

File diff suppressed because it is too large Load diff

259
Greenshot/Forms/ColorDialog.Designer.cs generated Normal file
View file

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

View file

@ -0,0 +1,238 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Threading;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
namespace Greenshot {
/// <summary>
/// Description of ColorDialog.
/// </summary>
public partial class ColorDialog {
private static ColorDialog uniqueInstance;
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
private ColorDialog() {
this.SuspendLayout();
InitializeComponent();
lang = Language.GetInstance();
updateUI();
this.SuspendLayout();
this.createColorPalette(5,5,15,15);
this.createLastUsedColorButtonRow(5,190,15,15);
this.ResumeLayout();
updateRecentColorsButtonRow();
}
public static ColorDialog GetInstance() {
if(uniqueInstance == null) {
uniqueInstance = new ColorDialog();
}
return uniqueInstance;
}
private ILanguage lang;
private List<Button> colorButtons = new List<Button>();
private List<Button> recentColorButtons = new List<Button>();
private ToolTip toolTip = new ToolTip();
private bool updateInProgress = false;
public Color Color {
get {return colorPanel.BackColor;}
set {previewColor(value,this);}
}
private void updateUI() {
this.Text = lang.GetString(LangKey.colorpicker_title);
this.btnApply.Text = lang.GetString(LangKey.colorpicker_apply);
this.btnTransparent.Text = lang.GetString(LangKey.colorpicker_transparent);
this.labelHtmlColor.Text = lang.GetString(LangKey.colorpicker_htmlcolor);
this.labelRed.Text = lang.GetString(LangKey.colorpicker_red);
this.labelGreen.Text = lang.GetString(LangKey.colorpicker_green);
this.labelBlue.Text = lang.GetString(LangKey.colorpicker_blue);
this.labelAlpha.Text = lang.GetString(LangKey.colorpicker_alpha);
this.labelRecentColors.Text = lang.GetString(LangKey.colorpicker_recentcolors);
}
#region user interface generation
private void createColorPalette(int x, int y, int w, int h) {
this.createColorButtonColumn(255,0,0, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(255,255/2,0, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(255,255,0, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(255/2,255,0, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(0,255,0, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(0,255,255/2, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(0,255,255, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(0,255/2,255, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(0,0,255, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(255/2,0,255, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(255,0,255, x, y, w, h, 11);
x += w;
this.createColorButtonColumn(255,0,255/2, x, y, w, h, 11);
x += w + 5;
this.createColorButtonColumn(255/2,255/2,255/2, x, y, w, h, 11);
this.Controls.AddRange(this.colorButtons.ToArray());
}
private void createColorButtonColumn(int red, int green, int blue, int x, int y, int w, int h, int shades) {
int shadedColorsNum = (shades - 1) / 2;
for(int i=0; i<=shadedColorsNum; i++) {
colorButtons.Add(createColorButton(red * i / shadedColorsNum, green * i /shadedColorsNum, blue * i / shadedColorsNum, x, y + i * h, w, h));
if(i>0) colorButtons.Add(createColorButton(red + (255 - red) * i / shadedColorsNum, green + (255 - green)* i /shadedColorsNum, blue+ (255 - blue) * i / shadedColorsNum, x, y + (i+shadedColorsNum) * h, w,h));
}
}
private Button createColorButton(int red, int green, int blue, int x, int y, int w, int h) {
return createColorButton(Color.FromArgb(255, red, green, blue), x, y, w, h);
}
private Button createColorButton(Color color, int x, int y, int w, int h) {
Button b = new Button();
b.BackColor = color;
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 += new System.EventHandler(colorButtonClick);
toolTip.SetToolTip(b,ColorTranslator.ToHtml(color)+" | R:"+color.R +", G:"+color.G+", B:"+color.B);
return b;
}
private void createLastUsedColorButtonRow(int x, int y, int w, int h) {
for(int i=0; i<12; i++) {
Button b = this.createColorButton(Color.Transparent, x, y, w, h);
b.Enabled = false;
recentColorButtons.Add(b);
x += w;
}
this.Controls.AddRange(this.recentColorButtons.ToArray());
}
#endregion
#region update user interface
private void updateRecentColorsButtonRow() {
for(int i=0; i<editorConfiguration.RecentColors.Count && i<12; i++) {
recentColorButtons[i].BackColor = editorConfiguration.RecentColors[i];
recentColorButtons[i].Enabled = true;
}
}
private void previewColor(Color c, Control trigger) {
updateInProgress = true;
this.colorPanel.BackColor = c;
if(trigger != this.textBoxHtmlColor) {
this.textBoxHtmlColor.Text = System.Drawing.ColorTranslator.ToHtml(c);
} else {
if(!this.textBoxHtmlColor.Text.StartsWith("#")) {
int selStart = this.textBoxHtmlColor.SelectionStart;
int selLength = this.textBoxHtmlColor.SelectionLength;
this.textBoxHtmlColor.Text = "#" +this.textBoxHtmlColor.Text;
this.textBoxHtmlColor.Select(selStart+1, selLength+1);
}
}
if(trigger != this.textBoxRed && trigger != this.textBoxGreen && trigger != this.textBoxBlue && trigger != this.textBoxAlpha) {
this.textBoxRed.Text = c.R.ToString();
this.textBoxGreen.Text = c.G.ToString();
this.textBoxBlue.Text = c.B.ToString();
this.textBoxAlpha.Text = c.A.ToString();
}
updateInProgress = false;
}
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);
updateRecentColorsButtonRow();
}
#endregion
#region textbox event handlers
void TextBoxHexadecimalTextChanged(object sender, System.EventArgs e)
{
if(updateInProgress) return;
TextBox tb = (TextBox) sender;
string t = tb.Text.Replace("#","");
int i = 0;
Int32.TryParse(t, System.Globalization.NumberStyles.AllowHexSpecifier, Thread.CurrentThread.CurrentCulture, out i);
Color c = Color.FromArgb(i);
Color opaqueColor = Color.FromArgb(255, c.R, c.G, c.B);
previewColor(opaqueColor, tb);
}
void TextBoxRGBTextChanged(object sender, System.EventArgs e)
{
if(updateInProgress) return;
TextBox tb = (TextBox) sender;
previewColor(Color.FromArgb(getColorPartIntFromString(textBoxAlpha.Text),getColorPartIntFromString(textBoxRed.Text),getColorPartIntFromString(textBoxGreen.Text),getColorPartIntFromString(textBoxBlue.Text)), tb);
}
void TextBoxGotFocus(object sender, System.EventArgs e) {
this.textBoxHtmlColor.SelectAll();
}
void TextBoxKeyDown(object sender, KeyEventArgs e) {
if(e.KeyCode == Keys.Return || e.KeyCode == Keys.Enter) {
addToRecentColors(colorPanel.BackColor);
}
}
#endregion
#region button event handlers
void colorButtonClick(object sender, System.EventArgs e) {
Button b = (Button) sender;
previewColor(b.BackColor, b);
}
void btnTransparentClick(object sender, System.EventArgs e)
{
colorButtonClick(sender, e);
}
void BtnApplyClick(object sender, System.EventArgs e)
{
this.DialogResult = DialogResult.OK;
this.Hide();
addToRecentColors(colorPanel.BackColor);
}
#endregion
#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;
return ret;
}
#endregion
}
}

View file

@ -0,0 +1,78 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using System.Diagnostics;
namespace GreenShot
{
public delegate void ColorPickerEventHandler(object o, ColorPickerEventArgs e);
public class ColorPickerToolStripButton : System.Windows.Forms.ToolStripButton
{
private Color color;
public Point Offset = new Point(0,0);
public event ColorPickerEventHandler ColorPicked;
private ColorDialog cd;
public ColorPickerToolStripButton()
{
cd = ColorDialog.GetInstance();
this.Click += new System.EventHandler(this.ToolStripButton1Click);
}
public Color Color {
set {color = value;this.Invalidate();}
get {return color;}
}
protected override void OnPaint (PaintEventArgs e) {
base.OnPaint(e);
if(color != null) {
// replace transparent color with selected color
Graphics g = e.Graphics;
//Graphics g = Graphics.FromImage(Image);
ColorMap[] colorMap = new ColorMap[1];
colorMap[0] = new ColorMap();
colorMap[0].OldColor = Color.Magenta;//this.ImageTransparentColor;
colorMap[0].NewColor = color;
ImageAttributes attr = new ImageAttributes();
attr.SetRemapTable(colorMap);
Rectangle rect = new Rectangle(0, 0, Image.Width, Image.Height);
// todo find a way to retrieve transparency offset automatically
// for now, we use the public variable Offset to define this manually
rect.Offset(Offset.X,Offset.Y);
//Image.
Debug.WriteLine("paint!"+this.Text+": "+color);
//ssif(color.Equals(Color.Transparent)) ((Bitmap)Image).MakeTransparent(Color.Magenta);
g.DrawImage(Image, rect, 0, 0, rect.Width, rect.Height, GraphicsUnit.Pixel, attr);
//this.Image.In
}
}
void ToolStripButton1Click(object sender, System.EventArgs e)
{
cd.ShowDialog(this.Owner);
Color = cd.Color;
if(ColorPicked != null) {
ColorPicked(this, new ColorPickerEventArgs(Color, cd.RecentColors));
}
}
}
public class ColorPickerEventArgs : System.EventArgs {
public Color Color;
public Color[] RecentColors;
public ColorPickerEventArgs(Color color, Color[] recentColors) {
Color = color;
RecentColors = recentColors;
}
}
}

View file

@ -0,0 +1,96 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Forms
{
partial class DestinationPickerForm
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
this.buttonGo = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// flowLayoutPanel1
//
this.flowLayoutPanel1.AutoSize = true;
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
this.flowLayoutPanel1.Size = new System.Drawing.Size(292, 273);
this.flowLayoutPanel1.TabIndex = 0;
//
// buttonGo
//
this.buttonGo.AutoSize = true;
this.buttonGo.Dock = System.Windows.Forms.DockStyle.Bottom;
this.buttonGo.Location = new System.Drawing.Point(0, 250);
this.buttonGo.Name = "buttonGo";
this.buttonGo.Size = new System.Drawing.Size(292, 23);
this.buttonGo.TabIndex = 1;
this.buttonGo.Text = "GO";
this.buttonGo.UseVisualStyleBackColor = true;
//
// DestinationPickerForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoSize = true;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.buttonGo);
this.Controls.Add(this.flowLayoutPanel1);
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "DestinationPickerForm";
this.Text = "DestinationPickerForm";
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Button buttonGo;
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
}
}

View file

@ -0,0 +1,71 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
namespace Greenshot.Forms
{
/// <summary>
/// Description of DestinationPickerForm.
/// </summary>
public partial class DestinationPickerForm : Form {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(DestinationPickerForm));
private static CoreConfiguration config = IniConfig.GetIniSection<CoreConfiguration>();
private static ILanguage lang = Language.GetInstance();
public DestinationPickerForm() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
this.Text = lang.GetString(LangKey.settings_destination);
AddCheckBox(flowLayoutPanel1, Destination.Clipboard, lang.GetString(LangKey.settings_destination_clipboard));
AddCheckBox(flowLayoutPanel1, Destination.Editor, lang.GetString(LangKey.settings_destination_editor));
AddCheckBox(flowLayoutPanel1, Destination.EMail, lang.GetString(LangKey.settings_destination_email));
AddCheckBox(flowLayoutPanel1, Destination.FileDefault, lang.GetString(LangKey.settings_destination_file));
AddCheckBox(flowLayoutPanel1, Destination.FileWithDialog, lang.GetString(LangKey.settings_destination_fileas));
AddCheckBox(flowLayoutPanel1, Destination.Printer, lang.GetString(LangKey.settings_destination_printer));
}
public void ShowAtMouse(IWin32Window owner) {
this.Show(owner);
Point target = Cursor.Position;
target.X -= this.Width / 2;
target.Y -= this.Height / 2;
this.Location = target;
}
private void AddCheckBox(Panel panel, Destination destination, string text) {
CheckBox checkbox = new CheckBox();
checkbox.Text = text;
//checkbox.Width = 200;
//checkbox.Height = 20;
checkbox.AutoSize = true;
if (config.OutputDestinations.Contains(destination)) {
checkbox.Checked = true;
}
panel.Controls.Add(checkbox);
}
}
}

1603
Greenshot/Forms/ImageEditorForm.Designer.cs generated Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,996 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Drawing.Printing;
using System.IO;
using System.Resources;
using System.Threading;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing;
using Greenshot.Drawing.Fields;
using Greenshot.Drawing.Fields.Binding;
using Greenshot.Experimental;
using Greenshot.Forms;
using Greenshot.Help;
using Greenshot.Helpers;
using Greenshot.Plugin;
using GreenshotPlugin.Core;
namespace Greenshot {
/// <summary>
/// Description of ImageEditorForm.
/// </summary>
public partial class ImageEditorForm : Form, IImageEditor {
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageEditorForm));
private static EditorConfiguration editorConfiguration = IniConfig.GetIniSection<EditorConfiguration>();
private static CoreConfiguration coreConf = IniConfig.GetIniSection<CoreConfiguration>();
private ILanguage lang;
private string lastSaveFullPath;
public Surface surface;
private System.Windows.Forms.ToolStripButton[] toolbarButtons;
private static string[] SUPPORTED_CLIPBOARD_FORMATS = {typeof(string).FullName, "Text", "DeviceIndependentBitmap", "Bitmap", typeof(DrawableContainerList).FullName};
private bool originalBoldCheckState = false;
private bool originalItalicCheckState = false;
// whether part of the editor controls are disabled depending on selected item(s)
private bool controlsDisabledDueToConfirmable = false;
/// <summary>
/// An Implementation for the IImageEditor, this way Plugins have access to the HWND handles wich can be used with Win32 API calls.
/// </summary>
public IWin32Window WindowHandle {
get { return this; }
}
public ImageEditorForm(Surface surface, bool outputMade) {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImageEditorForm));
Image backgroundForTransparency = (Image)resources.GetObject("checkerboard.Image");
surface.TransparencyBackgroundBrush = new TextureBrush(backgroundForTransparency, WrapMode.Tile);
// Make sure Double-buffer is enabled
SetStyle(ControlStyles.DoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
// Intial "saved" flag for asking if the image needs to be save
surface.Modified = !outputMade;
// resizing the panel is futile, since it is docked. however, it seems
// to fix the bug (?) with the vscrollbar not being able to shrink to
// a smaller size than the initial panel size (as set by the forms designer)
panel1.Height = 10;
// init surface
this.surface = surface;
surface.TabStop = false;
surface.MovingElementChanged += delegate { refreshEditorControls(); };
surface.DrawingModeChanged += new SurfaceDrawingModeEventHandler(surface_DrawingModeChanged);
this.fontFamilyComboBox.PropertyChanged += new PropertyChangedEventHandler(FontPropertyChanged);
surface.FieldAggregator.FieldChanged += new FieldChangedEventHandler( FieldAggregatorFieldChanged );
obfuscateModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
highlightModeButton.DropDownItemClicked += FilterPresetDropDownItemClicked;
panel1.Controls.Add(surface);
lang = Language.GetInstance();
// Make sure the editor is placed on the same location as the last editor was on close
WindowDetails thisForm = new WindowDetails(this.Handle);
thisForm.SetWindowPlacement(editorConfiguration.GetEditorPlacement());
if (editorConfiguration.MatchSizeToCapture) {
// Set editor's initial size to the size of the surface plus the size of the chrome
Size imageSize = this.Surface.Image.Size;
Size currentFormSize = this.Size;
Size currentImageClientSize = this.panel1.ClientSize;
int minimumFormWidth = 480;
int minimumFormHeight = 360;
int newWidth = Math.Max(minimumFormWidth, (currentFormSize.Width - currentImageClientSize.Width) + imageSize.Width);
int newHeight = Math.Max(minimumFormHeight, (currentFormSize.Height - currentImageClientSize.Height) + imageSize.Height);
this.Size = new Size(newWidth, newHeight);
}
updateUI();
IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);
bindFieldControls();
refreshEditorControls();
toolbarButtons = new ToolStripButton[]{btnCursor,btnRect,btnEllipse,btnText,btnLine,btnArrow,btnHighlight, btnObfuscate, btnCrop};
//toolbarDropDownButtons = new ToolStripDropDownButton[]{btnBlur, btnPixeliate, btnTextHighlighter, btnAreaHighlighter, btnMagnifier};
PluginHelper.instance.CreateImageEditorOpenEvent(this);
pluginToolStripMenuItem.Visible = pluginToolStripMenuItem.DropDownItems.Count > 0;
emailToolStripMenuItem.Enabled = MapiMailMessage.HasMAPIorOutlook();
// This is a "work-around" for the MouseWheel event which doesn't get to the panel
this.MouseWheel += new MouseEventHandler( PanelMouseWheel);
}
private void ReloadConfiguration(object source, FileSystemEventArgs e) {
this.Invoke((MethodInvoker) delegate {
// Even update language when needed
updateUI();
});
}
private void updateUI() {
string editorTitle = lang.GetString(LangKey.editor_title);
if (surface != null && surface.CaptureDetails != null && surface.CaptureDetails.Title != null) {
editorTitle = editorTitle + " - " + surface.CaptureDetails.Title;
}
this.Text = editorTitle;
this.fileStripMenuItem.Text = lang.GetString(LangKey.editor_file);
this.btnSave.Text = lang.GetString(LangKey.editor_save);
this.saveToolStripMenuItem.Text = lang.GetString(LangKey.editor_save);
this.saveAsToolStripMenuItem.Text = lang.GetString(LangKey.editor_saveas);
this.btnClipboard.Text = lang.GetString(LangKey.editor_copyimagetoclipboard);
this.copyImageToClipboardToolStripMenuItem.Text = lang.GetString(LangKey.editor_copyimagetoclipboard);
this.emailToolStripMenuItem.Text = lang.GetString(LangKey.editor_email);
this.btnEmail.Text = lang.GetString(LangKey.editor_email);
this.btnPrint.Text = lang.GetString(LangKey.editor_print);
this.printToolStripMenuItem.Text = lang.GetString(LangKey.editor_print)+"...";
this.closeToolStripMenuItem.Text = lang.GetString(LangKey.editor_close);
this.editToolStripMenuItem.Text = lang.GetString(LangKey.editor_edit);
this.btnCursor.Text = lang.GetString(LangKey.editor_cursortool);
this.btnRect.Text = lang.GetString(LangKey.editor_drawrectangle);
this.addRectangleToolStripMenuItem.Text = lang.GetString(LangKey.editor_drawrectangle);
this.btnEllipse.Text = lang.GetString(LangKey.editor_drawellipse);
this.addEllipseToolStripMenuItem.Text = lang.GetString(LangKey.editor_drawellipse);
this.btnText.Text = lang.GetString(LangKey.editor_drawtextbox);
this.addTextBoxToolStripMenuItem.Text = lang.GetString(LangKey.editor_drawtextbox);
this.btnLine.Text = lang.GetString(LangKey.editor_drawline);
this.drawLineToolStripMenuItem.Text = lang.GetString(LangKey.editor_drawline);
this.btnArrow.Text = lang.GetString(LangKey.editor_drawarrow);
this.drawArrowToolStripMenuItem.Text = lang.GetString(LangKey.editor_drawarrow);
this.btnHighlight.Text = lang.GetString(LangKey.editor_drawhighlighter);
this.selectAllToolStripMenuItem.Text = lang.GetString(LangKey.editor_selectall);
this.btnObfuscate.Text = lang.GetString(LangKey.editor_obfuscate);
this.btnCrop.Text = lang.GetString(LangKey.editor_crop);
this.btnDelete.Text = lang.GetString(LangKey.editor_deleteelement);
this.removeObjectToolStripMenuItem.Text = lang.GetString(LangKey.editor_deleteelement);
this.btnSettings.Text = lang.GetString(LangKey.contextmenu_settings);
this.preferencesToolStripMenuItem.Text = lang.GetString(LangKey.contextmenu_settings);
this.objectToolStripMenuItem.Text = lang.GetString(LangKey.editor_object);
this.btnCut.Text = lang.GetString(LangKey.editor_cuttoclipboard);
this.cutToolStripMenuItem.Text = lang.GetString(LangKey.editor_cuttoclipboard);
this.btnCopy.Text = lang.GetString(LangKey.editor_copytoclipboard);
this.copyToolStripMenuItem.Text = lang.GetString(LangKey.editor_copytoclipboard);
this.btnPaste.Text = lang.GetString(LangKey.editor_pastefromclipboard);
this.pasteToolStripMenuItem.Text = lang.GetString(LangKey.editor_pastefromclipboard);
this.duplicateToolStripMenuItem.Text = lang.GetString(LangKey.editor_duplicate);
this.arrangeToolStripMenuItem.Text = lang.GetString(LangKey.editor_arrange);
this.upToTopToolStripMenuItem.Text = lang.GetString(LangKey.editor_uptotop);
this.upOneLevelToolStripMenuItem.Text = lang.GetString(LangKey.editor_uponelevel);
this.downOneLevelToolStripMenuItem.Text = lang.GetString(LangKey.editor_downonelevel);
this.downToBottomToolStripMenuItem.Text = lang.GetString(LangKey.editor_downtobottom);
this.btnLineColor.Text = lang.GetString(LangKey.editor_forecolor);
this.btnFillColor.Text = lang.GetString(LangKey.editor_backcolor);
this.lineThicknessLabel.Text = lang.GetString(LangKey.editor_thickness);
this.arrowHeadsDropDownButton.Text = lang.GetString(LangKey.editor_arrowheads);
this.helpToolStripMenuItem.Text = lang.GetString(LangKey.contextmenu_help);
this.helpToolStripMenuItem1.Text = lang.GetString(LangKey.contextmenu_help);
this.btnHelp.Text = lang.GetString(LangKey.contextmenu_help);
this.aboutToolStripMenuItem.Text = lang.GetString(LangKey.contextmenu_about);
this.copyPathMenuItem.Text = lang.GetString(LangKey.editor_copypathtoclipboard);
this.openDirectoryMenuItem.Text = lang.GetString(LangKey.editor_opendirinexplorer);
this.obfuscateModeButton.Text = lang.GetString(LangKey.editor_obfuscate_mode);
this.highlightModeButton.Text = lang.GetString(LangKey.editor_highlight_mode);
this.pixelizeToolStripMenuItem.Text = lang.GetString(LangKey.editor_obfuscate_pixelize);
this.blurToolStripMenuItem.Text = lang.GetString(LangKey.editor_obfuscate_blur);
this.textHighlightMenuItem.Text = lang.GetString(LangKey.editor_highlight_text);
this.areaHighlightMenuItem.Text = lang.GetString(LangKey.editor_highlight_area);
this.grayscaleHighlightMenuItem.Text = lang.GetString(LangKey.editor_highlight_grayscale);
this.magnifyMenuItem.Text = lang.GetString(LangKey.editor_highlight_magnify);
this.blurRadiusLabel.Text = lang.GetString(LangKey.editor_blur_radius);
this.brightnessLabel.Text = lang.GetString(LangKey.editor_brightness);
this.previewQualityLabel.Text = lang.GetString(LangKey.editor_preview_quality);
this.magnificationFactorLabel.Text = lang.GetString(LangKey.editor_magnification_factor);
this.pixelSizeLabel.Text = lang.GetString(LangKey.editor_pixel_size);
this.arrowHeadsLabel.Text = lang.GetString(LangKey.editor_arrowheads);
this.arrowHeadStartMenuItem.Text = lang.GetString(LangKey.editor_arrowheads_start);
this.arrowHeadEndMenuItem.Text = lang.GetString(LangKey.editor_arrowheads_end);
this.arrowHeadBothMenuItem.Text = lang.GetString(LangKey.editor_arrowheads_both);
this.arrowHeadNoneMenuItem.Text = lang.GetString(LangKey.editor_arrowheads_none);
this.shadowButton.Text = lang.GetString(LangKey.editor_shadow);
this.fontSizeLabel.Text = lang.GetString(LangKey.editor_fontsize);
this.fontBoldButton.Text = lang.GetString(LangKey.editor_bold);
this.fontItalicButton.Text = lang.GetString(LangKey.editor_italic);
this.btnConfirm.Text = lang.GetString(LangKey.editor_confirm);
this.btnCancel.Text = lang.GetString(LangKey.editor_cancel);
this.saveElementsToolStripMenuItem.Text = lang.GetString(LangKey.editor_save_objects);
this.loadElementsToolStripMenuItem.Text = lang.GetString(LangKey.editor_load_objects);
}
public ISurface Surface {
get {return surface;}
}
public void SetImagePath(string fullpath) {
this.lastSaveFullPath = fullpath;
if (fullpath == null) {
return;
}
updateStatusLabel(lang.GetFormattedString(LangKey.editor_imagesaved,fullpath),fileSavedStatusContextMenu);
this.Text = lang.GetString(LangKey.editor_title) + " - " + Path.GetFileName(fullpath);
}
void surface_DrawingModeChanged(object source, DrawingModes drawingMode) {
switch (drawingMode) {
case DrawingModes.None:
SetButtonChecked(btnCursor);
break;
case DrawingModes.Ellipse:
SetButtonChecked(btnEllipse);
break;
case DrawingModes.Rect:
SetButtonChecked(btnRect);
break;
case DrawingModes.Text:
SetButtonChecked(btnText);
break;
case DrawingModes.Line:
SetButtonChecked(btnLine);
break;
case DrawingModes.Arrow:
SetButtonChecked(btnArrow);
break;
case DrawingModes.Crop:
SetButtonChecked(btnCrop);
break;
case DrawingModes.Highlight:
SetButtonChecked(btnHighlight);
break;
case DrawingModes.Obfuscate:
SetButtonChecked(btnObfuscate);
break;
}
}
#region plugin interfaces
/**
* Interfaces for plugins, see GreenshotInterface for more details!
*/
public Image GetImageForExport() {
return surface.GetImageForExport();
}
public ICaptureDetails CaptureDetails {
get { return surface.CaptureDetails; }
}
public void SaveToStream(Stream stream, OutputFormat extension, int quality) {
using (Image image = surface.GetImageForExport()) {
ImageOutput.SaveToStream(image, stream, extension, quality);
}
}
public ToolStripMenuItem GetPluginMenuItem() {
return pluginToolStripMenuItem;
}
public ToolStripMenuItem GetFileMenuItem() {
return fileStripMenuItem;
}
#endregion
#region filesystem options
void SaveToolStripMenuItemClick(object sender, System.EventArgs e) {
// Use SaveAs if we didn't save before
if (lastSaveFullPath == null) {
SaveAsToolStripMenuItemClick(sender,e);
return;
}
try {
using (Image img = surface.GetImageForExport()) {
ImageOutput.Save(img, lastSaveFullPath);
surface.Modified = false;
}
updateStatusLabel(lang.GetFormattedString(LangKey.editor_imagesaved,lastSaveFullPath),fileSavedStatusContextMenu);
} catch(Exception) {
MessageBox.Show(lang.GetFormattedString(LangKey.error_nowriteaccess,lastSaveFullPath).Replace(@"\\",@"\"), lang.GetString(LangKey.error));
}
}
void BtnSaveClick(object sender, EventArgs e) {
if (lastSaveFullPath != null) {
SaveToolStripMenuItemClick(sender,e);
} else {
SaveAsToolStripMenuItemClick(sender, e);
}
}
void SaveAsToolStripMenuItemClick(object sender, EventArgs eventArgs) {
try {
using (Image img = surface.GetImageForExport()) {
// Bug #2918756 don't overwrite lastSaveFullPath if SaveWithDialog returns null!
string savedTo = ImageOutput.SaveWithDialog(img, surface.CaptureDetails);
if (savedTo != null) {
surface.Modified = false;
lastSaveFullPath = savedTo;
}
}
if(lastSaveFullPath != null) {
SetImagePath(lastSaveFullPath);
updateStatusLabel(lang.GetFormattedString(LangKey.editor_imagesaved,lastSaveFullPath),fileSavedStatusContextMenu);
} else {
clearStatusLabel();
}
} catch (Exception e) {
LOG.Error(lang.GetString(LangKey.error_save), e);
MessageBox.Show(lang.GetString(LangKey.error_save), lang.GetString(LangKey.error));
}
}
void CopyImageToClipboardToolStripMenuItemClick(object sender, System.EventArgs e) {
try {
using (Image img = surface.GetImageForExport()) {
ClipboardHelper.SetClipboardData(img);
surface.Modified = false;
}
updateStatusLabel(lang.GetString(LangKey.editor_storedtoclipboard));
} catch (Exception) {
updateStatusLabel(lang.GetString(LangKey.editor_clipboardfailed));
}
}
void BtnClipboardClick(object sender, EventArgs e) {
this.CopyImageToClipboardToolStripMenuItemClick(sender, e);
}
void PrintToolStripMenuItemClick(object sender, EventArgs e) {
InvokePrint();
}
void BtnPrintClick(object sender, EventArgs e) {
// commented for now: workaround seems to have issues on Vista :(
//new ShowPrintDialogDelegate(InvokePrint).BeginInvoke(null,null);
InvokePrint();
}
void InvokePrint() {
using(Image img = surface.GetImageForExport()) {
PrintHelper ph = new PrintHelper(img, surface.CaptureDetails);
this.Hide();
this.Show();
PrinterSettings ps = ph.PrintWithDialog();
if(ps != null) {
surface.Modified = false;
updateStatusLabel(lang.GetFormattedString(LangKey.editor_senttoprinter,ps.PrinterName));
}
}
}
void CloseToolStripMenuItemClick(object sender, System.EventArgs e) {
this.Close();
}
#endregion
#region drawing options
void BtnEllipseClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.Ellipse;
refreshFieldControls();
}
void BtnCursorClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.None;
refreshFieldControls();
}
void BtnRectClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.Rect;
refreshFieldControls();
}
void BtnTextClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.Text;
refreshFieldControls();
}
void BtnLineClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.Line;
refreshFieldControls();
}
void BtnArrowClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.Arrow;
refreshFieldControls();
}
void BtnCropClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.Crop;
refreshFieldControls();
}
void BtnHighlightClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.Highlight;
refreshFieldControls();
}
void BtnObfuscateClick(object sender, EventArgs e) {
surface.DrawingMode = DrawingModes.Obfuscate;
refreshFieldControls();
}
void SetButtonChecked(ToolStripButton btn) {
UncheckAllToolButtons();
btn.Checked = true;
}
private void UncheckAllToolButtons() {
if (toolbarButtons != null) {
foreach (ToolStripButton butt in toolbarButtons) {
butt.Checked = false;
}
}
}
void AddRectangleToolStripMenuItemClick(object sender, System.EventArgs e) {
BtnRectClick(sender, e);
}
void AddEllipseToolStripMenuItemClick(object sender, System.EventArgs e) {
BtnEllipseClick(sender, e);
}
void AddTextBoxToolStripMenuItemClick(object sender, System.EventArgs e) {
BtnTextClick(sender, e);
}
void DrawLineToolStripMenuItemClick(object sender, System.EventArgs e) {
BtnLineClick(sender, e);
}
void DrawArrowToolStripMenuItemClick(object sender, EventArgs e) {
BtnArrowClick(sender, e);
}
void DrawHighlightToolStripMenuItemClick(object sender, EventArgs e) {
BtnHighlightClick(sender, e);
}
void BlurToolStripMenuItemClick(object sender, EventArgs e) {
BtnObfuscateClick(sender, e);
}
void RemoveObjectToolStripMenuItemClick(object sender, System.EventArgs e) {
surface.RemoveSelectedElements();
}
void BtnDeleteClick(object sender, EventArgs e) {
RemoveObjectToolStripMenuItemClick(sender, e);
}
#endregion
#region copy&paste options
void CutToolStripMenuItemClick(object sender, System.EventArgs e) {
surface.CutSelectedElements();
updateClipboardSurfaceDependencies();
}
void BtnCutClick(object sender, System.EventArgs e) {
CutToolStripMenuItemClick(sender, e);
}
void CopyToolStripMenuItemClick(object sender, System.EventArgs e) {
surface.CopySelectedElements();
updateClipboardSurfaceDependencies();
}
void BtnCopyClick(object sender, System.EventArgs e) {
CopyToolStripMenuItemClick(sender, e);
}
void PasteToolStripMenuItemClick(object sender, System.EventArgs e) {
surface.PasteElementFromClipboard();
updateClipboardSurfaceDependencies();
}
void BtnPasteClick(object sender, System.EventArgs e) {
PasteToolStripMenuItemClick(sender, e);
}
void DuplicateToolStripMenuItemClick(object sender, System.EventArgs e) {
surface.DuplicateSelectedElements();
updateClipboardSurfaceDependencies();
}
#endregion
#region element properties
void UpOneLevelToolStripMenuItemClick(object sender, EventArgs e) {
surface.PullElementsUp();
}
void DownOneLevelToolStripMenuItemClick(object sender, EventArgs e) {
surface.PushElementsDown();
}
void UpToTopToolStripMenuItemClick(object sender, EventArgs e) {
surface.PullElementsToTop();
}
void DownToBottomToolStripMenuItemClick(object sender, EventArgs e) {
surface.PushElementsToBottom();
}
#endregion
#region help
void HelpToolStripMenuItem1Click(object sender, System.EventArgs e) {
new HelpBrowserForm(coreConf.Language).Show();
}
void AboutToolStripMenuItemClick(object sender, System.EventArgs e) {
new AboutForm().Show();
}
void PreferencesToolStripMenuItemClick(object sender, System.EventArgs e) {
new SettingsForm().Show();
}
void BtnSettingsClick(object sender, System.EventArgs e) {
PreferencesToolStripMenuItemClick(sender, e);
}
void BtnHelpClick(object sender, System.EventArgs e) {
HelpToolStripMenuItem1Click(sender, e);
}
#endregion
#region image editor event handlers
void ImageEditorFormActivated(object sender, EventArgs e) {
updateClipboardSurfaceDependencies();
}
void ImageEditorFormFormClosing(object sender, FormClosingEventArgs e) {
IniConfig.IniChanged -= new FileSystemEventHandler(ReloadConfiguration);
if (surface.Modified) {
// Make sure the editor is visible
WindowDetails.ToForeground(this.Handle);
MessageBoxButtons buttons = MessageBoxButtons.YesNoCancel;
// Dissallow "CANCEL" if the application needs to shutdown
if (e.CloseReason == CloseReason.ApplicationExitCall || e.CloseReason == CloseReason.WindowsShutDown || e.CloseReason == CloseReason.TaskManagerClosing) {
buttons = MessageBoxButtons.YesNo;
}
DialogResult result = MessageBox.Show(lang.GetString(LangKey.editor_close_on_save), lang.GetString(LangKey.editor_close_on_save_title), buttons, MessageBoxIcon.Question);
if (result.Equals(DialogResult.Cancel)) {
e.Cancel = true;
return;
}
if (result.Equals(DialogResult.Yes)) {
if (lastSaveFullPath != null) {
SaveToolStripMenuItemClick(sender,e);
} else {
SaveAsToolStripMenuItemClick(sender, e);
}
// Check if the save was made, if not it was cancelled so we cancel the closing
if (surface.Modified) {
e.Cancel = true;
return;
}
}
}
// persist our geometry string.
editorConfiguration.SetEditorPlacement(new WindowDetails(this.Handle).GetWindowPlacement());
IniConfig.Save();
surface.Dispose();
System.GC.Collect();
}
void ImageEditorFormKeyDown(object sender, KeyEventArgs e) {
// LOG.Debug("Got key event "+e.KeyCode + ", " + e.Modifiers);
// avoid conflict with other shortcuts and
// make sure there's no selected element claiming input focus
if(e.Modifiers.Equals(Keys.None) && !surface.KeysLocked) {
if (Keys.Escape.Equals(e.KeyCode)) {
BtnCursorClick(sender, e);
} else if (Keys.R.Equals(e.KeyCode)) {
BtnRectClick(sender, e);
} else if (Keys.E.Equals(e.KeyCode)) {
BtnEllipseClick(sender, e);
} else if (Keys.L.Equals(e.KeyCode)) {
BtnLineClick(sender, e);
} else if (Keys.A.Equals(e.KeyCode)) {
BtnArrowClick(sender, e);
} else if (Keys.T.Equals(e.KeyCode)) {
BtnTextClick(sender, e);
} else if(Keys.H.Equals(e.KeyCode)) {
BtnHighlightClick(sender, e);
} else if(Keys.O.Equals(e.KeyCode)) {
BtnObfuscateClick(sender, e);
} else if(Keys.C.Equals(e.KeyCode)) {
BtnCropClick(sender, e);
}
}
}
/// <summary>
/// This is a "work-around" for the MouseWheel event which doesn't get to the panel
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void PanelMouseWheel(object sender, MouseEventArgs e) {
panel1.Focus();
}
#endregion
#region cursor key strokes
protected override bool ProcessCmdKey(ref Message msg, Keys k) {
// disable default key handling if surface has requested a lock
if(!surface.KeysLocked) {
surface.ProcessCmdKey(k);
return base.ProcessCmdKey(ref msg, k);
}
return false;
}
#endregion
#region helpers
private void updateClipboardSurfaceDependencies() {
// check dependencies for the Surface
bool hasItems = surface.HasSelectedElements();
bool actionAllowedForSelection = hasItems && !controlsDisabledDueToConfirmable;
this.cutToolStripMenuItem.Enabled = actionAllowedForSelection;
this.btnCut.Enabled = actionAllowedForSelection;
this.btnCopy.Enabled = actionAllowedForSelection;
this.copyToolStripMenuItem.Enabled = actionAllowedForSelection;
this.duplicateToolStripMenuItem.Enabled = actionAllowedForSelection;
// check dependencies for the Clipboard
bool hasClipboard = ClipboardHelper.ContainsFormat(SUPPORTED_CLIPBOARD_FORMATS);
this.btnPaste.Enabled = hasClipboard && !controlsDisabledDueToConfirmable;
this.pasteToolStripMenuItem.Enabled = hasClipboard && !controlsDisabledDueToConfirmable;
}
#endregion
#region status label handling
private void updateStatusLabel(string text, ContextMenuStrip contextMenu) {
statusLabel.Text = text;
statusStrip1.ContextMenuStrip = contextMenu;
}
private void updateStatusLabel(string text) {
updateStatusLabel(text, null);
}
private void clearStatusLabel() {
updateStatusLabel(null, null);
}
void StatusLabelClicked(object sender, MouseEventArgs e) {
ToolStrip ss = (StatusStrip)((ToolStripStatusLabel)sender).Owner;
if(ss.ContextMenuStrip != null) {
ss.ContextMenuStrip.Show(ss, e.X, e.Y);
}
}
void CopyPathMenuItemClick(object sender, EventArgs e) {
Clipboard.SetText(lastSaveFullPath);
}
void OpenDirectoryMenuItemClick(object sender, EventArgs e) {
ProcessStartInfo psi = new ProcessStartInfo("explorer");
psi.Arguments = Path.GetDirectoryName(lastSaveFullPath);
psi.UseShellExecute = false;
Process p = new Process();
p.StartInfo = psi;
p.Start();
}
#endregion
private void bindFieldControls() {
new BidirectionalBinding(btnFillColor, "SelectedColor", surface.FieldAggregator.GetField(FieldType.FILL_COLOR), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(btnLineColor, "SelectedColor", surface.FieldAggregator.GetField(FieldType.LINE_COLOR), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(lineThicknessUpDown, "Value", surface.FieldAggregator.GetField(FieldType.LINE_THICKNESS), "Value", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance());
new BidirectionalBinding(blurRadiusUpDown, "Value", surface.FieldAggregator.GetField(FieldType.BLUR_RADIUS), "Value", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance());
new BidirectionalBinding(magnificationFactorUpDown, "Value", surface.FieldAggregator.GetField(FieldType.MAGNIFICATION_FACTOR), "Value", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance());
new BidirectionalBinding(pixelSizeUpDown, "Value", surface.FieldAggregator.GetField(FieldType.PIXEL_SIZE), "Value", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance());
new BidirectionalBinding(brightnessUpDown, "Value", surface.FieldAggregator.GetField(FieldType.BRIGHTNESS), "Value", DecimalDoublePercentageConverter.GetInstance(), NotNullValidator.GetInstance());
new BidirectionalBinding(fontFamilyComboBox, "Text", surface.FieldAggregator.GetField(FieldType.FONT_FAMILY), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(fontSizeUpDown, "Value", surface.FieldAggregator.GetField(FieldType.FONT_SIZE), "Value", DecimalFloatConverter.GetInstance(), NotNullValidator.GetInstance());
new BidirectionalBinding(fontBoldButton, "Checked", surface.FieldAggregator.GetField(FieldType.FONT_BOLD), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(fontItalicButton, "Checked", surface.FieldAggregator.GetField(FieldType.FONT_ITALIC), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(shadowButton, "Checked", surface.FieldAggregator.GetField(FieldType.SHADOW), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(previewQualityUpDown, "Value", surface.FieldAggregator.GetField(FieldType.PREVIEW_QUALITY), "Value", DecimalDoublePercentageConverter.GetInstance(), NotNullValidator.GetInstance());
new BidirectionalBinding(obfuscateModeButton, "SelectedTag", surface.FieldAggregator.GetField(FieldType.PREPARED_FILTER_OBFUSCATE), "Value");
new BidirectionalBinding(highlightModeButton, "SelectedTag", surface.FieldAggregator.GetField(FieldType.PREPARED_FILTER_HIGHLIGHT), "Value");
}
/// <summary>
/// shows/hides field controls (2nd toolbar on top) depending on fields of selected elements
/// </summary>
private void refreshFieldControls() {
propertiesToolStrip.SuspendLayout();
if(surface.HasSelectedElements() || surface.DrawingMode != DrawingModes.None) {
FieldAggregator props = surface.FieldAggregator;
btnFillColor.Visible = props.HasFieldValue(FieldType.FILL_COLOR);
btnLineColor.Visible = props.HasFieldValue(FieldType.LINE_COLOR);
lineThicknessLabel.Visible = lineThicknessUpDown.Visible = props.HasFieldValue(FieldType.LINE_THICKNESS);
blurRadiusLabel.Visible = blurRadiusUpDown.Visible = props.HasFieldValue(FieldType.BLUR_RADIUS);
previewQualityLabel.Visible = previewQualityUpDown.Visible = props.HasFieldValue(FieldType.PREVIEW_QUALITY);
magnificationFactorLabel.Visible = magnificationFactorUpDown.Visible = props.HasFieldValue(FieldType.MAGNIFICATION_FACTOR);
pixelSizeLabel.Visible = pixelSizeUpDown.Visible = props.HasFieldValue(FieldType.PIXEL_SIZE);
brightnessLabel.Visible = brightnessUpDown.Visible = props.HasFieldValue(FieldType.BRIGHTNESS);
arrowHeadsLabel.Visible = arrowHeadsDropDownButton.Visible = props.HasFieldValue(FieldType.ARROWHEADS);
fontFamilyComboBox.Visible = props.HasFieldValue(FieldType.FONT_FAMILY);
fontSizeLabel.Visible = fontSizeUpDown.Visible = props.HasFieldValue(FieldType.FONT_SIZE);
fontBoldButton.Visible = props.HasFieldValue(FieldType.FONT_BOLD);
fontItalicButton.Visible = props.HasFieldValue(FieldType.FONT_ITALIC);
shadowButton.Visible = props.HasFieldValue(FieldType.SHADOW);
btnConfirm.Visible = btnCancel.Visible = props.HasFieldValue(FieldType.FLAGS)
&& ((FieldType.Flag)props.GetFieldValue(FieldType.FLAGS)&FieldType.Flag.CONFIRMABLE) == FieldType.Flag.CONFIRMABLE;
obfuscateModeButton.Visible = props.HasFieldValue(FieldType.PREPARED_FILTER_OBFUSCATE);
highlightModeButton.Visible = props.HasFieldValue(FieldType.PREPARED_FILTER_HIGHLIGHT);
} else {
foreach(ToolStripItem c in propertiesToolStrip.Items) {
c.Visible = false;
}
}
propertiesToolStrip.ResumeLayout();
}
/// <summary>
/// refreshes all editor controls depending on selected elements and their fields
/// </summary>
private void refreshEditorControls() {
FieldAggregator props = surface.FieldAggregator;
// if a confirmable element is selected, we must disable most of the controls
// since we demand confirmation or cancel for confirmable element
if (props.HasFieldValue(FieldType.FLAGS) && ((FieldType.Flag)props.GetFieldValue(FieldType.FLAGS) & FieldType.Flag.CONFIRMABLE) == FieldType.Flag.CONFIRMABLE) {
// disable most controls
if(!controlsDisabledDueToConfirmable) {
ToolStripItemEndisabler.Disable(menuStrip1);
ToolStripItemEndisabler.Disable(toolStrip1);
ToolStripItemEndisabler.Disable(toolStrip2);
ToolStripItemEndisabler.Enable(closeToolStripMenuItem);
ToolStripItemEndisabler.Enable(helpToolStripMenuItem);
ToolStripItemEndisabler.Enable(aboutToolStripMenuItem);
ToolStripItemEndisabler.Enable(preferencesToolStripMenuItem);
controlsDisabledDueToConfirmable = true;
}
} else if(controlsDisabledDueToConfirmable) {
// re-enable disabled controls, confirmable element has either been confirmed or cancelled
ToolStripItemEndisabler.Enable(menuStrip1);
ToolStripItemEndisabler.Enable(toolStrip1);
ToolStripItemEndisabler.Enable(toolStrip2);
controlsDisabledDueToConfirmable = false;
}
// en/disable controls depending on whether an element is selected at all
bool actionAllowedForSelection = surface.HasSelectedElements() && !controlsDisabledDueToConfirmable;
this.btnCopy.Enabled = actionAllowedForSelection;
this.btnCut.Enabled = actionAllowedForSelection;
this.btnDelete.Enabled = actionAllowedForSelection;
this.copyToolStripMenuItem.Enabled = actionAllowedForSelection;
this.cutToolStripMenuItem.Enabled = actionAllowedForSelection;
this.duplicateToolStripMenuItem.Enabled = actionAllowedForSelection;
this.removeObjectToolStripMenuItem.Enabled = actionAllowedForSelection;
// en/disablearrage controls depending on hierarchy of selected elements
bool push = actionAllowedForSelection && surface.CanPushSelectionDown();
bool pull = actionAllowedForSelection && surface.CanPullSelectionUp();
this.arrangeToolStripMenuItem.Enabled = (push || pull);
if (this.arrangeToolStripMenuItem.Enabled) {
this.upToTopToolStripMenuItem.Enabled = pull;
this.upOneLevelToolStripMenuItem.Enabled = pull;
this.downToBottomToolStripMenuItem.Enabled = push;
this.downOneLevelToolStripMenuItem.Enabled = push;
}
// finally show/hide field controls depending on the fields of selected elements
refreshFieldControls();
}
void ArrowHeadsToolStripMenuItemClick(object sender, EventArgs e) {
surface.FieldAggregator.GetField(FieldType.ARROWHEADS).Value = (ArrowContainer.ArrowHeadCombination)((ToolStripMenuItem)sender).Tag;
}
void EditToolStripMenuItemClick(object sender, EventArgs e) {
updateClipboardSurfaceDependencies();
}
void FontPropertyChanged(object sender, EventArgs e) {
// in case we forced another FontStyle before, reset it first.
if(originalBoldCheckState != fontBoldButton.Checked) fontBoldButton.Checked = originalBoldCheckState;
if(originalItalicCheckState != fontItalicButton.Checked) fontItalicButton.Checked = originalItalicCheckState;
FontFamily fam = fontFamilyComboBox.FontFamily;
bool boldAvailable = fam.IsStyleAvailable(FontStyle.Bold);
if(!boldAvailable) {
originalBoldCheckState = fontBoldButton.Checked;
fontBoldButton.Checked = false;
}
fontBoldButton.Enabled = boldAvailable;
bool italicAvailable = fam.IsStyleAvailable(FontStyle.Italic);
if(!italicAvailable) fontItalicButton.Checked = false;
fontItalicButton.Enabled = italicAvailable;
bool regularAvailable = fam.IsStyleAvailable(FontStyle.Regular);
if(!regularAvailable) {
if(boldAvailable) {
fontBoldButton.Checked = true;
} else if(italicAvailable) {
fontItalicButton.Checked = true;
}
}
}
void FieldAggregatorFieldChanged(object sender, FieldChangedEventArgs e) {
// in addition to selection, deselection of elements, we need to
// refresh toolbar if prepared filter mode is changed
if(e.Field.FieldType == FieldType.PREPARED_FILTER_HIGHLIGHT) {
refreshFieldControls();
}
}
void FontBoldButtonClick(object sender, EventArgs e) {
originalBoldCheckState = fontBoldButton.Checked;
}
void FontItalicButtonClick(object sender, System.EventArgs e) {
originalItalicCheckState = fontItalicButton.Checked;
}
void ToolBarFocusableElementGotFocus(object sender, System.EventArgs e) {
surface.KeysLocked = true;
}
void ToolBarFocusableElementLostFocus(object sender, System.EventArgs e) {
surface.KeysLocked = false;
}
void SaveElementsToolStripMenuItemClick(object sender, EventArgs e) {
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Greenshot templates (*.gst)|*.gst";
saveFileDialog.FileName = FilenameHelper.GetFilenameWithoutExtensionFromPattern(coreConf.OutputFileFilenamePattern, surface.CaptureDetails);
DialogResult dialogResult = saveFileDialog.ShowDialog();
if(dialogResult.Equals(DialogResult.OK)) {
using (Stream streamWrite = File.OpenWrite(saveFileDialog.FileName)) {
surface.SaveElementsToStream(streamWrite);
}
}
}
void LoadElementsToolStripMenuItemClick(object sender, EventArgs e) {
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Greenshot templates (*.gst)|*.gst";
if (openFileDialog.ShowDialog() == DialogResult.OK) {
using (Stream streamRead = File.OpenRead(openFileDialog.FileName)) {
surface.LoadElementsFromStream(streamRead);
}
surface.Refresh();
}
}
void EmailToolStripMenuItemClick(object sender, EventArgs e) {
using (Image img = surface.GetImageForExport()) {
MapiMailMessage.SendImage(img, surface.CaptureDetails);
surface.Modified = false;
}
}
void BtnEmailClick(object sender, EventArgs e) {
EmailToolStripMenuItemClick(sender, e);
}
protected void FilterPresetDropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) {
refreshFieldControls();
}
void SelectAllToolStripMenuItemClick(object sender, EventArgs e) {
surface.SelectAllElements();
}
void BtnConfirmClick(object sender, EventArgs e) {
surface.ConfirmSelectedConfirmableElements(true);
refreshFieldControls();
}
void BtnCancelClick(object sender, EventArgs e) {
surface.ConfirmSelectedConfirmableElements(false);
refreshFieldControls();
}
void Insert_window_toolstripmenuitemMouseEnter(object sender, EventArgs e) {
ToolStripMenuItem captureWindowMenuItem = (ToolStripMenuItem)sender;
MainForm.AddCaptureWindowMenuItems(captureWindowMenuItem, Contextmenu_window_Click);
}
void Contextmenu_window_Click(object sender, EventArgs e) {
ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
try {
WindowDetails windowToCapture = (WindowDetails)clickedItem.Tag;
ICapture capture = new Capture();
using (Graphics graphics = Graphics.FromHwnd(this.Handle)) {
capture.CaptureDetails.DpiX = graphics.DpiY;
capture.CaptureDetails.DpiY = graphics.DpiY;
}
windowToCapture.Restore();
windowToCapture = CaptureForm.SelectCaptureWindow(windowToCapture);
if (windowToCapture != null) {
capture = CaptureForm.CaptureWindow(windowToCapture, capture, coreConf.WindowCaptureMode);
this.Activate();
WindowDetails.ToForeground(this.Handle);
if (capture!= null && capture.Image != null) {
surface.AddBitmapContainer((Bitmap)capture.Image, 100, 100);
}
}
if (capture!= null) {
capture.Dispose();
}
} catch (Exception exception) {
LOG.Error(exception);
}
}
}
}

View file

@ -0,0 +1,863 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="btnCursor.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAVVJREFUOE9jZkAC
YWFhvpqamizXrl17jSxONDsgICCjqKioOiQkRItoTcgKgQZk/geC/Pz8Gl9fX22SDfH09MwGGQACWVlZ
tSQb4ubmlgszAERnZGTUu7q66hDtEicnp3xkA0DslJSURmdnZ12iDLGxsSlENwDEj4+PbwbK6RE0xNLS
shibASCxqKioFnNzc/yGmJiYlOIyACQeHh7eZmBgoI/TJXp6ehXIBnz69Omrg4NDPUgchoEGROE0QF1d
vQpkwPPnz993dnauBLHnzp27U1VVFbetyKYpKCjUgTQDo64fyI4/f/78nQ8fPnwzMjLKV1FRYScYiJKS
ko329vYTZWRkdMXExMSBATcD5IopU6bslZKSMiRogJCQULKoqCjcuUB+8JkzZ+6BXCErK1tI0AB0BVxc
XBLA/DEb5AqgNyaTbABIg7CwsB8wBqZycHDYYTMAALM46JYWd6MAAAAAAElFTkSuQmCC
</value>
</data>
<data name="btnRect.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAaFJREFUOE9jYKAU
GJftMTMu25UDook1C0WPYcnu3P///58B0UalO6KJwch6GIzKdlkYlO7Kn7nz7sKX776fIgaD1IL0gPSC
XW1QsiPuxbvvJ++/+rqbGAxSC9ID97J+0faEp++/H7/z/NMOYjBILUgP3ACdwq2Jj15/OXrzyadtyPjy
4w8bTtx+s3j/5Zczdpx/NnHzmad9IHz67rvlID1wA7TzNibff/Hl0JVH7zeD8Lm7H9btvfJyzsbTTyas
O/m0D4KfwPGRG2+WgvTADdDK35x6+8WXA+cffNgAktx4+umUdSeeTFp3CoiRaRAbiA9df70CpAdugHrO
+vSrTz/u23vl1eINp55OA+MTT6diYKjckRuvV4H0wA1Qy1qXCfTX9vWnnsxae/LJzA1oGCQGEwfRR66/
WgfSAzdAOWN19tEbbzYB/ToPhteffDoXhEF8dDZQ7UaQHrABSmnLnRVSVrSULzy75PD1N1tAGBgOm5Fp
mDhMDKQWpAekl0E6flEvKCmDaKn4xaXEYGQ9DCIRc7xFwmdPBdHEZiZy9OA0GwCftfffWErtOQAAAABJ
RU5ErkJggg==
</value>
</data>
<data name="btnEllipse.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAhNJREFUOE9jZMAB
jMv2mDEw/ANiplNnu1xO4VKHIa5fvl3BqGyXt2HJ7tz///+fAdGGZbsSQWIgOZwG2dfvZzEs3eXs234o
c8nhh5Nm77m9xKB4Z960nXcWPn7zbSNIDCQHUgNSi2GQYckOj8L550sfv/266/GbLwfuv/q6GxmDxEBy
IDUgtSgG6BTt0AjuPpr3+NXXXXeef9oJxDtw4J0gNSC1ID1wQ3QLt0ZtPfdkJkjTraeftuLDIDUgtSA9
YAO08jbZaOdvKe3ffGPp1UcfNiHj8/ferTly49WCHRdeTN145mnf6pOPu0C4cfmlWSA9IL0gAypAoQ2i
Lzz4sB6ET915t2rHheczVh573LPyyEMwXnHkYTcMI+th0MxZb6uZs7Gqff3VJadvv127/8qrhauOPZq4
4uijPmS8/MijfhAGiVUtOz8HpAekF+wN9ewNiauOPpi+9/LLJSuOPpy8/OjDSbjwmuOPpi/cd68PpAce
iOrZ63XdG/eUHbr6cukqoAKgLdOwYZDcoWsvl7g27CwF6UGJSpWMNcEx/QdrjgANAQYY0BsPZ4Hw6uOP
Z4NokBhIDqQGpBYjIRmnzWSVT1sRYFG2sbJ73cVJB688X1g499QSheQVrVULz64EiYHkQGpAanEmaYnY
hZpScYsSpWIX1knGLuwDxRCIBomB5IjOVCCFIhFzvIF4GogmSSMpigET+75j5Br2oAAAAABJRU5ErkJg
gg==
</value>
</data>
<data name="btnLine.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAMZJREFUOE9jNC7b
Y8bA8A+ImU6d7XI5xUAqMCzZnfv///8zIJpUvWD1RmW7LAyKd+YZlO7M0qncI06WISBNpiVbJAxKdsSB
aMoMKd4Wr0WJISDNOoVbEzUKtkuS7RKQZp38zUkUG6JdsClFo2At+S5Rz94gpZG3MQ1Ek+0dkGb17HUZ
FBmimr5SWi1zbRaIJtslIM3K6WtyKDJEJWWtjHzy8gaF5BWtcokrXMhyjWTswj5Q3gHRZBkgEjHHG4in
gWiyDEDXBAAHrU15FHuNuwAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnArrow.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAANVJREFUOE9jNC7b
Y8bA8A+ImU6d7XI5xUAqMCzZnfv///8zIJpUvWD1RmW7LAyKd+YZlO7M0qncI06WISBNpiVbJAxKdsSB
aMoMKd4Wr0WJISDNOoVbEzUKtkuS7RKQZp38zUkUG6JdsClFo2At+S5Rz94gpZG3MQ1Ek+0dkGb17HUZ
MEO08zc3kGyYavpKabXMtVnaeZt7yTIAZCNIs3L6mhwQTbILQLZCcZ988vIGheQVrXKJK1xINgikQTJ2
YR8o74BosgwQiZjjDcTTQDRZBqBrAgCqh1bS2fh/NwAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnText.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAVlJREFUOE9jYKAG
MC7b42pUtiuKFAzSA7fbrGp30uuP3y6+/Pj9FDEYpBakB26AbfXO7Bfvvp/cef75GreGXfUwDBIDYWQx
kBqQGEgP3ADH2l0lrz9+P+dUv7MMJghiP33//TgIo4uD1IL0wA1wb9gV61q/s8alfpcFTBBkw9PXX46C
MLJtIDUgtSA9eMPfvGpnwp0XX/Zde/hpG4hNcmSZlu6OPnTj5dJD114uAbFJNsCkdFfs4etvloEwiE2y
AeaVu1IPXXu9EoRBbJINsK3aUXD4xus1IAxik2SAef56BaeaHdWHr73ZcBSIQWyQGFGGKKWvDVROX5PT
tOJi++6LL1buvvxiJYgNEgPJYRgil7jCRSF5RSuIBkkqpC7Pv/H08/ELDz7sO3b9zRYQPnfvw16QGEgO
wwDJ2IV9////PwOiJWMWlZGCwYaJRMzxBuJpIJooP6IpAgC4RiYACOOwJwAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnHighlight.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAVFJREFUOE/Vkj9r
wlAUxU8wW7e6dUwIzd6CS4cORYQWCoWOrg4OguAHcCw4RNzcRA34B5W6uhRR65BRcBBFUQRR8xVu331t
CpYMceyDxyEv9/y497wH+Kx4/DXrd+57djjg43gECaX9HrTbgTKZF9puQZsNaL0GrVag5RK0WIBmM9yf
gFwX1OmYlM/fUbttSkA6/Sx3o2FKQL1uyu9azaT5HKfdMYA7aLWuKZV6kgBW7oB1NApL9TrwBeRyEXKc
S0omYxLAygDW4TAs1QNMp8gOBrj6HYMzSCQeRJs6sTKAlbdt63KEavX7X6Wi03iMt14PTreLYuCgvcJ+
HzE288iTCVzbRiIw5K+5XIZTKuEmEOCfmlVVvTUM490L7KyZRTBGKBQqWpZFmqZ9nmuGZ1YUpStgaQG4
CJQ2F4lXJu/5x/wY2OgVNptwCgU40WiwO/4CYnsLuFkXhBoAAAAASUVORK5CYII=
</value>
</data>
<data name="btnObfuscate.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgVJREFUOE/FkN1L
U2EcgP0HIugmuukiIYgwjLwxhWqsSGIWlYJJSaasIXOM/OiijRm2IDPIPi7WTWEwsS0tNRS2UrCGsPzI
aZalY9qYOvo64trY9rT33VW0XfvC7+b8nud5zzk5OZt+yk0mzVmzWZtpaqxhsu2EJ1/+lMl0mSzn3LVA
thXCSweamnSJZJKDt6G4HVR3Qd0B+m7QGHxUPwWjA24Ogd0LPVMgeOHJQElDQ10skUDXlQKd0DoIbS54
9A4OXRylYxjujaTlkXkYXwLBC08Gjun1+kg8TuvAW5wTqwx9hMFZ+PAN9p95RW/qxn5fWp5Yhi9rIHjh
yYBKpzMosRiHW6opbTdiH/MxHQT/d9h93IlnIcqY/w+TyzE+r8YJ/koieOHJQHFtrfFHNMqO80XsrddQ
Yq3jzoAD98wsu9TPeD0Xwp2a0a9hpoIKgZ9RBC88GSisqroSjkTYVlrO9tOV5F7QcsDQjN72mNyjLzA/
H+bBGx+dXj+9Myu4FhQELzwZKKioaAxtbFCgtVFU/wR1czcnr/dzwzHJnhNuLC8/ccu1yENPiM7p3/Qs
RpF8ypOBfWVlV4Pr6/8ENJY+WuzjqZ/opbFrDktfgDb3Gvc9Crb3MQQvPBnYqVKZV1LftKQo/01h5XzG
54IXngxszc+v2ZKXZ800Ry6FyLYTngxs+vkLMazwcEy5froAAAAASUVORK5CYII=
</value>
</data>
<data name="btnCrop.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAeFJREFUOE9jZICC
/UksGYz//yuDuItVX5rOrRJxgMkRRe9NZO79e3PZ/19XFv6Pa3j2nyhNIEUgmw8kMnfvTmQ68+vygv/3
N9b9Dy2/8x8khguD9MAtgNl8pc/1/4+L8/5/PjH1v3fuRbBLcGGQHrgBuxOY+0E2X+x2+v/93Oz/d9dV
/7dPPPr/66npYNcg0yA2CIP0wA0wC99zwDR89/+ysPiXX4CS7w72/QfxseH7m+rBLtwVyzwRI4w2RjLP
+nR8yv9bq8r/6/htxAhEkBjIhR+PTvq/LY55CoYBayOZ5344POH/y13t/1Xd12AYABIDeQ/kwi3RzNMx
DFgVzrzg3YHe/9eWFf9XclmNYQBIDOTCN/u6/4Nci2HAslDGJW/2dP5/srnhv7LrOgwDQGI3gd4DuRDk
WgwDFgUzrni1s+3/lYV5QC9sxYpBLny+veV/rHPMO5AaNbctB+AGzfdnXPsCKPkA6M8X25r/X1mUj0Jr
++7/f31pEdiF+8oN/r/Z3fEfpAduwEQvxl3Ptzb9v7emEis2DD79H+TCRxtq/28v1P4PUgvSAzegzZlx
SrMD4zFc2DzyGthVIBdO8WV6C1IH0kN0nrGNf/j/NdAFz7Y0otpMrAlOyS8OwFyHbDMABSyMgqopG4QA
AAAASUVORK5CYII=
</value>
</data>
<data name="saveToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAXJJREFUOE+lk0FL
AkEYhlvwv3jzoiDoQdCbdEnYf6CrqCgoHgRRAk/9EQVLdEGyFiQNMS+dvHnoEkgglGAmCL7NO6RMIZvU
wsMO3zzzzGk0ACf/+hjQNO1ccKlXKsYx0OUZeflXoFmtVsUS2P4CHboi0FQDrXK5jM12i/VmYwsduiLQ
UgNmqVTCuzj8tlrZQoeuCJhqoFMsFvG6XmO2WNhCh64IdNRAt1Ao4EXc/jSf20KHrgh01YCVy+Uwnkzw
vFzaQoeuCFhqoJfJZBCLxY6Crgj01EA/lUrB4/HA7XYfhHs78vk8A301MIzH4/B6vRiNHjAY3H+DM+7p
ug6fz4dsNsvAUA2Mo9Eo/H4/LOsOTqdTYprXEs64x0AwGEQ6nWZgrAYeDcNAIBBAu30r/6Reb0t2MwbC
4TCSySQDj/uAeEyngqnL5fpoNG4QCoUktVpHspsxEIlEkEgk+AKnaoAP8kwwczgcF4fg3g+u9gEu/son
bfJW/NwRDyIAAAAASUVORK5CYII=
</value>
</data>
<data name="copyImageToClipboardToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAYBJREFUOE+NkL1L
QlEYh1+XIlpaGoMiCKSGIoQIopoiaO0faCkaHFoKGhqCwiKQwtCGIkMFcWxvdDlgBFHaxSSszBTLT65f
b/dnXpcThy483MN7nvPcw7UwM+E5nbe03niee6xdid7RJWPZ3x59Dpbur4cqD1XTWb/5PUcIANcceQwE
2JugW++W/S0W0xhgjZm5D9c81wmczJKIulY4tGbjcPiOI5FHjseTLbDGDHtw4EoB50xryF7vFTsch+x2
n7HPF+BgMMTnF5fsdB6z3x+Awm239fHODY6mSTSNSb3Z5CdN+xPswYEr3eBgikTNEPR6XQkcuFJg30ZC
bzS4VK0qgQNXCuxOkijXavxdqSiBA1cK7IyTKBhfzxaLSuDAlQLbYyS+dJ1T+bwSOHClwKaVRNa4fjKX
UwIHrhTYGCGRLpc5kckogQNXCtiHSbyXSqyl00rgwJUCqwMkXo0fGE2llMCBKwWW+0h8GD/opVBQAgeu
FFjsJs9CF4n/ANcM/AD2zO2FV7v8igAAAABJRU5ErkJggg==
</value>
</data>
<data name="printToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAm1JREFUOE+Nkl9I
U1Ecx39T31o9SBq97cWHiUIimKiQ0zFbbcJ1U2YkBtLuFYkQnMrcdKQyEUIwWk+GDy58EfUhmYoTRtKE
HitI8kGZIkEW/oF0um/nd3OyYUnn8rn3nMPn+733wNXYe3spOTQajVXMb55vpE/CiUTiqyB91+b1Ugry
j3gcWwcH2Nzfx8benspsJALhyII8qaeHUiHJ7U5F+Xl0hM3dXXzZ2cGn7W183NpCcG4OPISrmNvbdQZF
IaZOlolsNhvVOZ1U29XFtO4fH+ObeGtqyYuJCSTJM5s9Aqqqr1ez6s1ut5OtqYksHR1tB6Lg++HhhRL+
Ej4OO+yqmbOCDLGwCuSsrKznLpcLl8EOu5wRBRkkSdJ1t9vdtyPOrCgK+vv74fV6L+DxeODz+VQnFouh
u7u7j7NksVj0o6Oj42tra3A4HOjs7ITT6URzczMkqQ7V1UaUl1egpOQ2zOZ7qjM/v4yBgcFxzlJNTU3l
1NTU8urqKoxGowjLMJnMqKioFME7aRiNd1VndnYRIyOBZc6SwWBwRKPR9XA4jKKiIjQ0PBSS9a+YTLWq
4xTX5OTbdc5SWVnZk1AohGAwCJ1OB7v9EazWB/+EnbGxMUxPT4OzVFxc7IpE3mFmJoS2tqcYHg5gaOgl
/P5ACq/E/A+tre1YXPygwlnS6/XupaUVLCysoLGx8b9IFnCWcnJyWrKzsweZzMzMIf5l7weA1++BN9HP
MPhacEv2o8o1iV8nJ2An6XOWxIK0Wi1dy82lG6Wlz9SfPmWcJhJg4qeniIsnO+xyhrPnBVcLC0lbUPD4
Sn6+/zLYUd2zgt/AGvcWHCMAZwAAAABJRU5ErkJggg==
</value>
</data>
<data name="emailToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAn9JREFUOE+lkltI
U3Ecx3879BIq+lThQwUFZSb4UFF2BUcPlYSkQUL2IF5i0W2ZeU+duZ6aVCjWYIkxMrMkcVIqm05jLQVH
NWNKOudlprtg043lvv3/pwtCV+rAh8P5/76f3/lyOJKecoEEgcgU2ke9wb0kkUiSiCg6UpiPWrfCvpUk
RGPBta+9oQgPO/92TQJ4Kj7wBb0KgUzXBHpUuZ7SCs/lsiFCv4DPjubnn2YQZ/mCyFdK4Zji6qHOYCiE
lLtAlhY4VQ/Im4EKHaC3AXyWLJddqi7fTUMqVp01CGMNjtRV7mrS3MmxKW4XLrWaTMi4VY0bLd1QPzej
tt0M9TMzdP1D8AWDKC482MZkKWMlGcqEM8ONiV3ND4sCf6pe166H2++H5n5RwNmR3GpVCScpU55yuUev
QoO2QKw3+HjVV1bD8oTR8uXOZyVNBjgXFlB7rxgv+ushy0u5QFKZ7KzLZYdKo8CUxwNlzna2IAZ2/SbM
DO6AZ1SKceMWsbpap8OI243SmyXweKfAXTqQnX3+E9s+OvEe7QMDOLF/I64c3wBN6WYMmQ7D78uCpS1e
rK5uKEVXdw3m3BPgDndpT0bGRf/SEnyBACbZ9utViahXRkNbGY7Wmgj0NUfhgTIc75xOVNSUwekaF7Pc
4S7tTE+Xf2T13D6fyFuHA1qD4QcajUaYrZbvOe5wl7alpeW62cZprxdjs7N4abPBwZq4WOXl8DM+4xme
5Q53KT41Ne/D4iJs09Pos1rFu31u7qcsz3CHuxSTlFQwyrYbLBa8YfWHZ2Z+C8/wLHe4S2sSEso62dcf
YW91zM//FTzLHe5SRFxcZlhsbNW/wF1iv+9/8RkqBcVavPFSdAAAAABJRU5ErkJggg==
</value>
</data>
<data name="closeToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAUNJREFUOE+lk79L
QlEcxW9/gqCrm6vg4uYoOAgOrqLk4ioP0r2Glhp0SSjoF1FE0BIUDU3RdIOGoKBVGlpapaHTObeuCPe6
9ITD5fs9n3Pue8JbAWBS/VSQRvPwKR/j3JgaZXVqPv5TzPOXLhYoZDEcQidVWyhw3qzfn3tBAWH7PRjg
uV7HV5JAM6USyX50u86btlrOCwoOCR7Q+Oz1cFcu473dhmbppdFwu8dq1e3EBgU0zB6NXQJvzSaui0U8
VCq4LZWwn8vhLJ+HPDFiowUEzITADsGrQgFHmYzTSTYL7eSJiRZs0timRoTGhC956wXDXtrJEyM2eAIt
t34Be8NgTPLELCuQYe8Z9tK8ZBf+ieuEnxj20rzB26SYF7zCGsGEoVeW6NTMoJFiXlDAkFllqMOwTs2+
IOYFBf/9oFJ9ibr0B4f94vVG3bWDAAAAAElFTkSuQmCC
</value>
</data>
<data name="cutToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAd9JREFUOE+lkL1r
U1EYxt+z378gkiWQr+kM4RbaJcmQISQuiUtJt4wuGUopZ6yUdhZErAi6qYhfg4gFyVAQpJBSLoLBwWBL
hixdHFTs8f2dmHKR4tLAk/e+z9c95xrvvVzp1+l0pNvtXlfYdrst9Xpd4jiWUqkk2Ww2THZ4dHz4yYWX
Q/b7fQdarZb9XwH6wkvu4vT5fN6NRiPf6/VcrVazl50AHh0ffq6dvr4tFAouSRKvR3OVSsWmr8AOj45P
s/bfAnZbLBbdeDz2zWbTqdHyDZjs8OiL8EXBTWNkoFhRIOqb3WQy8dVq1WUymRtMdnh0fPjJhSt80oev
ilPFs3mRLZfLbjqd+kaj8W44HHp2eHR8+MmlC6ITY1YVtxVPnxuzfyuXS2azmT+IouRYd/i/+qoWROmC
6Isx27Pl5cNf6+tnfmfn3O/u+uPBwL8X+c5zgPLo+PBrQRROcGTM2relpRGml7nc5zsih7+3tvxbnYq7
THZ4dHz4yYWCA2MepMM/Njb8KzW/Fll7o1+NyQ6fLgk5Cl6I7Kt4jvhzc9M/1vlkHhIKmOzw6PjwkwsF
90T2PsbxlFM8VPHR3ByCiwJ2eHR8+MmFgj2Ra7rcV3zQZ0xyWQE8Oj785EIBf1fBHzMKb+X21x4lAAAA
AElFTkSuQmCC
</value>
</data>
<data name="copyToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAiZJREFUOE+lk11I
U2EYx9/u/EiR2CJ2UeZNrHWjjDHWx4UEkjJZH2IXIYRKfkQwl/NiOr0w6yocqIuhTEphDEJZhtOdIcgk
81AKXqisSNO8cEXUtOXX/r3PWedcBSke+PFwDv/n/54fh3MMADvSdaulhcmUOZ1mzr1DYJaWrzscMjX8
jZA8AJTjezWMnyaVmO12om4vmUShCyjq4gFPat7gs3IQqPMBAyIQmAcoR3mpoKy1ld1sbmbXrNb7v/f3
8XjsFzxTSfjeAS9mAP97wPsGeBYBxM9ANAZQjvJUoHiXNjX5RqanYeloRK3bBU/wLfoFEYMTInrHU3NE
XMRGHNjc3cXV+voH5H4o775xAV83E/i+vY0r1dVWxXv2pQr/Rq08J2+HPwx/dAexRALGigqb4j03lIuF
16exNPqX4Bl8EM7i40QeoqFcLPF78rY9F9A3t4f1rS0UlJfbGXmQz93Ci3hSa8SnsBark1p8mbqAn6tF
2InfxrfFy1iLnJe8vcEg1uJxbHCFc8XFDkYe5HNJo0GJVgvnnQL0t+kheE34EWvgX7sdseUqrEwaJG+d
xRLKyc9/RJzQ66sYeZDP8NMMiUDncbxyZWHUnY35kBrrCxrMDKkQ7s1WvE8ajSxTp2O8hDHyIJ+uhjSF
blsa3I3pGO7JRCSQhYGODPQ8TFe8+Q5TGwypAvIgH/L6H7I336E9dspkYow8ZKeDTMqr+OkyjH7no/AH
ckpmZFpW+tMAAAAASUVORK5CYII=
</value>
</data>
<data name="pasteToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAqJJREFUOE+NkltI
VFEUhrcvVuiDQeZDBUWWTl7QplFHsbGcqLyAQ2qMM+ZoY5M5WTqajoIWWlYomtfUrmZppamhFYYEJWjO
CS9RmoQZiVA9FOENBf/23unxoQtt+M5e/Hvtf61zzrICQNiq2GXFd7Y+rJJYj9m4hNDQflH6unHqTdum
maG5pZzFa4QwA0Z5AKmiCIxznqS/NiNpYmTkPRgsZtrSOcstUxDCEA1KFUR4Vx6H1uO+6O4eRF/fMEZH
xzksZho7GyrVgeVSSGoMfSx1UOxPhNdFWtyKcUXNQUfcjN6G+sMeuBu/HXU6N1yLcsLtWHcMFEaB5epP
6Eh4dvayQaEvEfoL1Og6HYrHpgDO5TQVitLVIpU5sbh61gCT2vcjvWyghIodXPQhwqsLkXiWtU+kJEtL
GwQW/gDTwzIzE0SDfBkRevJU6DgViBpzBC6ZNUgzG/CktxfhxRYcqrBAV2lBwhULqp8OY35hAcEmU6Jo
kCslAmu/PXknCtIi/1m5rrMHU/Pz2GM0JokGOR5EYO03JXgh2xDEKww0r+UMtjhgsJVCd6aXPOzAt9lZ
+Ov1yaJBlisRHqUocF3jjPRYJa9w/qgMb9ud8emFBN/HlJh46c51c30nPk9Pw0ujSRUN0iVEaE70wQ2t
BKm6QF5B7W2PMzGOaC1zx8xkPIaf+3O9uq0NX+bm4KZSZYgGKVuJ8IAa1NI5SI7ezSvcybPhNOTboqvJ
Do0FtlyXK/1+rJHJch3k8jjRIGkzNTjmzYfFGKXgFcYnJ3+D6SF+LuPrPVwJNVkeJMOGXwYNek+cPCCF
NvgvhEihdHYYC9uymvg5rVs2iLAjQotRzv9CI/149w07RO4dkYLBxprBcimEIb7C/hWkaq81Ef4Hlhu0
khDGT1IcUfrcDm8HAAAAAElFTkSuQmCC
</value>
</data>
<data name="preferencesToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgpJREFUOE+lkMtr
GmEUxT9xIfgA3bhplRKUUDQljFCcdCEEgsRx4esfcBVC6aogtKRdBEoodNESs8omgST7BFcxD0hlAo6g
cSQm1KZWxiS4l4Kb2+8McZjQrBrhcC/n/s6ZGS1ExB71Q0EikWDJZJKl02mWyWT0mcvlRK6FO4nmG1hk
9IebC1Kp1AwHF/l8gjkajWg4HJLZA/NggSRJrwqFwtfBYED5fP49h15fX/cJwg4PNzBg771BPB5nXG+6
3S4pSpX6fY1KpdIPTdMIwt7pdPQbGLDIGJ8giiKLxWJPs9nsx7OzBjUadbq6+km93m9d2OHhBgYsMkZB
NBqNceMttLm50Wm1VNrZ2W6Hw+E1CDs83MYcMkaBIAiFWk2h4+MjOj2Vqdls0tTUixWr1cog7PBwAwMW
GaMgFAq9q1QqVC6XCVNVz2l6Wli2WCwMwg7PzCBjFASDwblAILAEra4Wf9XrLdrbO6hHIi8/QNjh4Tbm
kDEK/H4/8/l8zwQh8kWWa3R4+J0uLzW6vf2jCzs83MCARcYo8Hq9jGtZlhu0u7tPJyc1KhbXu9VqiyDs
8HADAxYZo8Dj8TCu+dnZuS1FuaDJyeff3G73J1lWeUAl7PBwAwMWmXsFHGJOpzPhcDhWXC7XBGa7fcP/
0B6ZPTBgHyzgILPb7bpsNpvE9flO0tgH808BXuV/9Rc0A+b+f/6UZAAAAABJRU5ErkJggg==
</value>
</data>
<data name="addRectangleToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAZpJREFUOE+lk10r
g2EYxy/fgQM5EkkkbyXnDn0Bkre0vJMYPoBTCyHWphh5bR7bMFZIFvbSHKxMWsQ2xsyw4WyuP9t6yMFT
e+rX/+56rt99X3c9T0o0GqWkntIBUxnTgSzp3yUpiB0InTyFDcnUSCThULF8p5zpVprcs/7Qp0UK6IUD
l4r6jKDuPvR5ev0YMUkBvXDgUmHvNmjwPX8cu/1hoxTQCwcuFfRsgsabwLv5wve2JcZ5+yKcXD5p9p0P
U8azu1GD3acAVndwEQ5cyu/Wg6arh8ghC3rguApp95x+1YbVOyJYvIofPIr1GOaLwAIcuJTXpQOyy/vw
geM6JBy5AgssjmtPPWMsjIkTa8A9S3DgUm6HAJrPva97PKpGsHon+UQw8Q/f78yuwAocuJTTpgWtNndw
m8dU8qnTnL9ALV5Hml2PWjhwKat5lbJb1tr5XjrefUaEmtcAtV9rnmADDlzKlC1XMEODc/Z53sQQQ/8n
43WkHr1w4FJGvWYYnzKSkUsk4VBatboytUo1gUyvnSUpiB3C75wMX4BZWZbbegpyAAAAAElFTkSuQmCC
</value>
</data>
<data name="addEllipseToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAjpJREFUOE+lk91L
U3EYx38D/Q8Kom4WRSllbxdBUFeBCEIEdlEhxaDoVWvVkbKIvOjClDNa5ClfYCfPbGdbW/OtbRZWm1su
rWGZEkvmjg2n9kbm7Xq+hx0768WbDnx4fud5vp/nBzvMsOWCn+ExGAy/1+3UALFsNhtTh/TQOa8yLABb
uYDKtpqgkSgnqig8hEqYcj2jltM8/YICGu7eUx860RGatLY8/iDRe7UQSIjK3IIPPcyQIQr+WECNMrPt
Nad8WggST5OzP/r0oIcZMsguLth8/hEjivY1hqvppuBEZj5A+P9BABlk4cBlJeYetulc78HeV+m7iel5
//v0956lQAZZOHDZxrPdOwnO0j1uH1W+deqJJ7+4w+NzNn98+rZv6CPvHpy6AerkkWY4cNmGM10X8Wuj
xpNfveBl4rOTpDvOqNIoD6Q0GuisondYcZVvF1Fb7x2VSHzQ/3ZGJPGmYyDFOyLEr2qhM+Avd8Rb4cBl
RacfsvWnvCZXZFJ48iYjkXSLQtb7fwF9z+CUIPZP8HDgsnUnPaCkrK6vJjQ2Y3dGU4IcTTXlEaF3wvVC
ESgjlV4LcnDgsrXH3RoVlZZnV8Jjs/au4bToiirNOVpQ0cMMGXIqNI+tOebSKFx9VN67g+u81OAZsT5/
lxHNbTHJeMRxvbZ9WEYPM2TIKdQ8/QJGYbbqcHvxykP3TMRVgscXQkUPM2R0lzJ8xsVGbgFbUWlTWX6g
rXzZ/tYmVLzTAvWSvAX4e/4PPwF+djhWftNOkwAAAABJRU5ErkJggg==
</value>
</data>
<data name="drawLineToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAV1JREFUOE+lk0lK
A0EUhl/TnRso9iAozvMI4gHcZetCQRLUEGObxDlu3bh1KS4URBeK8zzeQDyCh+gbxP8vbTFNR5PY8HV1
UbyP11V/aYNrL0MiQl6/wPD5eJ6n0DRNDMMQXdclEomokc/79qjIQO45k8/n3zgCzgtw4gdSNbYj5sSe
8Ls+cSSNMycK1In0rz4NgyxwQU3fyqP0LN1L9+KddM7fSEf2WtrSl6qAxQ3J4+9vX0AJMVEcA2aYoMU9
l+bZM1VMCWVBgbC4d/khDoEZ7KBUAdtnB5MQWD9/oRwB/9/qWridgsDy96BcATeQHSQgsLiJlQh4AnZ7
5ioJgV2pgEdot85dpCCwSzmF0Ayg2AEuBM5fx1hMwAw4TanTNAROaA78CDNUv2SgFgFaBxt104cjKkiM
Li5UARTYsf1ibPLuYJ2jqJaDAs6RA6ke3w0jisu1hbWoEvD1Hz4ArP6Aa6ObcAoAAAAASUVORK5CYII=
</value>
</data>
<data name="drawArrowToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK8gAA
CvIBPVL3EQAAAWFJREFUOE+lk8lKw1AUhk9o8gaKSbpQnOcRxAdw160LBWlRS62xrbNuu3Fpl+JCQXSh
OM/jG4iP4EPkDeL/X43YEMXGwJeTEM6Xc+49VxtYex4UEfLyCcLH5bquQtM00XVdYrGYGIahIq+3rRGR
/tWnvOd5r4yA72XEU/tSNbot5viu8LkufSgN08cK5In0rTwOgQJwQE3v8oN0L95J18KtdMxdS3vhSlpz
FyqByfWZo69nX0AJMZGcBGaYoNk5k6aZU5VMCWVBgTC5Z+k+BYEZrOCvApbPCiYgsL63UImA/Vud8zeT
EFj+GlQq4AKygjQEFhcxioA7YLflLzMQ2FEF3EK7ZfY8C4GNtgQUf9uF0BlAchw4aGkjkoB/ZnJj9iTH
GFqBP8IcquAM8K8EySUMUBGs104dDKtB4ujiQJVBgZ3c+4kSzw6+M4rqOSjgO8uuHtsJI4HDtYlvCSXg
7T+8A+brhQsT6jHdAAAAAElFTkSuQmCC
</value>
</data>
<data name="addTextBoxToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAbtJREFUOE+lkdsr
w2EYx1//AyUSsUsXysrKqdi4cOXOac5DIUTMcSi5c+mKkvNYklO8v7iZQyTNlCEXSg5rWw4TczXP9+VX
P4dkWX16n9/3+T7f97Agv9/P/vVTGyVG6OJbpLxAwIzYPKFNAqUe7+uh88G39xfgxYwISO6QQPXtvW+X
224smT3cJAMNKDV4oGFGBKR1cdDkevQdpJt4s66bM4D65u5lB3zV4cWMCNCZOMvo5nqig9DgWz7Vled5
C2A3aB9ezYdXrwxgmbQrNVhqJ71Jq6D4/PZp4/jycQU1NPTgkb0/Bqhb6F95J9964pqwOlzjqGX914AU
OqYiQG91uCcBaXpZh+fTCaLKp1ls7RxLNK4wTStXYqBhMyDdoOxp6Z2SjMtMXAEB0RUzYo1rWCAWWXL7
GqinK1gAamjowaOqMLPworHvATGVs0xVZWHqxoWotM7V9s0T9/wWgRoaevBg+LeAbDLW9M7Y+yW70ywd
Oc2ooRHZ3wIiy6a0dPw+rBElE7hK3dm1d8d2cb+xfepeAlSvQ0MPnk8nCCscHaDH2MdKNAeCeMSQ3OGs
4JyhQayhBSMsEBDwBkZp2+pOUfIBAAAAAElFTkSuQmCC
</value>
</data>
<data name="removeObjectToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAfRJREFUOE+lkjFI
G2EYhq9GMFmMuSGEoqsBB4cIZhchOIToIsJZ7KqkdOlaOpSCFro4OEgVIxitlNZCXKz2VIKI5GKOFtpC
yOAVmnbI0HJHluPzfYMexMYU2sAD//3f9z73/Zf/jogo//WjYB2GDbAFXinK3W1FSYMsyF/BdZo19rCX
mcbLbwiSbwIBvRSPWz+np+3fc3Pur9lZ94em2efDwxZrECRvEyTf9fQYVU1zvs/MiKVpTXDv29SUsxMM
GhAkmybIcDS/X7+YnHS+TkzI51SqJV/Gx6WcSjmbXV06M94RVnG+k1jMMsfG5GxkpC3niYQcDAxYzHiC
ZUXZ/JhI2Ho8LtfsxWKyE41KtrdX1sJheamqDbjORaM2M55gCV8bb3ffDw1JvV6XSqUixWJRTNOUcrks
1WpVarVag0woJK/7+lxmPMEiHozRUXe3v19KpZIUCoWWYQq2IXgbibjMeIIXGOdwcNDOYcQtNLQjR4Gq
2sx4ggVenHD44gjn+4CGv5EJBCxmPMEz/CXPfT79KBJxTjHFKSS3sR8MOgsdHToznuApruUTXI75zk4j
r6qOCYkJyU2OEZ73+Qz2MtMkeIyNhyg8gn3F77fy3d32p1DIJVxzjzX2sLel4AEK9zHaPZwPZEH+Cq7T
rLHnDwFH+VcuAfO631eT7BU0AAAAAElFTkSuQmCC
</value>
</data>
<data name="helpToolStripMenuItem1.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAmRJREFUOE9j/P//
PwNFAGQAs85mBmbdrQzM+juAeKcEs8GuFCCeBcTboBjETgHLgdSA1AL1gC1HM8CD12LvZseMm7fSu99+
LJ725U/R1C9/0jrffrRPu3ELJAc0wAOXAR6idgcOpXe9/Zza/vp/QNENFJza/up/UturzyK2+w8BDfBA
c8EmSV7THVtS2l5+jqx+8N8r5xLQYaigpO/Wf5BcVN3jzzwm27cw62ySRHhBa32qTeLF22EVd/77FVz7
75l98f/ERVfBeNuhZ2CT5qx9AJYLLr313yj85G1moB64AUzqq+eGVd795J55/j8MO6Wc+m8eeeB/aceh
/2fOnPlf3rnnv4rb2v/qXhv+m0Ue/ATSgzBAdfnOyOq7f1zSzvx3SDr53zBk7391763/o4r3/j9//uL/
peuO/1fz3PRfzWsLGAPl/zAB9SAMUF68K7T85l/r+BP/dYIO/NcK2Pdfw2/n/9u3b4Oxpt8usBgM64ce
+ssE1IMwQGH+PKfUC58NIk//149AYE3/Pf9BGFkMxNYKOPqZCagHYYDc7AxV9713LZJv/jdNuAHGBpFn
/7979w6MQWyYOIiWst1xjwmoB2GA9HRJDsU5OywSb32xynj23yr96X+T+OtwA0BskBgIG0bf+MKmMGcH
E1APwgCpqQxMEpO8uFXmHjdLevjFPv/jfzsgNow6D8YgNgibJDz4wqU89zhILRNQD6oB4hMYGPmbvNlE
O/co2O54aJb4+ItDwde/IAxig8RAciA1TEC12A3ga2BgYCuVYmAtygbipUB8GIpB7GyQHCNQDYYBIKeQ
iwHBPxS/lCcjgAAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnSave.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAWtJREFUOE+tkzFr
wkAYhhV/jJtLBEEHQTfpUiH/QKNoUFAcAqIUnPpHFGyLBqS2AakWsS5Obg5dClIQWsFaQfDtvQHLVSR1
MPAQ7rvnnpvO5TrH53a7rwQ3arWqnQJdnvm9WyzuarUa+O3+gQ5dnpEDrUqlgu1uh8126wgduiLQkgNm
uVzGlzj8uV47QoeuCJhyoGMYBj42G8yXS0fo0BWBjhzolkolvIvbXxcLR+jQFYGuHLAKhQLG0yneVitH
6NAVAUsO9HK5HJLJ5EnQFYGeHOhns1n4/X4oinIU7u0pFosM9OXAMJVKIRAIYDR6wWDw/AfOuKeqKoLB
IPL5PANDOTBOJBIIhUKwrCd4vV4b07y34Yx7DEQiEei6zsBYDkw0TUM4HEa7/Wj/SaPRttnPGIjFYshk
MgxM5Gd0IRYzn8/33Ww+IBqN2tTrHZv9jIF4PI50Og36h+/wUgzmHo/n+hjcO+D2HA/Z9QPwx9BhcKWf
fQAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnClipboard.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAW1JREFUOE+NkL1L
QlEYh9/b4NzS1BgNShBRQQ3VGEGr/0BDBEG0uLRIFIREIX2ANhgZKphj/4PLASOi0i4SYWWmWH5y/bhv
5yc4HTl04YHD+z4893AMGvB53S7Hg+1cNQxjBGtm/p4YerrdvXlsDfJ7s7MlCp4ukgD7U3QX8mx+ZDIm
A5wx6+/hKiEs0+drnNiY5WTynlOpZ85mcz1wxgw7OHCVwPECCXlVDoev2ec75EDggiORGMfjCQ5dXrHf
f8LRaAwKw1UCR/MkbLns2Da/mOZAsIMDVwn45ki0pWB1OlrgwFUCBzMkrG6X662WFjhwlcDeNIlGu82/
zaYWOHCVgHeSRFX+vVSraYEDVwnsuEj8WBbnKxUtcOAqAY+TREleP1cua4EDVwlsj5MoNBr8WixqgQNX
CWyNkfis19ksFLTAgasE1kdJvMsHTOfzWuDAVQLuYRJf8oHeqlUtcOAqgRUHBZcdJP4D3H7gDzdsNup2
mXizAAAAAElFTkSuQmCC
</value>
</data>
<data name="btnPrint.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAj9JREFUOE+NkkFI
WnEcx9/0uF0EYezmpcPrND20KMG2Hr7lfGPJI3QMGsTUiCGDlLAn2mwYQRdH7uTokMPDojwsrMhAVluw
4zaYrMNCQwZrIw1WVt+93xuOJ6Xs9/jw//P/fb/f9/683yVGVQOhkACN5pr6rL4Hw+ReT0x8vaj370wc
H/f8rNVQqlaxW6ng28GBQiafB/UcktTWMuBeMOj9dXSE3f19fCmX8WlvDx9LJaSWl0FFfd7nMzQNEQKB
4crxMb7Lb1WHPJ+fR502npeaBthHR0eqcsCPw8NzIfQldB3SNASEw2GNw+EQRFH0aLXaGb/fj1aQhrTk
IS9jt9v1wWAwXJbv7PV6EY1GEQqFziFJEiKRiKIpFosYGxsLk5ex2WxsPB6fKxQKcDqdCAQCcLvdGBwc
RH+/A729HLq7zejouIG+PpuiWVnZwOTk5Bx5GZ7nexYWFja2t7fBcZxs9sBq7YPZ3CMbLQ1w3G1Fk8ms
YWZmdoO8jMVicW5tbe3kcjkYjUYMDDyQRcKFWK13FY1bftLpNzvkZbq6uh5ns1mkUikYDAaI4kMIwv2m
kCaZTGJxcRHkZUwmkz+ff4ulpSxGRnyYnk5gamoWsVhCxQt5/5fh4SdYW/ugQF6GZdng+vomVlc34XK5
/ot6AHkZvV4/pNPpnhHyP56ikb2TAF6+A169/4ybkSFc98Rwy5/G75MTkKauJ2/DUF3t7HyqDL2qTs/O
QNROT1GTV9I0HeUr7e2PLrNsrBWkUQf8ARn81oqOs3tVAAAAAElFTkSuQmCC
</value>
</data>
<data name="btnEmail.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAnBJREFUOE+dk11I
k1Ecxs+2q1DLqwRvvCgoM6mLvoTAC6WLSrDUYBcSGK6y6EMzc6a2NnERlVKhSEMTYWSyksTZh7KZGboU
HNmUKemcupnuI5tuqHs6/7cSUenrwMPhPf/n97wPB46IrVrHCwuTxCJR5EbxbHiUZHQnEzE2uhj18Wsw
zPPLGgQmdErli9Ws8C2VX8wFX9y0rmiWnJ9/dg38Qc02dZdKUlQ3DrcuBINIfQTItMDJWiBHByj1gMEK
0OxY9rkrywEvb7OQdzclR6tKDjRUV522qh7Kl5q6unDqQTnuNbZD89qEyhYTNK9M0PcMwLewgOsFh5oH
70oSbXfYBmZUiM8P1Se06Z4WBP5UvarFALffj+q6goDjTXJTf7k4nWVmp159ayhDnVYu1Ot7tvmnImB+
ztX4Y6dZUYMRzrk5VD4uxPueWmTlpVxmCVlZF1wuG8pqVJj0eKA+s5cHRMNm2Iapvn3wjCRirGOHUF2j
12PY7Ubx/SJ4vJMglsXLZJcWefrI+Ge09PZCGr8V105sQU3xdgx0HYHfJ4O5ebdQXVNXjLb2Csy4x0EM
sexgRka2f2kJvkAAEzz9VmkCatWR0JaEoqkiDJ26cDxRh2LQ6YSyQgGna0zwEkMs25+envON13P7fII+
2e3QGo1rVN/RAZPFvOwjhli2RyrNdfNEh9eL0elpdFutsPMmLl55peiMZuQhLzHEsl1paXlf5udhdTjQ
abEIu21mZl2t9BBDLItOSpKP8HSj2Yx+Xn9oauq3Ig95iSGWRcTFKVr57Q/zv9pnZ/9K5CWGWBYaG5sZ
EhNT+j8idt0X+S+H3wE2DYYIXysH6QAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnDelete.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAbxJREFUOE+tUz1I
QlEUvoaCgYgKioSu6qzDGwUHxSHURRILodmhobW5hIaWlrC/QTMpbDCIgi6Rg8TTfCRUIA69IGtw8+Ei
p3PEHhhmiw8+3uF+P++c++5lbNZPnrGFU8bSRcbyiMoIeVojbur3Cowtns/Pc1EQ5K9Eosf9/gHhE2vR
65WJI83EkBwSJZOp1kkmlY9UCuRkcgy09r60pJQMhhppx0Ky2FpBr+fNeFx5jcXgORKZiJdoFJrBoJLT
6Th51JADnO8eW5TCYXgIBKbiMRSCa49HJo8asMfYyZPf3+OCAD+49nrhwu2GvMMBRzYbZC2WIaguu1w9
8qgBu7jbtFk3Ph/0+31ot9tQr9dBkiRotVrQ6XSg2+0OcWw2w5nTOSCPGrAzCrh0uaDRaIAoihPNFFDE
gJLdPiCPGrCN7XBsq4wtFlAwDWXkcwZDjzxqwBYdHKv17Q7nu0XBfzjUamXyqAEZ/CUZjYZfGY1KFbuo
YshfIA1pyTN2FjbwcGzOzdVIIGGIhCG/QRxpSDvxNK4hsY7p+9gixzm52TwYAmtaI440U+/DKra2jPOt
4GXCd4UwqtPEzfrysm+MR0ij/f1svAAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnCut.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAZtJREFUOE+tkbFL
AmEYxt9v9z+4RQQRp3MSJBAEF5EGpSVs8g8Qp0O+5cAInGswkqAtapBaIhLCQQhCuIhbkpaD4ohbWgoK
8ut9vjRUVAw6eHnvfZ7f+9z3cUT/8RSLxfVCoWCukgUO/BRbLpclKp/PLw2BP2anAqLRqHQcR5VKJZnJ
ZOaGQIcPDvzsaU2IrusqPqJMJBJTIZihwx8tz/2IGYvF5GAwULlcTjKoIXTM0OGztPSaOsTzPJVOp6Vh
GBvomFdZ1tda4y/E43Hp+77KZrNX3W5XYYa+8C+9EIWeiTafhNjlOm0L0dkOh90gCFQvFHLveIYOHxz4
3zCXh0chdoJUqv9eqbzatj1UjYa6r1bVNdEb3lHQ4YMDjz0d4hBtecmkA+gsEnnYI+p/1evqgvslURMd
M3T44MBjTwf0hDicXP6wLHXOMJcG0DFDnwzBng5oE3VsyxrC/KzV1DH3k3H66KKYocMHBx572t4nOrg1
TR+nOGKT6+doMw90+ODAY08jTSKDq8XCTWvB8jgLPjjw2Fv4W/9ifAObfelTis5eHQAAAABJRU5ErkJg
gg==
</value>
</data>
<data name="btnCopy.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAfVJREFUOE+t0U9I
k3Ecx/HnqJZGoJcdyrrEqstGVFRe7CBZwooYHfIQKeWIYK7toDg6lHWKBuZiKJNSGINQluFyG4JMMkcl
eFBZ0h/NgzOipi3/7d3znW1uELTAH3z48jx8+P548VOU7TzGlpaai3b7tXwj/Zz7DU1N11FPMo9IT/o5
C85Zrab1ZJJKB1S1wXnX5rygzqs9YPJAdwR8EyA96ecsOGM23/i1scG9lz9xjSTxvIGnY+B9C+5X8DgM
kc8QjYH0pK9ku2tsNk//6CiGVisNTgcu/2u6ghF6hiJ0DG7O/sgUC3FYWlvjtMl0U/lfd+dgkMWlBN9W
VjhVX29W0u53z0r5e8oy/8Xd7A3hja4SSyQ4VltrUdLu8d5yJl/sYXrgT/x7eR/cx8zQfqKBcqbVb3Fb
ngTpHF9nfnkZndFoU8QhniuVJ7nfcJwPIS2zw1q+jBzmx2wVq/FLfJ2qYC58MOV2+/3MxeMsqIQD1dXN
ijhSHo2Gs1ot9st6um4fIeg+wfdYo/rad4h9rOPT8NGU+5DBENil092V7Nbr6xRxiKfvQVEqvoc7ee4o
ZsBZwkSgjPlJDWO9pYQ6Srbc2Y8vDvG0NRZk8shSgNNaSF/7DsK+Yrpbi2i/Vbjlzl4gDvGI61/JuLMX
iCNtymem3Nt5fgMnuhz+MJjldQAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnPaste.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAndJREFUOE+Nkl1I
U2EYx9914U1eCGVedJmSG2atLecyXeSirAlaamzOnJouc4lbLjuJmmiYoFlqmVr2ZWmpqaEVhgQlaO6E
H4UuCTESoboowkwU9u+8b3hujkUHfpyX//Pwe17OeWRklacoXuH1ziM3yGQyX1oG8DVozWRPcdvE0mr9
LKvVkfqaCMJTSpVktMmZNTc19QEUeqbZSp32SkS0+P5KKrpP7sTg4DhGRtyYnp5l0DPNaG2yxgLaKxFc
DCf82yoz7iYHofGIP24nKdCStg0P0rej2bIFTabNuJcSjLFKE2ivRFCpJfxohRED56Lx9NRuxjVnLKry
jCJ1RSm4cd4Kh1HzMa6w0HqooCBaFJWHEv5NeQJe5O8Xqc43C98P8KwCzWM4LlMUlKkJP1Qai77TkWjk
4nGZS4STs+LZ8DDiLrlw9KoLljoXMq+70PDcjWWPB1EOR5YoKFERnl6/1x6BCmfCPyc39w/h5/Iy9tps
2aKgaCvh6fU7MkNQaD3AJox1bmCMd/lhvFtAeNO8+nEfvi0uYldaml0UnFUQ/olDh5uJgchL0bMJF47v
wERvID69kuP7jB5zr4NZzrX04/PCAkJMplxR4JQTvjMrFLfMcuRaItkEo8YXxcn+6K4Nxq/5dLhfhrO8
oacHX5aWEBQTc0YU5AQQ/pEguCPsgT1pD5twv3Qto7XMGwMdPmiv8Ga5Uh/2Y51aXeKn1aaKguxNguCE
hi2LzaRjE2bn5yXQ3BCmmJUsUsbGP4LWY0rkHFbBfPAvGFTQB6yfkQjifQjfZdOyv9AufLw2q1rkYYYK
FLrWFNorEUR5kfp9XoT/H2jviuA3wNPrkyhsrGEAAAAASUVORK5CYII=
</value>
</data>
<data name="btnSettings.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAcxJREFUOE+1k79L
AnEYxpsUdBAHpwIjNEKUUAi8GkQowRQU8Q9wi4im4KCoBiEkCCwkaGgxoj1wykowucAT/HGSRVYmp4m7
BC5v90iKooMECQ/fh+f5vO8dd+fExH/9/H4/I2ntV8xY1/F4PIter3fd5XJN4my329Rqtag/AzNymdPp
XGJZ9rjZbFIgENhxu90b9XqNIHhk6MCAHVricDg2K5UK8XyaajWRYrHYqyiKBMGXy+VOBwbs0AKbzTbl
8/n28/kc5XJZen9/o2r1syN4ZOjAgB1YYLVabQzDbEHR6Hm5WBTo6uqiZDQaTyF4ZOi6HGZ6S8xmM5vJ
8JRI3NPjI0eFQoFMJlOoC8AjQwcGLGZ6CwwGw3YqlaJ4PE44BeGJ5ufNwS4Aj6yfwUxvgU6nW9Hr9btQ
JBL5yGaLdH19m7VYFvYgeGTouhxmBp6DVqudlm7riOMydHf3QC8vIjUa3x3BI0MHBuzQW9BoNEGOy0lX
vqFkMkPh8FklnS4SBI8MHRiwQwvUarXTbl++5Plnmp2dO1GpVAccJ0gDAsEjQwcG7MivUaFQrCqVypA0
MIOzVPqSHmiV+jMwY/0vZDKZSy6XH0LwYw39BfoBAspKYi5+XTsAAAAASUVORK5CYII=
</value>
</data>
<data name="btnHelp.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAjdJREFUOE9jYKA6
0NoiwWSwK4XZYOcsRv1d20AYxAaJMQDl8NrHrLfDg9t872bHjJu3Ujrefiyuv/KnCIhBbPvkG7dAciA1
WA1h1tviIWqz71B819vPqe2v/wcU3UDBqe2v/se3vfosBFQDUotqiMZaSW6THVvi2+5/jqx+8N8r59J/
dFDSd+s/SC6q5P5nbpOtWxiAeuCGMGmtS7WJv3A7rOLOf7+Ca/89sy/+n7joKhhvO/QMbNactQ/AcsGl
t/4bhZ+8DdIDN4BRddXcsMq7n9wzz/+HYaeUU//NIw/8L+049P/MmTP/yzv3/FdxW/tf3WvDf8OIXZ9A
epAMWLozsvrKH5e0M/8dkk7+NwzZ+1/de+v/qOK9/8+fv/h/6brj/9U8N/1X89oCxlpae/8wqi7diTBA
efEue/v9f63jT/zXCTrwXytg338Nv53/b9++DcaafrvAYjCsD1TLCNSDMEBh/jyn+JOfDSJP/9ePQGBN
/z3/QRhZDMSW9zr6mRGoBxGIsrMyFN333rVIvvnfNOEGGBtEnv3/7t07MAaxYeIgWspy6z0moB5EVMrN
kORQnLPDIvHWF6uMZ/+t0p/+N4m/DjcAxAaJgbBh4I0vrHJzdjAA9aCkBWaJCV7cSnOPmyXd+WKf//G/
HRAbRp0HYxAbhE0S7nzhAqoBqcWepHkbvVlF2vfI2m57aJYINAgYWCAMYoPEQHIMQDX48x9nqRQDS1E2
EC9lYC04DMYgNkgMJEdtAABbvniIc+V/VQAAAABJRU5ErkJggg==
</value>
</data>
<data name="pixelizeToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAH9JREFUOE9jZMAN
HJCkjiGxf+HRgyIFMgCG2YBsGCZWP1wzyBCiDUBWeACoEYaTgWwYxuuCgTfADug+GK4GsmF4NZANw3i9
MPAGGALdB8PiQDYM3wOyYRg5fWB4Z2AM8AO6A4bjgGwYRk4Tk4HiMDwHyIZhdZAfBt4AonMXNoUAoi44
jzfx4iwAAAAASUVORK5CYII=
</value>
</data>
<data name="blurToolStripMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAWBJREFUOE+V070r
xVEcx3GklJISCwNiQBEGhEgekqc8hQwesmBSpGRQTJQilM1gMRilDEaD7FiUUkoU/gPvtw7pdi/uqVe/
372/7/2c8/uecxMTYo90HuWFx+9c73+pjfool2+70YtyJMUTkEJxM9axixFkxBOQTfE0znCJZZT8N8Cl
VmIN13jCIXqQ+p+QTIpasIErPOMCc7Avf45iKtqwgAPc4BH7sC/2J+ZI40kDWuEO2IdTvOI8fLY/MUdB
mMWZCkPYDtcH3GMLdUiOlmCD/OEEZmAfhrEHm+lhcjWTyIoWYIM6MYZ+1IaQea4neIH9WEVpZICzu7Q+
jKI+BBjShZ87csTnAdiv7+HsQ0FVRLqFvsox3uDWLqEIn73Ih0tfgSeuHR5bD5S8d0a39A634d6Vln0F
NHEzhXFURwnw9WaxiW0swlf7DKiAATbPP43FOXB58r4Gg6HGXbC2A40fsXk8/aA8wdkAAAAASUVORK5C
YII=
</value>
</data>
<data name="obfuscateModeButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAWBJREFUOE+V070r
xVEcx3GklJISCwNiQBEGhEgekqc8hQwesmBSpGRQTJQilM1gMRilDEaD7FiUUkoU/gPvtw7pdi/uqVe/
372/7/2c8/uecxMTYo90HuWFx+9c73+pjfool2+70YtyJMUTkEJxM9axixFkxBOQTfE0znCJZZT8N8Cl
VmIN13jCIXqQ+p+QTIpasIErPOMCc7Avf45iKtqwgAPc4BH7sC/2J+ZI40kDWuEO2IdTvOI8fLY/MUdB
mMWZCkPYDtcH3GMLdUiOlmCD/OEEZmAfhrEHm+lhcjWTyIoWYIM6MYZ+1IaQea4neIH9WEVpZICzu7Q+
jKI+BBjShZ87csTnAdiv7+HsQ0FVRLqFvsox3uDWLqEIn73Ih0tfgSeuHR5bD5S8d0a39A634d6Vln0F
NHEzhXFURwnw9WaxiW0swlf7DKiAATbPP43FOXB58r4Gg6HGXbC2A40fsXk8/aA8wdkAAAAASUVORK5C
YII=
</value>
</data>
<data name="textHighlightMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK+QAA
CvkBtGHeGQAAAPpJREFUOE9jYKAGcEv37EfCx6FsMSxiRkCxMqh4Hdxuz2zfj9lTS78BJe5DJc8B6QAg
Pp41peQ3EP9HMuwlSBzEp4bjIWYgmR4HMx1JTA9NzAvIb0dxAZADcjIsHOBOBDkfKK4BNQAkDlIDcj6Y
jdUL//8z/MeFcfoZanI4yGnnrjP8n76S4f+uYwz/8zogbBD+/JUBOSBBLgmAG4jkheMHzzD8Dy2BaIZh
EB9kICwsoF47TnUvgAMFaEs1UoCCnYrGB4mBvKuJzQugaAQpgIV4P9S54BhCYuOOBbJSF5oTzdH4LDi8
gUgHWBIScqICsdETGlieLNeiawIAaZgQICy+wd4AAAAASUVORK5CYII=
</value>
</data>
<data name="areaHighlightMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK+QAA
CvkBtGHeGQAAAn1JREFUOE9dk99LFFEUx2dp7sy97oIQUg/r7vzYhVwLsdgQSnpIigzzwVI0zWy1NA3U
TItMN7MgNZOKqHehf6W/xZfA6r0+585Y2cOXc+f8+N7vuedMRleyjY7jNIEcUBa/nH3svpNxGrASF98P
7Pc0x2SczE/wzYHgpIrMrCqZba9k3lhEZsEL9E3sPP4PqtzwScXmiRfqcXyPwArxW7olGzp+JVsl+Jyk
XVXSnyF468XmKclT+F8cKZsvYJfzGoWLxDfAFgQ1CGIU5EI30ANupO+rUNcI3AEjXlH3e4EZciMz7sZm
mtgYvgE/MMMSV83+FdQfd2CpcNtdyx6Zx9y+BV5bVZF56IVmAv+qvTUmHup5vkVhDYKSELTx8QDnMgmr
4CN4R+8bbqlhFWXTxNa9WIv/JedX2G0v0lOWwLRkC6rgdyOvTxV0L4TnQLtXyba5rblWv5KLRCU4n7Ql
LfpjtNAFwdGkhUDfRuosSkZO91UHL09274BR8DU97+Q7i6eIT9jWYlNXoRmBoJC0wAPa0YT63pnrZ2co
2kuLhUCwV+3vWCBvRlpjYu953DkITqQt6B6Rp/L+RQjLMh7pDwQgn9p2lN6Qm12ZTrPuMi25pr9TCPUk
b3CNpHEeqS6PitQlbloUC1bAOli2O9LsXzp4g2QKoZmjeIjCOUa2Ccma9OqW7EjrUuyWzQ4tbJJTl1yU
5v9tYQAFV2USBGVZhhWSWbJeVdQ9nAdRU7MLFegxyT28SHZ9zXyqRpYFqXwX9aAU2P8j2RVZaWlj9PAi
yRJF5lmacGBlcWRDl+z/IcXJRq79IeAlj4E22Kr01AEupNaeWbROu1z/x5MpNf4GKpmbjiTkSWoAAAAA
SUVORK5CYII=
</value>
</data>
<data name="grayscaleHighlightMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAK+QAA
CvkBtGHeGQAAAONJREFUOE9jYKAGiIyM7EfCx6FsMSxiRkCxMqh4Hdzu2NjYjy0tLd+AEvehkueAdAAQ
H29ubv4NxP+RDHsJEgfxqeF4iBlIpsfBTEcS00MT8wLy21FcAOSAnAwLB7gTQc4HimtADQCJg9SAnA9m
U90L4SCnuaV7OgNxPxDHAfFxKBvEF0CLrQC4C5C8ANIQCsQvoZpBfBAG8eHhA/Xacap7ARwoQNdUozsV
jQ8KSJB3NbF5AeRMkAJYiPdDnQuOISQ2bWIBlg7M0ZzMAuSDkjVyfgGzsXkBxflIXkFPaKgGUBIdALJS
5si8Z54VAAAAAElFTkSuQmCC
</value>
</data>
<data name="magnifyMenuItem.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgpJREFUOE9j/P//
P4O/vz8DOmBmZmYAYkFGRkZ9oJwUEHMD8VcgfgbUc/Hv37/vgZiBAWSAn58fBg4MDFSMS0hOmrJ4Y/fR
q8/W33/15fjNx2+3LlqzrQ8kDpIH6QMb4OPjg4J9fX0Fo2LjU9YdvLrwyI3Xhx69+Xb2ydtv50AYxN5x
4uaS6NiEFJA6sAGenp7o2Hni/LV9uy+9OHD18ccTMM0w+tqTTyemL9kwEajPGWyAs7MzOk7YdvrBGpAB
uPDBy082AfUlgA2ws7NDx/n7rrzcB9OM7gIQ/8Ttt0eB+vLBBlhYWKDj1D3nH24EGYBNM0js1I3nO4D6
UsEGGBoaomPPyXNXTN9/9dXh+y+/nkY3BBiQ5+YtWzsXqM8TbICDgwPYC7a2tgw2NjYM5ubmKi5u7tVH
Lt7bd/PZZxQDnr3/fvHyzfs7rG1sS9TU1EQwDLC2tpYHGlK8du36/xqa2u0Tp89d+vjFuyNvP/+89vTV
+6PzFixeqaGhWSsoKKglJycHSQcwFwA1arm5udfs2LHnv6ioWDMLC4sWEIcBcSUQt0NpEF+Mj4+PAcUA
oPMtAgOD244cOfNfUVGpB6hIFYgZcGEUA4D+905ISJlw8eLd/3p6BtOAmozxaQbJoRgADLSSW7de/be3
d57HysrqQkgzhgF6enpaIiIiLUDNMcRoxjAAFJDkYgBdbLFwSdIP+QAAAABJRU5ErkJggg==
</value>
</data>
<data name="highlightModeButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAARRJREFUOE9jYKAG
cE337IdhtzTP42B2hqsYuph7qrsRUKwMJO6W7lEHt9szxfdj8tTSb87JnvfBkqme54AGBYAMi58S/ztr
Ssl/uGFJni9hllDD8RAz4Kane8bBvQD1lkemhx6ymEu6hxdQfTtID9wFICdjcyLI+W5pbhogA9yATgd7
D4mN1Qv//zP8x4Vx+hlqcjjIaeeuM/yfvpLh/65jDP/zOiBsEP78lQEekFD1ARheADnv4BmG/6ElEM0w
DOKDDISFBcRrnsep6wVYqAITSDVawgpA5sO865LppYnpBWA0ghVAQxzEBjkXZgCMDZOnfkIC25TqZY7s
ZPt6exZQskb3Bt6EhJyoYHkDXQzFAEr8AgCijg7R+5ew9wAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnFillColor.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAOpgAA
DqYBh9ypbwAAAkNJREFUOE+lkl1oUmEYgF//EEUICb0K68LISHYaZquIZttUpmSWSlDECEtbNOpm2M/m
xFAy2E2MlcRgeCXYlYwIkpEJ2oVs0G6mdnDgJrjMIAgvBN++7+gGlVC0Dx7OxTnP873nO4fncrmgxzrR
bDYHisXiJz6fn2FZFlqtFkgkErg+swXtdhvI/Y5GA7/jdDq9VqsVFArFE5VK5REIBAx9lgY8TxtwM1yH
a9MVjp4Bh8PhNplMHp/Ph41GA4l7m6D/1wBD5Xq9jjSQy+WwWt1GHo8Xlkql5/42ASfXajXMZDJcIJFI
YDL5BldWyqhUKsNj/s/f3KEvkV6vwMnVahULhQJGo1HM5/MYicziwsJrXFxMYqn0FYcvTSWuPCyjy8de
dUyWAGw2GweVK5UKJ9OxY7EYksMlgXlOXlrK4ubmDzQajffM46tIKBAANBoNBz3tcrnMyalUiht7Z2cq
b2x852S73X5c53qHXTqfhiISiRhyUN5sNveHzLINNBgME3q9/uxpyzQcGopjl18CQH4aHcEXj7/dHXt9
fRvVavVdhmH6dTod7Ot/QcH9+lcBAgB6ovDBNgnDB47SAJ3kjFgs9i8vr+La2hbKZLLHcrl8QKvVwuGT
4yA6MksJyPrmYDeAt14CuufhveU+jJCQUCgcJDzrMmg5eAw+jtwBvBCA9FAQgqdCkB6cATQ+6EywE8Ab
c4BjzyFtnoAgMwrBPjOkz3sBL4cALwa5AFr9gKNTgOZHnUAgEEC6/vcKe5Hppnue4Cdc2PX6a/zfmwAA
AABJRU5ErkJggg==
</value>
</data>
<data name="btnLineColor.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAAlwSFlzAAAOpgAA
DqYBh9ypbwAAAaxJREFUOE+lkk0obGEYx//PZDMLS7O0clnYISviiCZNOHO6uPnIxsfQRGGiMTSp6+Nm
IiwuUVJDxiTdkZWPRDYUC7KiKEKSLTWe+74znamp46PmqV9Pp87vd87pvAQxLeUkV2yKioAUS/RyalWN
7On1dbksT8DjDXPc/ZGApKeGsLMUj91uh+SWKO+aaO2EaDgkdJ1ISZf9HhgGVFVNVxSl493l4hur9WEN
KBZAEpmhJoKUjQK6HA6HORgMngeAA79wdGKiUWDbTwX/Zmnj4lDjrUD2i9lsHvEQYUEEdD4M6PLrfR+f
7amPQx3YT0tNgmYyfR0wkr1tgJJr+jrwkTzgiA+cpuWDS3qB2e4ocy7xXb1InXcn9z9fNvPmYs69fG35
ZCnrgZWMQnCpB2x1RwPjziiT7aBxJw3y8zF3VtFCq0ruvkaKybt1CrjMC7YNxAdGHQSJ+JVjd+dL7NRo
2VFBpfJsdNUSdhuKwdpvcMWgccCbXaYfBxZiQIiZPu0HQj+t4Oo/4MqRzwPcPANu+gtvlg2hXzZwwyS4
fgJc4/te4OjqjRMBicjSTTjwH6Tov650h2O3AAAAAElFTkSuQmCC
</value>
</data>
<data name="fontBoldButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAIpJREFUOE9jYBgF
6CGgzcjIuAYHng5ULEZMkDkBDVgPwkDFOlANEVB+BDEG6AEVbwFhoGI9qIYoKD+KGAP0gYp3YsNAzfrE
GGAA1LwfhIGKPYDYAIjjoWLLgWwuQoYYARUfBWGgQiOoYmxiOM3xA2o+A8JAFSZQVchiKvhcYAWUfIgH
FxBy/kiUBwCbgyMPwOVlBAAAAABJRU5ErkJggg==
</value>
</data>
<data name="fontItalicButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAGBJREFUOE9jYBgF
+EJAm5GRcQ0yBirWJjXIdIAGrAfiHlI1wtTrATVvAXJ0yTUgDWjABnI1MwA1bwVqziTXACOgAUeBmg3J
MgCoeQkQnwFqNiHVACughodoGCQ2CnCEAACbwQ6ZOSbWkwAAAABJRU5ErkJggg==
</value>
</data>
<data name="arrowHeadsDropDownButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAMxJREFUOE9jYBgF
8BCwn/3Mw3bO85mEggSkBqQWRZ3FlPseFpPvnQFhQgbA1IH0gNXqtV3w0Gu/dKbnxt//IJoYbLrzO0Qt
UC+DcuXhMxPu/P/fePbP/44rf/43n//5v+7U9/+VR7/8L9///n/xrlf/c7a/+J+07eX/kG1v/7vu+PRf
fO3X/+q7//wH6WWQyNrhIZa1FewCEE0MBrkApA6kF+wNvviVHjwxy8+AMKEwgKkD6UFRyx4424MtcA7B
WACpAaklZNGoPAkhAACKUZ0duA4mKwAAAABJRU5ErkJggg==
</value>
</data>
<data name="shadowButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAQVJREFUOE9jYKA2
qJ6883/L3GP/yTK3Zd7x/zdu3ADjhpkHSTckNr/nPwzEF/aTbkDn/ENwFzROWkOaAci2w1yRUDQBxZCl
R3/8T6+e/d8rsuB/zZTdqBZgMwAkBgpMkOKonI7/oakN/z3Ccv/ntyz/v+TwN+IMAGn2jSn5b+Me9d/C
ORTMrpq0A9N7Jd3r/8fkdSMCsaD7f0b1nP8+UUX/Te0D/pvY+f+38YgGuwRnFKdWzoAbEJXd/j+usA+s
EYQdfBL+J5dNxR+wyOEAYoM0gpydVjnzf1HHasKxgmwASLNbcOb/rPoFhDXC/IRsgL13/P+SrnXEawYZ
AjIAGZOVH+iuCQBy8wHwFhVd2QAAAABJRU5ErkJggg==
</value>
</data>
<data name="btnConfirm.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAbhJREFUOE9jYBha
YI2EPMMq0TMMK0U9SHf4fH4BhmUiG9Lelf9nWC5yhmEZKYasYmBjWCw8T+eY/dOoR9n/4+/H/2ZYBDSE
KPCfgZFhvnCrwlajewE3Ev97X/X5xbNc7hLDQhEfVP2zBT0YZgueAWJU/80WyBRYpnzDbUf4P/v99n/5
lyheY5grlIyqeQpQ03TBM96XY/6CaAYQHwSmCfhwzJW4LD9f7bfaDPN/fAvkbzFMF6jGdPkk/jM+T3N/
eVyI/B9xJfMPA5DPMJEvl2mq4GmhxSY/FDcZ/eeeLX0fKNbDUM/AhGlAL58HQy/PGfub8T+V9hj/NzsR
8APEl9ok/1l6h85/vkVyTxh6+OYBNXPgDrc2oCHtPGe0Tjl/kzis+V/jjOV/8UMa//kXy71iaOVdx9AP
jEaCoJnLg6GJ+4z0AaUvwmdV/rNvE3/P2Mizm6GFU5qgXriCCHYPhgL2M6wLBF4wlrEdYQhn0yRGMyhg
+IFYHoh1GYyY0hjimc4waDGEAvkgA5SAWAqIhYGYB4jZgJgR2WAQBxRAIH+KQxVLQtmiQFoQiHmBmAuq
mRndAGJciVUNAFkNhnIqpOEtAAAAAElFTkSuQmCC
</value>
</data>
<data name="btnCancel.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAg9JREFUOE+tkj9I
W1EYxT+fkacSSELIH4vo4CKWDkrAMVmELFkKLsVF4qboYMDFUlrQNNAhiw6iTiZGoZVii+LyhhaUkmDp
H+G5PjuEDhkKLY8Wb88JfRdSg5MPDtx3v3N+3/fufSJ3/ZRF7u2JzO2LlKH3/1TmHmu39quIZF729FjV
8XGnPjPj/pyfV1Q9m3WrY2MOa/S0hZRQOAgGa2ppSf1aWFCbsZidN81ziuvTiYnGj9lZdeD31+htgWxi
tEp3t/Unl1O/FxfVVn+//URk+blIgHoqksT7/quRkav69LQqdXVZzGjINr7vHUb8ns02w+yEQBVKe6ZV
kTAhR4lE42R42GFGAzZEdu1k0i0Gg83ODH+bmroB4SQF07RPIhGXGQ1Yw2l/zWTUimGcc2R2JuRTKtUC
Ye0ZPG8HBxUzGlDEy8d0WrFIEwse5MPoqIZ4gOO+PsWMBrzAOFYi4RY7O22O6RU8yOnQkAdZpuc4HHaZ
0QCQ5yrRqPMmFGrwoHhg/0PO4vEm5LVpNnZ8PocZDSjgSgodHdbngQFV6u29IoSTeNfoHSwaXFdDIUUv
My3/wmP8HHnDqF1EIuoIXdYx6irOhOKae18Qpofetn/jQxRyoG9jRCsQcC8RoLjmHmv0tAv7sBmD7sdx
hSmR/KTI4SORM4pr7rEGzwMIS2FGPwZWfigK8dtuExvRy4z8Bf/r5wJUAb5DAAAAAElFTkSuQmCC
</value>
</data>
<data name="btnLineColor_.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAA1JREFUGFdjePPy
xn8ACR8DrWYMYwcAAAAASUVORK5CYII=
</value>
</data>
<data name="btnFillColor_.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAA1JREFUGFdjePPy
xn8ACR8DrWYMYwcAAAAASUVORK5CYII=
</value>
</data>
<data name="checkerboard.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAIAAAACUFjqAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAACJJREFUKFNjZEAF
////RxNB4QKlkQG6UupKU9c0TI+S7xMAKX+JeHFERhgAAAAASUVORK5CYII=
</value>
</data>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>551, 17</value>
</metadata>
<metadata name="toolStrip2.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 54</value>
</metadata>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>662, 17</value>
</metadata>
<metadata name="toolStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>452, 17</value>
</metadata>
<metadata name="propertiesToolStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>116, 54</value>
</metadata>
<metadata name="printDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>340, 17</value>
</metadata>
<metadata name="fileSavedStatusContextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,134 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot {
partial class JpegQualityDialog : System.Windows.Forms.Form {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.label_choosejpegquality = new System.Windows.Forms.Label();
this.textBoxJpegQuality = new System.Windows.Forms.TextBox();
this.trackBarJpegQuality = new System.Windows.Forms.TrackBar();
this.checkbox_dontaskagain = new System.Windows.Forms.CheckBox();
this.button_ok = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.trackBarJpegQuality)).BeginInit();
this.SuspendLayout();
//
// label_choosejpegquality
//
this.label_choosejpegquality.Location = new System.Drawing.Point(12, 9);
this.label_choosejpegquality.Name = "label_choosejpegquality";
this.label_choosejpegquality.Size = new System.Drawing.Size(268, 32);
this.label_choosejpegquality.TabIndex = 15;
this.label_choosejpegquality.Text = "Choose JPEG Quality";
//
// textBoxJpegQuality
//
this.textBoxJpegQuality.Location = new System.Drawing.Point(245, 44);
this.textBoxJpegQuality.Name = "textBoxJpegQuality";
this.textBoxJpegQuality.ReadOnly = true;
this.textBoxJpegQuality.Size = new System.Drawing.Size(35, 20);
this.textBoxJpegQuality.TabIndex = 16;
this.textBoxJpegQuality.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
//
// trackBarJpegQuality
//
this.trackBarJpegQuality.LargeChange = 10;
this.trackBarJpegQuality.Location = new System.Drawing.Point(12, 44);
this.trackBarJpegQuality.Maximum = 100;
this.trackBarJpegQuality.Name = "trackBarJpegQuality";
this.trackBarJpegQuality.Size = new System.Drawing.Size(233, 45);
this.trackBarJpegQuality.TabIndex = 14;
this.trackBarJpegQuality.TickFrequency = 10;
this.trackBarJpegQuality.Scroll += new System.EventHandler(this.TrackBarJpegQualityScroll);
//
// checkbox_dontaskagain
//
this.checkbox_dontaskagain.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 81);
this.checkbox_dontaskagain.Name = "checkbox_dontaskagain";
this.checkbox_dontaskagain.Size = new System.Drawing.Size(268, 39);
this.checkbox_dontaskagain.TabIndex = 17;
this.checkbox_dontaskagain.Text = "Save as default quality and do not ask again.";
this.checkbox_dontaskagain.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.UseVisualStyleBackColor = true;
//
// button_ok
//
this.button_ok.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_ok.Location = new System.Drawing.Point(205, 126);
this.button_ok.Name = "button_ok";
this.button_ok.Size = new System.Drawing.Size(75, 23);
this.button_ok.TabIndex = 18;
this.button_ok.Text = "OK";
this.button_ok.UseVisualStyleBackColor = true;
this.button_ok.Click += new System.EventHandler(this.Button_okClick);
//
// JpegQualityDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(299, 161);
this.Controls.Add(this.button_ok);
this.Controls.Add(this.checkbox_dontaskagain);
this.Controls.Add(this.label_choosejpegquality);
this.Controls.Add(this.textBoxJpegQuality);
this.Controls.Add(this.trackBarJpegQuality);
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "JpegQualityDialog";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "JpegQualityDialog";
((System.ComponentModel.ISupportInitialize)(this.trackBarJpegQuality)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.Button button_ok;
private System.Windows.Forms.CheckBox checkbox_dontaskagain;
private System.Windows.Forms.TrackBar trackBarJpegQuality;
private System.Windows.Forms.TextBox textBoxJpegQuality;
private System.Windows.Forms.Label label_choosejpegquality;
}
}

View file

@ -0,0 +1,68 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
namespace Greenshot {
/// <summary>
/// Description of JpegQualityDialog.
/// </summary>
public partial class JpegQualityDialog : Form {
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
ILanguage lang;
public int Quality = 0;
public JpegQualityDialog() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
lang = Language.GetInstance();
this.trackBarJpegQuality.Value = conf.OutputFileJpegQuality;
this.textBoxJpegQuality.Text = conf.OutputFileJpegQuality.ToString();
UpdateUI();
}
void Button_okClick(object sender, System.EventArgs e) {
Quality = this.trackBarJpegQuality.Value;
if(this.checkbox_dontaskagain.Checked) {
conf.OutputFileJpegQuality = Quality;
conf.OutputFilePromptJpegQuality = false;
IniConfig.Save();
}
}
void UpdateUI() {
this.Text = lang.GetString(LangKey.jpegqualitydialog_title);
this.label_choosejpegquality.Text = lang.GetString(LangKey.jpegqualitydialog_choosejpegquality);
this.checkbox_dontaskagain.Text = lang.GetString(LangKey.jpegqualitydialog_dontaskagain);
}
void TrackBarJpegQualityScroll(object sender, System.EventArgs e) {
textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString();
}
}
}

View file

@ -0,0 +1,96 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Forms {
partial class LanguageDialog {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(LanguageDialog));
this.lblSelectLanguage = new System.Windows.Forms.Label();
this.comboBoxLanguage = new System.Windows.Forms.ComboBox();
this.btnOK = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// comboBoxLanguage
//
this.comboBoxLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxLanguage.FormattingEnabled = true;
this.comboBoxLanguage.Location = new System.Drawing.Point(13, 15);
this.comboBoxLanguage.Name = "comboBoxLanguage";
this.comboBoxLanguage.Size = new System.Drawing.Size(299, 21);
this.comboBoxLanguage.TabIndex = 3;
//
// btnOK
//
this.btnOK.Location = new System.Drawing.Point(126, 42);
this.btnOK.Name = "btnOK";
this.btnOK.Size = new System.Drawing.Size(75, 23);
this.btnOK.TabIndex = 2;
this.btnOK.Text = "OK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.BtnOKClick);
//
// LanguageDialog
//
this.AcceptButton = this.btnOK;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(327, 77);
this.ControlBox = false;
this.Controls.Add(this.btnOK);
this.Controls.Add(this.comboBoxLanguage);
this.Controls.Add(this.lblSelectLanguage);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "LanguageDialog";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "Choose language / Sprache wählen / Taal kiezen";
this.ResumeLayout(false);
}
private System.Windows.Forms.Label lblSelectLanguage;
private System.Windows.Forms.Button btnOK;
private System.Windows.Forms.ComboBox comboBoxLanguage;
}
}

View file

@ -0,0 +1,78 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.Threading;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
namespace Greenshot.Forms {
/// <summary>
/// Description of LanguageDialog.
/// </summary>
public partial class LanguageDialog : Form {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(LanguageDialog));
private static LanguageDialog uniqueInstance;
private ILanguage language = Language.GetInstance();
private LanguageDialog() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
this.Load += FormLoad;
}
public string SelectedLanguage {
get { return comboBoxLanguage.SelectedValue.ToString(); }
}
protected void FormLoad(object sender, EventArgs e) {
// Initialize the Language ComboBox
this.comboBoxLanguage.DisplayMember = "Description";
this.comboBoxLanguage.ValueMember = "Ietf";
// Set datasource last to prevent problems
// See: http://www.codeproject.com/KB/database/scomlistcontrolbinding.aspx?fid=111644
this.comboBoxLanguage.DataSource = language.SupportedLanguages;
if (language.CurrentLanguage != null) {
LOG.DebugFormat("Selecting {0}", language.CurrentLanguage);
this.comboBoxLanguage.SelectedValue = language.CurrentLanguage;
}
}
void BtnOKClick(object sender, EventArgs e) {
this.Close();
}
public static LanguageDialog GetInstance() {
if(uniqueInstance == null) {
uniqueInstance = new LanguageDialog();
}
return uniqueInstance;
}
}
}

286
Greenshot/Forms/MainForm.Designer.cs generated Normal file
View file

@ -0,0 +1,286 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot {
partial class MainForm {
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
this.contextmenu_capturearea = new System.Windows.Forms.ToolStripMenuItem();
this.contextmenu_capturelastregion = new System.Windows.Forms.ToolStripMenuItem();
this.contextmenu_capturewindow = new System.Windows.Forms.ToolStripMenuItem();
this.contextmenu_capturefullscreen = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
this.contextmenu_captureclipboard = new System.Windows.Forms.ToolStripMenuItem();
this.contextmenu_openfile = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
this.contextmenu_quicksettings = new System.Windows.Forms.ToolStripMenuItem();
this.contextmenu_settings = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator3 = new System.Windows.Forms.ToolStripSeparator();
this.contextmenu_help = new System.Windows.Forms.ToolStripMenuItem();
this.contextmenu_about = new System.Windows.Forms.ToolStripMenuItem();
this.contextmenu_donate = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
this.contextmenu_exit = new System.Windows.Forms.ToolStripMenuItem();
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.contextmenu_captureie = new System.Windows.Forms.ToolStripMenuItem();
this.backgroundWorkerTimer = new System.Windows.Forms.Timer(this.components);
this.toolStripSeparator5 = new System.Windows.Forms.ToolStripSeparator();
this.contextmenu_openrecentcapture = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenu.SuspendLayout();
this.SuspendLayout();
//
// contextMenu
//
this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.contextmenu_capturearea,
this.contextmenu_capturelastregion,
this.contextmenu_capturewindow,
this.contextmenu_capturefullscreen,
this.contextmenu_captureie,
this.toolStripSeparator4,
this.contextmenu_captureclipboard,
this.contextmenu_openfile,
this.toolStripSeparator2,
this.contextmenu_openrecentcapture,
this.toolStripSeparator5,
this.contextmenu_quicksettings,
this.contextmenu_settings,
this.toolStripSeparator3,
this.contextmenu_help,
this.contextmenu_donate,
this.contextmenu_about,
this.toolStripSeparator1,
this.contextmenu_exit});
this.contextMenu.Name = "contextMenu";
this.contextMenu.Size = new System.Drawing.Size(243, 314);
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuOpening);
this.contextMenu.Closing += new System.Windows.Forms.ToolStripDropDownClosingEventHandler(this.ContextMenuClosing);
//
// contextmenu_capturearea
//
this.contextmenu_capturearea.Name = "contextmenu_capturearea";
this.contextmenu_capturearea.ShortcutKeyDisplayString = "Print";
this.contextmenu_capturearea.Size = new System.Drawing.Size(242, 22);
this.contextmenu_capturearea.Text = "Capture region";
this.contextmenu_capturearea.Click += new System.EventHandler(this.CaptureAreaToolStripMenuItemClick);
//
// contextmenu_capturelastregion
//
this.contextmenu_capturelastregion.Enabled = false;
this.contextmenu_capturelastregion.Name = "contextmenu_capturelastregion";
this.contextmenu_capturelastregion.ShortcutKeyDisplayString = "Shift + Print";
this.contextmenu_capturelastregion.Size = new System.Drawing.Size(242, 22);
this.contextmenu_capturelastregion.Text = "Capture last region";
this.contextmenu_capturelastregion.Click += new System.EventHandler(this.Contextmenu_capturelastregionClick);
//
// contextmenu_capturewindow
//
this.contextmenu_capturewindow.Name = "contextmenu_capturewindow";
this.contextmenu_capturewindow.ShortcutKeyDisplayString = "Alt + Print";
this.contextmenu_capturewindow.Size = new System.Drawing.Size(242, 22);
this.contextmenu_capturewindow.Text = "Capture window";
this.contextmenu_capturewindow.MouseEnter += new System.EventHandler(EnterCaptureWindowMenuItem);
//
// contextmenu_capturefullscreen
//
this.contextmenu_capturefullscreen.Name = "contextmenu_capturefullscreen";
this.contextmenu_capturefullscreen.ShortcutKeyDisplayString = "Ctrl + Print";
this.contextmenu_capturefullscreen.Size = new System.Drawing.Size(242, 22);
this.contextmenu_capturefullscreen.Text = "Capture full screen";
this.contextmenu_capturefullscreen.Click += new System.EventHandler(this.CaptureFullScreenToolStripMenuItemClick);
//
// toolStripSeparator4
//
this.toolStripSeparator4.Name = "toolStripSeparator4";
this.toolStripSeparator4.Size = new System.Drawing.Size(239, 6);
//
// contextmenu_captureclipboard
//
this.contextmenu_captureclipboard.Name = "contextmenu_captureclipboard";
this.contextmenu_captureclipboard.Size = new System.Drawing.Size(242, 22);
this.contextmenu_captureclipboard.Text = "Capture clipboard";
this.contextmenu_captureclipboard.Click += new System.EventHandler(this.CaptureClipboardToolStripMenuItemClick);
//
// contextmenu_openfile
//
this.contextmenu_openfile.Name = "contextmenu_openfile";
this.contextmenu_openfile.Size = new System.Drawing.Size(242, 22);
this.contextmenu_openfile.Text = "Open File";
this.contextmenu_openfile.Click += new System.EventHandler(this.OpenFileToolStripMenuItemClick);
//
// toolStripSeparator2
//
this.toolStripSeparator2.Name = "toolStripSeparator2";
this.toolStripSeparator2.Size = new System.Drawing.Size(239, 6);
//
// contextmenu_quicksettings
//
this.contextmenu_quicksettings.Name = "contextmenu_quicksettings";
this.contextmenu_quicksettings.Size = new System.Drawing.Size(242, 22);
this.contextmenu_quicksettings.Text = "Quick settings";
//
// contextmenu_settings
//
this.contextmenu_settings.Image = ((System.Drawing.Image)(resources.GetObject("contextmenu_settings.Image")));
this.contextmenu_settings.Name = "contextmenu_settings";
this.contextmenu_settings.Size = new System.Drawing.Size(242, 22);
this.contextmenu_settings.Text = "Settings";
this.contextmenu_settings.Click += new System.EventHandler(this.Contextmenu_settingsClick);
//
// toolStripSeparator3
//
this.toolStripSeparator3.Name = "toolStripSeparator3";
this.toolStripSeparator3.Size = new System.Drawing.Size(239, 6);
//
// contextmenu_help
//
this.contextmenu_help.Image = ((System.Drawing.Image)(resources.GetObject("contextmenu_help.Image")));
this.contextmenu_help.Name = "contextmenu_help";
this.contextmenu_help.Size = new System.Drawing.Size(242, 22);
this.contextmenu_help.Text = "Help";
this.contextmenu_help.Click += new System.EventHandler(this.Contextmenu_helpClick);
//
// contextmenu_about
//
this.contextmenu_about.Name = "contextmenu_about";
this.contextmenu_about.Size = new System.Drawing.Size(242, 22);
this.contextmenu_about.Text = "About";
this.contextmenu_about.Click += new System.EventHandler(this.Contextmenu_aboutClick);
//
// contextmenu_donate
//
this.contextmenu_donate.Image = ((System.Drawing.Image)(resources.GetObject("contextmenu_donate.Image")));
this.contextmenu_donate.Name = "contextmenu_donate";
this.contextmenu_donate.Size = new System.Drawing.Size(242, 22);
this.contextmenu_donate.Text = "Support Greenshot";
this.contextmenu_donate.Click += new System.EventHandler(this.Contextmenu_donateClick);
//
// toolStripSeparator1
//
this.toolStripSeparator1.Name = "toolStripSeparator1";
this.toolStripSeparator1.Size = new System.Drawing.Size(239, 6);
//
// contextmenu_exit
//
this.contextmenu_exit.Image = ((System.Drawing.Image)(resources.GetObject("contextmenu_exit.Image")));
this.contextmenu_exit.Name = "contextmenu_exit";
this.contextmenu_exit.Size = new System.Drawing.Size(242, 22);
this.contextmenu_exit.Text = "Exit";
this.contextmenu_exit.Click += new System.EventHandler(this.Contextmenu_exitClick);
//
// notifyIcon
//
this.notifyIcon.ContextMenuStrip = this.contextMenu;
this.notifyIcon.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.notifyIcon.Text = "Greenshot";
this.notifyIcon.Visible = false;
this.notifyIcon.Click += new System.EventHandler(this.NotifyIconClick);
//
// contextmenu_captureie
//
this.contextmenu_captureie.Name = "contextmenu_captureie";
this.contextmenu_captureie.Size = new System.Drawing.Size(231, 22);
this.contextmenu_captureie.Text = "Capture IE Tab";
this.contextmenu_captureie.ShortcutKeyDisplayString = "Ctrl + Shift + Print";
this.contextmenu_captureie.MouseEnter += new System.EventHandler(EnterCaptureIEMenuItem);
//
// backgroundWorkerTimer
//
this.backgroundWorkerTimer.Enabled = true;
this.backgroundWorkerTimer.Interval = 300000;
this.backgroundWorkerTimer.Tick += new System.EventHandler(this.BackgroundWorkerTimerTick);
//
// toolStripSeparator5
//
this.toolStripSeparator5.Name = "toolStripSeparator5";
this.toolStripSeparator5.Size = new System.Drawing.Size(240, 6);
//
// contextmenu_openrecentcapture
//
this.contextmenu_openrecentcapture.Name = "contextmenu_openrecentcapture";
this.contextmenu_openrecentcapture.Size = new System.Drawing.Size(243, 22);
this.contextmenu_openrecentcapture.Text = "Open recent capture location";
this.contextmenu_openrecentcapture.Click += new System.EventHandler(this.Contextmenu_OpenRecent);
//
// MainForm
//
this.ClientSize = new System.Drawing.Size(0, 0);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "MainForm";
this.Text = "Greenshot";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.MainFormFormClosing);
this.Activated += new System.EventHandler(this.MainFormActivated);
this.contextMenu.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.ToolStripSeparator toolStripSeparator5;
private System.Windows.Forms.ToolStripMenuItem contextmenu_openrecentcapture;
private System.Windows.Forms.Timer backgroundWorkerTimer;
private System.Windows.Forms.ToolStripMenuItem contextmenu_captureie;
private System.Windows.Forms.ToolStripMenuItem contextmenu_donate;
private System.Windows.Forms.ToolStripMenuItem contextmenu_openfile;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
private System.Windows.Forms.ToolStripMenuItem contextmenu_captureclipboard;
private System.Windows.Forms.ToolStripMenuItem contextmenu_quicksettings;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator3;
private System.Windows.Forms.ToolStripMenuItem contextmenu_help;
private System.Windows.Forms.ToolStripMenuItem contextmenu_capturewindow;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
private System.Windows.Forms.ToolStripMenuItem contextmenu_about;
private System.Windows.Forms.ToolStripMenuItem contextmenu_capturefullscreen;
private System.Windows.Forms.ToolStripMenuItem contextmenu_capturelastregion;
private System.Windows.Forms.ToolStripMenuItem contextmenu_capturearea;
private System.Windows.Forms.NotifyIcon notifyIcon;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
private System.Windows.Forms.ToolStripMenuItem contextmenu_exit;
private System.Windows.Forms.ContextMenuStrip contextMenu;
private System.Windows.Forms.ToolStripMenuItem contextmenu_settings;
}
}

888
Greenshot/Forms/MainForm.cs Normal file
View file

@ -0,0 +1,888 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Printing;
using System.IO;
using System.Reflection;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using Greenshot.Configuration;
using Greenshot.Drawing;
using Greenshot.Experimental;
using Greenshot.Forms;
using Greenshot.Help;
using Greenshot.Helpers;
using Greenshot.Plugin;
using Greenshot.UnmanagedHelpers;
using GreenshotPlugin.Controls;
using GreenshotPlugin.Core;
namespace Greenshot {
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form {
private const string LOG4NET_FILE = "log4net.xml";
private static log4net.ILog LOG = null;
private static Mutex applicationMutex = null;
private static CoreConfiguration conf;
private static void InitializeLog4NET() {
// Setup log4j, currently the file is called log4net.xml
string log4netFilename = Path.Combine(Application.StartupPath, LOG4NET_FILE);
if (File.Exists(log4netFilename)) {
log4net.Config.XmlConfigurator.Configure(new FileInfo(log4netFilename));
} else {
MessageBox.Show("Can't find file " + LOG4NET_FILE);
}
// Setup the LOG
LOG = log4net.LogManager.GetLogger(typeof(MainForm));
}
[STAThread]
public static void Main(string[] args) {
bool isAlreadyRunning = false;
List<string> filesToOpen = new List<string>();
// Set the Thread name, is better than "1"
Thread.CurrentThread.Name = Application.ProductName;
// Init Log4NET
InitializeLog4NET();
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
// Log the startup
LOG.Info("Starting: " + EnvironmentInfo.EnvironmentToString(false));
AppConfig.UpgradeToIni();
// Read configuration
conf = IniConfig.GetIniSection<CoreConfiguration>();
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));
bool created = false;
// 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;
}
if (args.Length > 0 && LOG.IsDebugEnabled) {
StringBuilder argumentString = new StringBuilder();
for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
argumentString.Append("[").Append(args[argumentNr]).Append("] ");
}
LOG.Debug("Greenshot arguments: " + argumentString.ToString());
}
for(int argumentNr = 0; argumentNr < args.Length; argumentNr++) {
string argument = args[argumentNr];
// Help
if (argument.ToLower().Equals("/help")) {
// Try to attach to the console
bool attachedToConsole = Kernel32.AttachConsole(Kernel32.ATTACHCONSOLE_ATTACHPARENTPROCESS);
// If attach didn't work, open a console
if (!attachedToConsole) {
Kernel32.AllocConsole();
}
StringBuilder helpOutput = new StringBuilder();
helpOutput.AppendLine();
helpOutput.AppendLine("Greenshot commandline options:");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t/help");
helpOutput.AppendLine("\t\tThis help.");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t/exit");
helpOutput.AppendLine("\t\tTries to close all running instances.");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t/reload");
helpOutput.AppendLine("\t\tReload the configuration of Greenshot.");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t/language [language code]");
helpOutput.AppendLine("\t\tSet the language of Greenshot, e.g. greenshot /language en-EN.");
helpOutput.AppendLine();
helpOutput.AppendLine();
helpOutput.AppendLine("\t[filename]");
helpOutput.AppendLine("\t\tOpen the bitmap files in the running Greenshot instance or start a new instance");
Console.WriteLine(helpOutput.ToString());
// If attach didn't work, wait for key otherwise the console will close to quickly
if (!attachedToConsole) {
Console.ReadKey();
}
FreeMutex();
return;
}
if (argument.ToLower().Equals("/exit")) {
// unregister application on uninstall (allow uninstall)
try {
LOG.Info("Sending all instances the exit command.");
// Pass Exit to running instance, if any
SendData(new CopyDataTransport(CommandEnum.Exit));
} catch (Exception e) {
LOG.Warn("Exception by exit.", e);
}
FreeMutex();
return;
}
// Reload the configuration
if (argument.ToLower().Equals("/reload")) {
// Modify configuration
LOG.Info("Reloading configuration!");
// Update running instances
SendData(new CopyDataTransport(CommandEnum.ReloadConfig));
FreeMutex();
return;
}
// Stop running
if (argument.ToLower().Equals("/norun")) {
// Make an exit possible
FreeMutex();
return;
}
// Language
if (argument.ToLower().Equals("/language")) {
conf.Language = args[++argumentNr];
IniConfig.Save();
continue;
}
// Files to open
filesToOpen.Add(argument);
}
// Finished parsing the command line arguments, see if we need to do anything
CopyDataTransport transport = new CopyDataTransport();
if (filesToOpen.Count > 0) {
foreach(string fileToOpen in filesToOpen) {
transport.AddCommand(CommandEnum.OpenFile, fileToOpen);
}
}
ILanguage lang = Language.GetInstance();
if (isAlreadyRunning) {
if (filesToOpen.Count > 0) {
SendData(transport);
} else {
MessageBox.Show(lang.GetString(LangKey.error_multipleinstances), lang.GetString(LangKey.error));
}
FreeMutex();
Application.Exit();
return;
}
// From here on we continue starting Greenshot
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// if language is not set, show language dialog
if(conf.Language == null || conf.Language.Trim().Length == 0) {
LanguageDialog ld = LanguageDialog.GetInstance();
ld.ShowDialog();
conf.Language = ld.SelectedLanguage;
IniConfig.Save();
}
// Check if it's the first time launch?
if(conf.IsFirstLaunch) {
conf.IsFirstLaunch = false;
IniConfig.Save();
transport.AddCommand(CommandEnum.FirstLaunch);
}
MainForm mainForm = new MainForm(transport);
Application.Run(mainForm);
} catch(Exception ex) {
LOG.Error("Exception in startup.", ex);
Application_ThreadException(MainForm.ActiveForm, new ThreadExceptionEventArgs(ex));
}
}
/// <summary>
/// Send DataTransport Object via Window-messages
/// </summary>
/// <param name="dataTransport">DataTransport with data for a running instance</param>
private static void SendData(CopyDataTransport dataTransport) {
string appName = Application.ProductName;
CopyData copyData = new CopyData();
copyData.Channels.Add(appName);
copyData.Channels[appName].Send(dataTransport);
}
private static void FreeMutex() {
// Remove the application mutex
if (applicationMutex != null) {
try {
applicationMutex.ReleaseMutex();
applicationMutex = null;
} catch (Exception ex) {
LOG.Error("Error releasing Mutex!", ex);
}
}
}
public static MainForm instance = null;
private ILanguage lang;
private ToolTip tooltip;
private CaptureForm captureForm = null;
private CopyData copyData = null;
public MainForm(CopyDataTransport dataTransport) {
instance = this;
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
lang = Language.GetInstance();
IniConfig.IniChanged += new FileSystemEventHandler(ReloadConfiguration);
// Make sure all hotkeys pass this window!
HotkeyControl.RegisterHotkeyHWND(this.Handle);
RegisterHotkeys();
tooltip = new ToolTip();
UpdateUI();
InitializeQuickSettingsMenu();
captureForm = new CaptureForm();
// Load all the plugins
PluginHelper.instance.LoadPlugins(this, captureForm);
SoundHelper.Initialize();
// Enable the Greenshot icon to be visible, this prevents Problems with the context menu
notifyIcon.Visible = true;
// Create a new instance of the class: copyData = new CopyData();
copyData = new CopyData();
// Assign the handle:
copyData.AssignHandle(this.Handle);
// Create the channel to send on:
copyData.Channels.Add("Greenshot");
// Hook up received event:
copyData.CopyDataReceived += new CopyDataReceivedEventHandler(CopyDataDataReceived);
if (dataTransport != null) {
HandleDataTransport(dataTransport);
}
ClipboardHelper.RegisterClipboardViewer(this.Handle);
}
/// <summary>
/// DataReceivedEventHandler
/// </summary>
/// <param name="sender"></param>
/// <param name="dataReceivedEventArgs"></param>
private void CopyDataDataReceived(object sender, CopyDataReceivedEventArgs copyDataReceivedEventArgs) {
// Cast the data to the type of object we sent:
CopyDataTransport dataTransport = (CopyDataTransport)copyDataReceivedEventArgs.Data;
HandleDataTransport(dataTransport);
}
private void HandleDataTransport(CopyDataTransport dataTransport) {
foreach(KeyValuePair<CommandEnum, string> command in dataTransport.Commands) {
LOG.Debug("Data received, Command = " + command.Key + ", Data: " + command.Value);
switch(command.Key) {
case CommandEnum.Exit:
exit();
break;
case CommandEnum.FirstLaunch:
LOG.Info("FirstLaunch: Created new configuration.");
break;
case CommandEnum.ReloadConfig:
IniConfig.Reload();
ReloadConfiguration(null, null);
break;
case CommandEnum.OpenFile:
string filename = command.Value;
if (File.Exists(filename)) {
captureForm.MakeCapture(filename);
} else {
LOG.Warn("No such file: " + filename);
}
break;
default:
LOG.Error("Unknown command!");
break;
}
}
}
private void ReloadConfiguration(object source, FileSystemEventArgs e) {
lang.SetLanguage(conf.Language);
this.Invoke((MethodInvoker) delegate {
// Even update language when needed
UpdateUI();
// Update the hotkey
// Make sure the current hotkeys are disabled
HotkeyControl.UnregisterHotkeys();
RegisterHotkeys();
});
}
public ContextMenuStrip MainMenu {
get {return contextMenu;}
}
#region hotkeys
protected override void WndProc(ref Message m) {
if (ClipboardHelper.HandleClipboardMessages(ref m)) {
return;
}
if (HotkeyControl.HandleMessages(ref m)) {
return;
}
base.WndProc(ref m);
}
public static void RegisterHotkeys() {
if (instance == null) {
return;
}
bool success = true;
StringBuilder failedKeys = new StringBuilder();
// Capture region
if (HotkeyControl.RegisterHotKey(conf.RegionHotkey, new HotKeyHandler(instance.CaptureRegion)) < 0) {
LOG.DebugFormat("Failed to register CaptureRegion to hotkey: {0}", conf.RegionHotkey);
success = false;
if(failedKeys.Length > 0) {
failedKeys.Append(", ");
}
failedKeys.Append(conf.RegionHotkey);
} else {
LOG.DebugFormat("Registered CaptureRegion to hotkey: {0}", conf.RegionHotkey);
}
// Capture window
if (HotkeyControl.RegisterHotKey(conf.WindowHotkey, new HotKeyHandler(instance.CaptureWindow)) < 0) {
LOG.DebugFormat("Failed to register CaptureWindow to hotkey: {0}", conf.WindowHotkey);
success = false;
if(failedKeys.Length > 0) {
failedKeys.Append(", ");
}
failedKeys.Append(conf.WindowHotkey);
} else {
LOG.DebugFormat("Registered CaptureWindow to hotkey: {0}", conf.WindowHotkey);
}
// Capture fullScreen
if (HotkeyControl.RegisterHotKey(conf.FullscreenHotkey, new HotKeyHandler(instance.CaptureFullScreen)) < 0) {
LOG.DebugFormat("Failed to register CaptureFullScreen to hotkey: {0}", conf.FullscreenHotkey);
success = false;
if(failedKeys.Length > 0) {
failedKeys.Append(", ");
}
failedKeys.Append(conf.FullscreenHotkey);
} else {
LOG.DebugFormat("Registered CaptureFullScreen to hotkey: {0}", conf.FullscreenHotkey);
}
// Capture last region
if (HotkeyControl.RegisterHotKey(conf.LastregionHotkey, new HotKeyHandler(instance.CaptureLastRegion)) < 0) {
LOG.DebugFormat("Failed to register CaptureLastRegion to hotkey: {0}", conf.LastregionHotkey);
success = false;
if(failedKeys.Length > 0) {
failedKeys.Append(", ");
}
failedKeys.Append(conf.LastregionHotkey);
} else {
LOG.DebugFormat("Registered CaptureLastRegion to hotkey: {0}", conf.LastregionHotkey);
}
// Capture IE
if (HotkeyControl.RegisterHotKey(conf.IEHotkey, new HotKeyHandler(instance.CaptureIE)) < 0) {
LOG.DebugFormat("Failed to register CaptureIE to hotkey: {0}", conf.IEHotkey);
success = false;
if(failedKeys.Length > 0) {
failedKeys.Append(", ");
}
failedKeys.Append(conf.IEHotkey);
} else {
LOG.DebugFormat("Registered CaptureIE to hotkey: {0}", conf.IEHotkey);
}
if (!success) {
ILanguage lang = Language.GetInstance();
MessageBox.Show(lang.GetFormattedString(LangKey.warning_hotkeys, failedKeys.ToString()),lang.GetString(LangKey.warning));
}
}
#endregion
public void UpdateUI() {
this.Text = lang.GetString(LangKey.application_title);
this.contextmenu_settings.Text = lang.GetString(LangKey.contextmenu_settings);
this.contextmenu_capturearea.Text = lang.GetString(LangKey.contextmenu_capturearea);
this.contextmenu_capturelastregion.Text = lang.GetString(LangKey.contextmenu_capturelastregion);
this.contextmenu_capturewindow.Text = lang.GetString(LangKey.contextmenu_capturewindow);
this.contextmenu_capturefullscreen.Text = lang.GetString(LangKey.contextmenu_capturefullscreen);
this.contextmenu_captureclipboard.Text = lang.GetString(LangKey.contextmenu_captureclipboard);
this.contextmenu_openfile.Text = lang.GetString(LangKey.contextmenu_openfile);
this.contextmenu_quicksettings.Text = lang.GetString(LangKey.contextmenu_quicksettings);
this.contextmenu_help.Text = lang.GetString(LangKey.contextmenu_help);
this.contextmenu_about.Text = lang.GetString(LangKey.contextmenu_about);
this.contextmenu_donate.Text = lang.GetString(LangKey.contextmenu_donate);
this.contextmenu_exit.Text = lang.GetString(LangKey.contextmenu_exit);
this.contextmenu_captureie.Text = lang.GetString(LangKey.contextmenu_captureie);
this.contextmenu_openrecentcapture.Text = lang.GetString(LangKey.contextmenu_openrecentcapture);
// Show hotkeys in Contextmenu
this.contextmenu_capturearea.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(conf.RegionHotkey);
this.contextmenu_capturelastregion.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(conf.LastregionHotkey);
this.contextmenu_capturewindow.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(conf.WindowHotkey);
this.contextmenu_capturefullscreen.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(conf.FullscreenHotkey);
this.contextmenu_captureie.ShortcutKeyDisplayString = HotkeyControl.GetLocalizedHotkeyStringFromString(conf.IEHotkey);
}
#region mainform events
void MainFormFormClosing(object sender, FormClosingEventArgs e) {
instance = null;
exit();
}
void MainFormActivated(object sender, EventArgs e) {
Hide();
ShowInTaskbar = false;
}
#endregion
#region key handlers
void CaptureRegion() {
captureForm.MakeCapture(CaptureMode.Region, true);
}
void CaptureClipboard() {
captureForm.MakeCapture(CaptureMode.Clipboard, false);
}
void CaptureFile() {
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Image files (*.png, *.jpg, *.gif, *.bmp, *.ico)|*.png; *.jpg; *.jpeg; *.gif; *.bmp; *.ico";
if (openFileDialog.ShowDialog() == DialogResult.OK) {
if (File.Exists(openFileDialog.FileName)) {
captureForm.MakeCapture(openFileDialog.FileName);
}
}
}
void CaptureFullScreen() {
captureForm.MakeCapture(CaptureMode.FullScreen, true);
}
void CaptureLastRegion() {
captureForm.MakeCapture(CaptureMode.LastRegion, true);
}
void CaptureIE() {
captureForm.MakeCapture(CaptureMode.IE, true);
}
void CaptureWindow() {
CaptureMode captureMode = CaptureMode.None;
if (conf.CaptureWindowsInteractive) {
captureMode = CaptureMode.Window;
} else {
captureMode = CaptureMode.ActiveWindow;
}
captureForm.MakeCapture(captureMode, true);
}
#endregion
#region contextmenu
void ContextMenuOpening(object sender, System.ComponentModel.CancelEventArgs e) {
if (Clipboard.ContainsImage()) {
contextmenu_captureclipboard.Enabled = true;
} else {
contextmenu_captureclipboard.Enabled = false;
}
contextmenu_capturelastregion.Enabled = RuntimeConfig.LastCapturedRegion != Rectangle.Empty;
// IE context menu code
if (conf.IECapture && IECaptureHelper.IsIERunning()) {
this.contextmenu_captureie.Enabled = true;
} else {
this.contextmenu_captureie.Enabled = false;
}
}
void ContextMenuClosing(object sender, EventArgs e) {
this.contextmenu_captureie.DropDownItems.Clear();
this.contextmenu_capturewindow.DropDownItems.Clear();
}
/// <summary>
/// Build a selectable list of IE tabs when we enter the menu item
/// </summary>
void EnterCaptureIEMenuItem(object sender, EventArgs e) {
List<KeyValuePair<WindowDetails, string>> tabs = IECaptureHelper.GetTabList();
this.contextmenu_captureie.DropDownItems.Clear();
if (tabs.Count > 0) {
this.contextmenu_captureie.Enabled = true;
Dictionary<WindowDetails, int> counter = new Dictionary<WindowDetails, int>();
foreach(KeyValuePair<WindowDetails, string> tabData in tabs) {
ToolStripMenuItem captureIETabItem = new ToolStripMenuItem(tabData.Value);
int index;
if (counter.ContainsKey(tabData.Key)) {
index = counter[tabData.Key];
} else {
index = 0;
}
captureIETabItem.Tag = new KeyValuePair<WindowDetails, int>(tabData.Key, index++);
captureIETabItem.Click += new System.EventHandler(Contextmenu_captureIE_Click);
this.contextmenu_captureie.DropDownItems.Add(captureIETabItem);
if (counter.ContainsKey(tabData.Key)) {
counter[tabData.Key] = index;
} else {
counter.Add(tabData.Key, index);
}
}
} else {
this.contextmenu_captureie.Enabled = false;
}
}
/// <summary>
/// Build a selectable list of windows when we enter the menu item
/// </summary>
void EnterCaptureWindowMenuItem(object sender, EventArgs e) {
// The Capture window context menu item used to go to the following code:
// captureForm.MakeCapture(CaptureMode.Window, false);
// Now we check which windows are there to capture
ToolStripMenuItem captureWindowMenuItem = (ToolStripMenuItem)sender;
AddCaptureWindowMenuItems(captureWindowMenuItem, Contextmenu_window_Click);
}
public static void AddCaptureWindowMenuItems(ToolStripMenuItem menuItem, EventHandler eventHandler) {
ILanguage lang = Language.GetInstance();
menuItem.DropDownItems.Clear();
List<WindowDetails> windows = WindowDetails.GetVisibleWindows();
foreach(WindowDetails window in windows) {
ToolStripMenuItem captureWindowItem = new ToolStripMenuItem(window.Text);
captureWindowItem.Tag = window;
captureWindowItem.Click += new System.EventHandler(eventHandler);
menuItem.DropDownItems.Add(captureWindowItem);
}
}
void CaptureAreaToolStripMenuItemClick(object sender, EventArgs e) {
captureForm.MakeCapture(CaptureMode.Region, false);
}
void CaptureClipboardToolStripMenuItemClick(object sender, EventArgs e) {
CaptureClipboard();
}
void OpenFileToolStripMenuItemClick(object sender, EventArgs e) {
CaptureFile();
}
void CaptureFullScreenToolStripMenuItemClick(object sender, EventArgs e) {
captureForm.MakeCapture(CaptureMode.FullScreen, false);
}
void Contextmenu_capturelastregionClick(object sender, EventArgs e) {
captureForm.MakeCapture(CaptureMode.LastRegion, false);
}
void Contextmenu_window_Click(object sender,EventArgs e) {
ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
try {
WindowDetails windowToCapture = (WindowDetails)clickedItem.Tag;
captureForm.MakeCapture(windowToCapture);
} catch (Exception exception) {
LOG.Error(exception);
}
}
void Contextmenu_captureIE_Click(object sender, EventArgs e) {
if (!conf.IECapture) {
LOG.InfoFormat("IE Capture is disabled.");
return;
}
ToolStripMenuItem clickedItem = (ToolStripMenuItem)sender;
KeyValuePair<WindowDetails, int> tabData = (KeyValuePair<WindowDetails, int>)clickedItem.Tag;
try {
IECaptureHelper.ActivateIETab(tabData.Key, tabData.Value);
} catch (Exception exception) {
LOG.Error(exception);
}
try {
captureForm.MakeCapture(CaptureMode.IE, false);
} catch (Exception exception) {
LOG.Error(exception);
}
}
void Contextmenu_donateClick(object sender, EventArgs e) {
Process.Start("http://getgreenshot.org/support/");
}
void Contextmenu_settingsClick(object sender, EventArgs e) {
SettingsForm settings = new SettingsForm();
settings.ShowDialog();
InitializeQuickSettingsMenu();
this.Hide();
}
void Contextmenu_aboutClick(object sender, EventArgs e) {
new AboutForm().Show();
}
void Contextmenu_helpClick(object sender, EventArgs e) {
HelpBrowserForm hpf = new HelpBrowserForm(conf.Language);
hpf.Show();
}
void Contextmenu_exitClick(object sender, EventArgs e) {
exit();
}
private void InitializeQuickSettingsMenu() {
this.contextmenu_quicksettings.DropDownItems.Clear();
// screenshot destination
ToolStripMenuSelectList selectList = new ToolStripMenuSelectList("destination",true);
selectList.Text = lang.GetString(LangKey.settings_destination);
selectList.AddItem(lang.GetString(LangKey.settings_destination_editor), Destination.Editor, conf.OutputDestinations.Contains(Destination.Editor));
selectList.AddItem(lang.GetString(LangKey.settings_destination_clipboard), Destination.Clipboard, conf.OutputDestinations.Contains(Destination.Clipboard));
selectList.AddItem(lang.GetString(LangKey.quicksettings_destination_file), Destination.FileDefault, conf.OutputDestinations.Contains(Destination.FileDefault));
selectList.AddItem(lang.GetString(LangKey.settings_destination_fileas), Destination.FileWithDialog, conf.OutputDestinations.Contains(Destination.FileWithDialog));
selectList.AddItem(lang.GetString(LangKey.settings_destination_printer), Destination.Printer, conf.OutputDestinations.Contains(Destination.Printer));
selectList.AddItem(lang.GetString(LangKey.settings_destination_email), Destination.EMail, conf.OutputDestinations.Contains(Destination.EMail));
selectList.CheckedChanged += new EventHandler(this.QuickSettingItemChanged);
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
// print options
selectList = new ToolStripMenuSelectList("printoptions",true);
selectList.Text = lang.GetString(LangKey.settings_printoptions);
selectList.AddItem(lang.GetString(LangKey.printoptions_allowshrink), "AllowPrintShrink", conf.OutputPrintAllowShrink);
selectList.AddItem(lang.GetString(LangKey.printoptions_allowenlarge), "AllowPrintEnlarge", conf.OutputPrintAllowEnlarge);
selectList.AddItem(lang.GetString(LangKey.printoptions_allowrotate), "AllowPrintRotate", conf.OutputPrintAllowRotate);
selectList.AddItem(lang.GetString(LangKey.printoptions_allowcenter), "AllowPrintCenter", conf.OutputPrintCenter);
selectList.CheckedChanged += new EventHandler(this.QuickSettingItemChanged);
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
// effects
selectList = new ToolStripMenuSelectList("effects",true);
selectList.Text = lang.GetString(LangKey.settings_visualization);
selectList.AddItem(lang.GetString(LangKey.settings_playsound), "PlaySound", conf.PlayCameraSound);
selectList.CheckedChanged += new EventHandler(this.QuickSettingItemChanged);
this.contextmenu_quicksettings.DropDownItems.Add(selectList);
}
void QuickSettingItemChanged(object sender, EventArgs e) {
ToolStripMenuSelectList selectList = (ToolStripMenuSelectList)sender;
ToolStripMenuSelectListItem item = ((ItemCheckedChangedEventArgs)e).Item;
if(selectList.Identifier.Equals("destination")) {
Destination selectedDestination = (Destination)item.Data;
if (item.Checked && !conf.OutputDestinations.Contains(selectedDestination)) {
conf.OutputDestinations.Add(selectedDestination);
}
if (!item.Checked && conf.OutputDestinations.Contains(selectedDestination)) {
conf.OutputDestinations.Remove(selectedDestination);
}
IniConfig.Save();
} else if(selectList.Identifier.Equals("printoptions")) {
if(item.Data.Equals("AllowPrintShrink")) conf.OutputPrintAllowShrink = item.Checked;
else if(item.Data.Equals("AllowPrintEnlarge")) conf.OutputPrintAllowEnlarge = item.Checked;
else if(item.Data.Equals("AllowPrintRotate")) conf.OutputPrintAllowRotate = item.Checked;
else if(item.Data.Equals("AllowPrintCenter")) conf.OutputPrintCenter = item.Checked;
IniConfig.Save();
} else if(selectList.Identifier.Equals("effects")) {
if(item.Data.Equals("PlaySound")) {
conf.PlayCameraSound = item.Checked;
}
IniConfig.Save();
}
}
#endregion
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) {
string exceptionText = EnvironmentInfo.BuildReport(e.ExceptionObject as Exception);
LOG.Error(exceptionText);
new BugReportForm(exceptionText).ShowDialog();
}
private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) {
string exceptionText = EnvironmentInfo.BuildReport(e.Exception);
LOG.Error(exceptionText);
new BugReportForm(exceptionText).ShowDialog();
}
private void NotifyIconClick(object sender, EventArgs eventArgs) {
MethodInfo oMethodInfo = typeof(NotifyIcon).GetMethod("ShowContextMenu", BindingFlags.Instance | BindingFlags.NonPublic);
oMethodInfo.Invoke(notifyIcon, null);
}
/// <summary>
/// The Contextmenu_OpenRecent currently opens the last know save location
/// </summary>
private void Contextmenu_OpenRecent(object sender, EventArgs eventArgs) {
string path;
string configPath = FilenameHelper.FillVariables(conf.OutputFilePath);
if (File.Exists(conf.OutputFileAsFullpath)) {
path = conf.OutputFileAsFullpath;
} else if (Directory.Exists(configPath)) {
path = configPath;
} else {
// What do I open when nothing can be found? Right, nothing...
return;
}
LOG.Debug("DoubleClick was called! Starting: " + path);
try {
System.Diagnostics.Process.Start(path);
} catch (Exception e) {
// Make sure we show what we tried to open in the exception
e.Data.Add("path", path);
throw e;
}
}
/// <summary>
/// Shutdown / cleanup
/// </summary>
public void exit() {
ClipboardHelper.DeregisterClipboardViewer(this.Handle);
LOG.Info("Exit: " + EnvironmentInfo.EnvironmentToString(false));
// 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 != this.Handle && !form.GetType().Equals(typeof(Greenshot.ImageEditorForm))) {
formsToClose.Add(form);
}
}
foreach(Form form in formsToClose) {
try {
LOG.InfoFormat("Closing form: {0}", form.Name);
this.Invoke((MethodInvoker) delegate { form.Close(); });
} catch (Exception e) {
LOG.Error("Error closing form!", e);
}
}
// Make sure hotkeys are disabled
try {
HotkeyControl.UnregisterHotkeys();
} catch (Exception e) {
LOG.Error("Error unregistering hotkeys!", e);
}
// Now the sound isn't needed anymore
try {
SoundHelper.Deinitialize();
} catch (Exception e) {
LOG.Error("Error deinitializing sound!", e);
}
// Inform all registed plugins
try {
PluginHelper.instance.Shutdown();
} catch (Exception e) {
LOG.Error("Error shutting down plugins!", e);
}
// Gracefull shutdown
try {
Application.DoEvents();
Application.Exit();
} catch (Exception e) {
LOG.Error("Error closing application!", e);
}
// Store any open configuration changes
try {
IniConfig.Save();
} catch (Exception e) {
LOG.Error("Error storing configuration!", e);
}
// Remove the application mutex
FreeMutex();
// make the icon invisible otherwise it stays even after exit!!
if (notifyIcon != null) {
notifyIcon.Visible = false;
notifyIcon.Dispose();
notifyIcon = null;
}
}
/// <summary>
/// Do work in the background
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BackgroundWorkerTimerTick(object sender, EventArgs e) {
LOG.Debug("BackgroundWorkerTimerTick");
if (UpdateHelper.IsUpdateCheckNeeded()) {
// Start update check in the background
Thread backgroundTask = new Thread (new ThreadStart(UpdateHelper.CheckAndAskForUpdate));
backgroundTask.IsBackground = true;
backgroundTask.Start();
}
}
}
}

View file

@ -0,0 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="contextmenu_settings.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAgpJREFUOE+lkMtr
GmEUxT9xIfgA3bhplRKUUDQljFCcdCEEgsRx4esfcBVC6aogtKRdBEoodNESs8omgST7BFcxD0hlAo6g
cSQm1KZWxiS4l4Kb2+8McZjQrBrhcC/n/s6ZGS1ExB71Q0EikWDJZJKl02mWyWT0mcvlRK6FO4nmG1hk
9IebC1Kp1AwHF/l8gjkajWg4HJLZA/NggSRJrwqFwtfBYED5fP49h15fX/cJwg4PNzBg771BPB5nXG+6
3S4pSpX6fY1KpdIPTdMIwt7pdPQbGLDIGJ8giiKLxWJPs9nsx7OzBjUadbq6+km93m9d2OHhBgYsMkZB
NBqNceMttLm50Wm1VNrZ2W6Hw+E1CDs83MYcMkaBIAiFWk2h4+MjOj2Vqdls0tTUixWr1cog7PBwAwMW
GaMgFAq9q1QqVC6XCVNVz2l6Wli2WCwMwg7PzCBjFASDwblAILAEra4Wf9XrLdrbO6hHIi8/QNjh4Tbm
kDEK/H4/8/l8zwQh8kWWa3R4+J0uLzW6vf2jCzs83MCARcYo8Hq9jGtZlhu0u7tPJyc1KhbXu9VqiyDs
8HADAxYZo8Dj8TCu+dnZuS1FuaDJyeff3G73J1lWeUAl7PBwAwMWmXsFHGJOpzPhcDhWXC7XBGa7fcP/
0B6ZPTBgHyzgILPb7bpsNpvE9flO0tgH808BXuV/9Rc0A+b+f/6UZAAAAABJRU5ErkJggg==
</value>
</data>
<data name="contextmenu_help.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAmRJREFUOE9j/P//
PwNFAGQAs85mBmbdrQzM+juAeKcEs8GuFCCeBcTboBjETgHLgdSA1AL1gC1HM8CD12LvZseMm7fSu99+
LJ725U/R1C9/0jrffrRPu3ELJAc0wAOXAR6idgcOpXe9/Zza/vp/QNENFJza/up/UturzyK2+w8BDfBA
c8EmSV7THVtS2l5+jqx+8N8r5xLQYaigpO/Wf5BcVN3jzzwm27cw62ySRHhBa32qTeLF22EVd/77FVz7
75l98f/ERVfBeNuhZ2CT5qx9AJYLLr313yj85G1moB64AUzqq+eGVd795J55/j8MO6Wc+m8eeeB/aceh
/2fOnPlf3rnnv4rb2v/qXhv+m0Ue/ATSgzBAdfnOyOq7f1zSzvx3SDr53zBk7391763/o4r3/j9//uL/
peuO/1fz3PRfzWsLGAPl/zAB9SAMUF68K7T85l/r+BP/dYIO/NcK2Pdfw2/n/9u3b4Oxpt8usBgM64ce
+ssE1IMwQGH+PKfUC58NIk//149AYE3/Pf9BGFkMxNYKOPqZCagHYYDc7AxV9713LZJv/jdNuAHGBpFn
/7979w6MQWyYOIiWst1xjwmoB2GA9HRJDsU5OywSb32xynj23yr96X+T+OtwA0BskBgIG0bf+MKmMGcH
E1APwgCpqQxMEpO8uFXmHjdLevjFPv/jfzsgNow6D8YgNgibJDz4wqU89zhILRNQD6oB4hMYGPmbvNlE
O/co2O54aJb4+ItDwde/IAxig8RAciA1TEC12A3ga2BgYCuVYmAtygbipUB8GIpB7GyQHCNQDYYBIKeQ
iwHBPxS/lCcjgAAAAABJRU5ErkJggg==
</value>
</data>
<data name="contextmenu_donate.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAihJREFUOE+lk11I
k2EYhp+FedxRgVEEQogGIYpBHVhKBrZBsDKWaLBGOmypC3FbMVcLlUUHYqzEcD9asr8y54GtlnP4s7VW
uVKoscSmkP1ARZEEcrdnxdjAE/OFi++D577u7+WDRwCANnTaThSIEtT9JyK6JM6Xr/74iN/fl9YFO+yS
+lhew8rXOOw9neuCHXapRbRb8fPzPJ49siM240sR8NiShaODRkSfezNmnGWHXWquzG36thxFcHQQn+KR
FJ2qOty5oYf/gRnG9paMGWfZYZcUFbsufFmcw+RIP2ZDHli7LiefBrUcE25rEn5Pn3GWHXZJXr6jdXkh
At/9Prx/G0xxXauAx3YLt69poD1fkzHjLDvskqw0R7MUC8Pr7EV4fChF6IkL7i4xxq3VmHIoMO1SYtom
Q9hehYfGk2CHXTp9YJt24U0QvQY17uoPY8wswWOLFMPGajj1JVj9MIBfsR7M+5qwOFaLlVdS2HXFYIdd
EhduaY9Hn+Ld3CT85poM4fU9CV66GxF0yuHuFsJzU4iw4xRCzkawwy4Vbd/cXJab3c2cO5TlDw5pMOVS
wdN3FjPDrWveoKMq6wXn2eU1yE6wNUFOQ6nAkX5lv0mC9EKv6QwCtnpcFG5q++ew+/cU7ySS7SO5WXdk
tv9qZWBAd3BEWS6wrPUPlGUC6/FCQeYOcoG0hOhKbT51yPaSQVaQVng0WWjRFHlNqj0R/lD9fiKGeJ03
wh+7ImBS7QvLFAAAAABJRU5ErkJggg==
</value>
</data>
<data name="contextmenu_exit.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAUNJREFUOE+lk79L
QlEcxW9/gqCrm6vg4uYoOAgOrqLk4ioP0r2Glhp0SSjoF1FE0BIUDU3RdIOGoKBVGlpapaHTObeuCPe6
9ITD5fs9n3Pue8JbAWBS/VSQRvPwKR/j3JgaZXVqPv5TzPOXLhYoZDEcQidVWyhw3qzfn3tBAWH7PRjg
uV7HV5JAM6USyX50u86btlrOCwoOCR7Q+Oz1cFcu473dhmbppdFwu8dq1e3EBgU0zB6NXQJvzSaui0U8
VCq4LZWwn8vhLJ+HPDFiowUEzITADsGrQgFHmYzTSTYL7eSJiRZs0timRoTGhC956wXDXtrJEyM2eAIt
t34Be8NgTPLELCuQYe8Z9tK8ZBf+ieuEnxj20rzB26SYF7zCGsGEoVeW6NTMoJFiXlDAkFllqMOwTs2+
IOYFBf/9oFJ9ibr0B4f94vVG3bWDAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="contextMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>293, 17</value>
</metadata>
<metadata name="notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>193, 17</value>
</metadata>
<metadata name="backgroundWorkerTimer.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View file

@ -0,0 +1,207 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 Thomas Braun, Jens Klingen, Robin Krom
*
* For more information see: http://getgreenshot.org/
* The Greenshot project is hosted on Sourceforge: http://sourceforge.net/projects/greenshot/
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Greenshot.Forms
{
partial class PrintOptionsDialog
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.checkbox_dontaskagain = new System.Windows.Forms.CheckBox();
this.checkboxAllowShrink = new System.Windows.Forms.CheckBox();
this.checkboxAllowEnlarge = new System.Windows.Forms.CheckBox();
this.checkboxAllowCenter = new System.Windows.Forms.CheckBox();
this.checkboxAllowRotate = new System.Windows.Forms.CheckBox();
this.button_ok = new System.Windows.Forms.Button();
this.checkboxDateTime = new System.Windows.Forms.CheckBox();
this.button_cancel = new System.Windows.Forms.Button();
this.checkboxPrintInverted = new System.Windows.Forms.CheckBox();
this.SuspendLayout();
//
// checkbox_dontaskagain
//
this.checkbox_dontaskagain.AutoSize = true;
this.checkbox_dontaskagain.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 152);
this.checkbox_dontaskagain.Name = "checkbox_dontaskagain";
this.checkbox_dontaskagain.Size = new System.Drawing.Size(206, 17);
this.checkbox_dontaskagain.TabIndex = 19;
this.checkbox_dontaskagain.Text = "Save as default and do not ask again.";
this.checkbox_dontaskagain.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkbox_dontaskagain.UseVisualStyleBackColor = true;
//
// checkboxAllowShrink
//
this.checkboxAllowShrink.AutoSize = true;
this.checkboxAllowShrink.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.Location = new System.Drawing.Point(12, 20);
this.checkboxAllowShrink.Name = "checkboxAllowShrink";
this.checkboxAllowShrink.Size = new System.Drawing.Size(191, 17);
this.checkboxAllowShrink.TabIndex = 21;
this.checkboxAllowShrink.Text = "Shrink large printouts to paper size.";
this.checkboxAllowShrink.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowShrink.UseVisualStyleBackColor = true;
//
// checkboxAllowEnlarge
//
this.checkboxAllowEnlarge.AutoSize = true;
this.checkboxAllowEnlarge.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.Location = new System.Drawing.Point(12, 43);
this.checkboxAllowEnlarge.Name = "checkboxAllowEnlarge";
this.checkboxAllowEnlarge.Size = new System.Drawing.Size(197, 17);
this.checkboxAllowEnlarge.TabIndex = 22;
this.checkboxAllowEnlarge.Text = "Enlarge small printouts to paper size.";
this.checkboxAllowEnlarge.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowEnlarge.UseVisualStyleBackColor = true;
//
// checkboxAllowCenter
//
this.checkboxAllowCenter.AutoSize = true;
this.checkboxAllowCenter.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.Location = new System.Drawing.Point(12, 89);
this.checkboxAllowCenter.Name = "checkboxAllowCenter";
this.checkboxAllowCenter.Size = new System.Drawing.Size(200, 17);
this.checkboxAllowCenter.TabIndex = 24;
this.checkboxAllowCenter.Text = "Align printouts centered on the page.";
this.checkboxAllowCenter.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowCenter.UseVisualStyleBackColor = true;
//
// checkboxAllowRotate
//
this.checkboxAllowRotate.AutoSize = true;
this.checkboxAllowRotate.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.Location = new System.Drawing.Point(12, 66);
this.checkboxAllowRotate.Name = "checkboxAllowRotate";
this.checkboxAllowRotate.Size = new System.Drawing.Size(195, 17);
this.checkboxAllowRotate.TabIndex = 23;
this.checkboxAllowRotate.Text = "Rotate printouts to page orientation.";
this.checkboxAllowRotate.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxAllowRotate.UseVisualStyleBackColor = true;
//
// button_ok
//
this.button_ok.DialogResult = System.Windows.Forms.DialogResult.OK;
this.button_ok.Location = new System.Drawing.Point(187, 179);
this.button_ok.Name = "button_ok";
this.button_ok.Size = new System.Drawing.Size(75, 23);
this.button_ok.TabIndex = 25;
this.button_ok.Text = "OK";
this.button_ok.UseVisualStyleBackColor = true;
this.button_ok.Click += new System.EventHandler(this.Button_okClick);
//
// checkboxDateTime
//
this.checkboxDateTime.AutoSize = true;
this.checkboxDateTime.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.Location = new System.Drawing.Point(12, 112);
this.checkboxDateTime.Name = "checkboxDateTime";
this.checkboxDateTime.Size = new System.Drawing.Size(187, 17);
this.checkboxDateTime.TabIndex = 26;
this.checkboxDateTime.Text = "Print date / time at bottom of page";
this.checkboxDateTime.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxDateTime.UseVisualStyleBackColor = true;
//
// button_cancel
//
this.button_cancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
this.button_cancel.Location = new System.Drawing.Point(268, 179);
this.button_cancel.Name = "button_cancel";
this.button_cancel.Size = new System.Drawing.Size(75, 23);
this.button_cancel.TabIndex = 27;
this.button_cancel.Text = "Cancel";
this.button_cancel.UseVisualStyleBackColor = true;
//
// checkBox1
//
this.checkboxPrintInverted.AutoSize = true;
this.checkboxPrintInverted.CheckAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.Location = new System.Drawing.Point(12, 132);
this.checkboxPrintInverted.Name = "checkBox1";
this.checkboxPrintInverted.Size = new System.Drawing.Size(88, 17);
this.checkboxPrintInverted.TabIndex = 28;
this.checkboxPrintInverted.Text = "Print inverted";
this.checkboxPrintInverted.TextAlign = System.Drawing.ContentAlignment.TopLeft;
this.checkboxPrintInverted.UseVisualStyleBackColor = true;
//
// PrintOptionsDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
this.ClientSize = new System.Drawing.Size(355, 212);
this.Controls.Add(this.checkboxPrintInverted);
this.Controls.Add(this.button_cancel);
this.Controls.Add(this.checkboxDateTime);
this.Controls.Add(this.button_ok);
this.Controls.Add(this.checkbox_dontaskagain);
this.Controls.Add(this.checkboxAllowCenter);
this.Controls.Add(this.checkboxAllowRotate);
this.Controls.Add(this.checkboxAllowEnlarge);
this.Controls.Add(this.checkboxAllowShrink);
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "PrintOptionsDialog";
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
this.Text = "PrintOptionsDialog";
this.ResumeLayout(false);
this.PerformLayout();
}
private System.Windows.Forms.CheckBox checkboxPrintInverted;
private System.Windows.Forms.Button button_cancel;
private System.Windows.Forms.CheckBox checkboxDateTime;
private System.Windows.Forms.Button button_ok;
private System.Windows.Forms.CheckBox checkboxAllowRotate;
private System.Windows.Forms.CheckBox checkboxAllowCenter;
private System.Windows.Forms.CheckBox checkboxAllowEnlarge;
private System.Windows.Forms.CheckBox checkboxAllowShrink;
private System.Windows.Forms.CheckBox checkbox_dontaskagain;
}
}

View file

@ -0,0 +1,92 @@
/*
* Greenshot - a free and open source screenshot tool
* Copyright (C) 2007-2011 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;
using System.Drawing;
using System.Windows.Forms;
using Greenshot.Configuration;
using GreenshotPlugin.Core;
namespace Greenshot.Forms {
/// <summary>
/// Description of PrintOptionsDialog.
/// </summary>
public partial class PrintOptionsDialog : Form {
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
ILanguage lang;
public bool AllowPrintCenter;
public bool AllowPrintEnlarge;
public bool AllowPrintRotate;
public bool AllowPrintShrink;
public bool PrintDateTime;
public bool PrintInverted;
public PrintOptionsDialog() {
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
lang = Language.GetInstance();
this.AllowPrintCenter = this.checkboxAllowCenter.Checked = conf.OutputPrintCenter;
this.AllowPrintEnlarge = this.checkboxAllowEnlarge.Checked = conf.OutputPrintAllowEnlarge;
this.AllowPrintRotate = this.checkboxAllowRotate.Checked = conf.OutputPrintAllowRotate;
this.AllowPrintShrink = this.checkboxAllowShrink.Checked = conf.OutputPrintAllowShrink;
this.PrintInverted = this.checkboxPrintInverted.Checked = conf.OutputPrintInverted;
this.PrintDateTime = this.checkboxDateTime.Checked = conf.OutputPrintTimestamp;
this.checkbox_dontaskagain.Checked = false;
UpdateUI();
}
void UpdateUI() {
this.Text = lang.GetString(LangKey.printoptions_title);
this.checkboxAllowCenter.Text = lang.GetString(LangKey.printoptions_allowcenter);
this.checkboxAllowEnlarge.Text = lang.GetString(LangKey.printoptions_allowenlarge);
this.checkboxAllowRotate.Text = lang.GetString(LangKey.printoptions_allowrotate);
this.checkboxAllowShrink.Text = lang.GetString(LangKey.printoptions_allowshrink);
this.checkbox_dontaskagain.Text = lang.GetString(LangKey.printoptions_dontaskagain);
this.checkboxDateTime.Text = lang.GetString(LangKey.printoptions_timestamp);
this.checkboxPrintInverted.Text = lang.GetString(LangKey.printoptions_inverted);
}
void Button_okClick(object sender, EventArgs e) {
this.AllowPrintCenter = this.checkboxAllowCenter.Checked;
this.AllowPrintEnlarge = this.checkboxAllowEnlarge.Checked;
this.AllowPrintRotate = this.checkboxAllowRotate.Checked;
this.AllowPrintShrink = this.checkboxAllowShrink.Checked;
this.PrintDateTime = this.checkboxDateTime.Checked;
this.PrintInverted = this.checkboxPrintInverted.Checked;
// update config
conf.OutputPrintCenter = this.AllowPrintCenter;
conf.OutputPrintAllowEnlarge = this.AllowPrintEnlarge;
conf.OutputPrintAllowRotate = this.AllowPrintRotate;
conf.OutputPrintAllowShrink = this.AllowPrintShrink;
conf.OutputPrintTimestamp = this.PrintDateTime;
conf.OutputPrintInverted = this.PrintInverted;
conf.OutputPrintPromptOptions = !this.checkbox_dontaskagain.Checked;
IniConfig.Save();
}
}
}

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