mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Added Imm.io plugin, somehow I still get Internal Server errors...?
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2138 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
6ceef4f65e
commit
4f3c621d44
12 changed files with 899 additions and 0 deletions
34
GreenshotImmioPlugin/Forms/ImmioForm.cs
Normal file
34
GreenshotImmioPlugin/Forms/ImmioForm.cs
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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 GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Controls;
|
||||
|
||||
namespace GreenshotImmioPlugin {
|
||||
/// <summary>
|
||||
/// Description of ImmioForm.
|
||||
/// </summary>
|
||||
public class ImmioForm : GreenshotForm {
|
||||
public ImmioForm() : base() {
|
||||
}
|
||||
}
|
||||
}
|
119
GreenshotImmioPlugin/Forms/SettingsForm.Designer.cs
generated
Normal file
119
GreenshotImmioPlugin/Forms/SettingsForm.Designer.cs
generated
Normal file
|
@ -0,0 +1,119 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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 GreenshotImmioPlugin {
|
||||
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.buttonOK = new GreenshotPlugin.Controls.GreenshotButton();
|
||||
this.buttonCancel = new GreenshotPlugin.Controls.GreenshotButton();
|
||||
this.combobox_uploadimageformat = new GreenshotPlugin.Controls.GreenshotComboBox();
|
||||
this.label_upload_format = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonOK
|
||||
//
|
||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonOK.LanguageKey = "immio.OK";
|
||||
this.buttonOK.Location = new System.Drawing.Point(222, 88);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonOK.TabIndex = 2;
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
this.buttonOK.Click += new System.EventHandler(this.ButtonOKClick);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.LanguageKey = "immio.CANCEL";
|
||||
this.buttonCancel.Location = new System.Drawing.Point(303, 88);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||
this.buttonCancel.TabIndex = 3;
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancelClick);
|
||||
//
|
||||
// combobox_uploadimageformat
|
||||
//
|
||||
this.combobox_uploadimageformat.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.combobox_uploadimageformat.FormattingEnabled = true;
|
||||
this.combobox_uploadimageformat.Location = new System.Drawing.Point(102, 7);
|
||||
this.combobox_uploadimageformat.Name = "combobox_uploadimageformat";
|
||||
this.combobox_uploadimageformat.PropertyName = "UploadFormat";
|
||||
this.combobox_uploadimageformat.SectionName = "Immio";
|
||||
this.combobox_uploadimageformat.Size = new System.Drawing.Size(276, 21);
|
||||
this.combobox_uploadimageformat.TabIndex = 8;
|
||||
//
|
||||
// label_upload_format
|
||||
//
|
||||
this.label_upload_format.LanguageKey = "immio.label_upload_format";
|
||||
this.label_upload_format.Location = new System.Drawing.Point(12, 10);
|
||||
this.label_upload_format.Name = "label_upload_format";
|
||||
this.label_upload_format.Size = new System.Drawing.Size(84, 20);
|
||||
this.label_upload_format.TabIndex = 9;
|
||||
//
|
||||
// SettingsForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
|
||||
this.ClientSize = new System.Drawing.Size(387, 123);
|
||||
this.Controls.Add(this.label_upload_format);
|
||||
this.Controls.Add(this.combobox_uploadimageformat);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonOK);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
|
||||
this.LanguageKey = "immio.settings_title";
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "SettingsForm";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
private GreenshotPlugin.Controls.GreenshotComboBox combobox_uploadimageformat;
|
||||
private GreenshotPlugin.Controls.GreenshotLabel label_upload_format;
|
||||
private GreenshotPlugin.Controls.GreenshotButton buttonCancel;
|
||||
private GreenshotPlugin.Controls.GreenshotButton buttonOK;
|
||||
}
|
||||
}
|
47
GreenshotImmioPlugin/Forms/SettingsForm.cs
Normal file
47
GreenshotImmioPlugin/Forms/SettingsForm.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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 GreenshotPlugin.Core;
|
||||
using GreenshotPlugin.Controls;
|
||||
|
||||
namespace GreenshotImmioPlugin {
|
||||
/// <summary>
|
||||
/// Description of PasswordRequestForm.
|
||||
/// </summary>
|
||||
public partial class SettingsForm : ImmioForm {
|
||||
public SettingsForm(ImmioConfiguration config) : base() {
|
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent();
|
||||
this.Icon = GreenshotPlugin.Core.GreenshotResources.getGreenshotIcon();
|
||||
}
|
||||
|
||||
void ButtonOKClick(object sender, EventArgs e) {
|
||||
this.DialogResult = DialogResult.OK;
|
||||
}
|
||||
|
||||
void ButtonCancelClick(object sender, System.EventArgs e) {
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
}
|
||||
}
|
||||
}
|
98
GreenshotImmioPlugin/GreenshotImmioPlugin.csproj
Normal file
98
GreenshotImmioPlugin/GreenshotImmioPlugin.csproj
Normal file
|
@ -0,0 +1,98 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="..\CommonProject.properties" />
|
||||
<PropertyGroup>
|
||||
<ProjectGuid>{B7B30064-1034-4C53-AB7C-17A007360C19}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>GreenshotImmioPlugin</RootNamespace>
|
||||
<AssemblyName>GreenshotImmioPlugin</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
|
||||
<NoStdLib>False</NoStdLib>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
|
||||
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||
<TargetFrameworkProfile />
|
||||
<FileUpgradeFlags>
|
||||
</FileUpgradeFlags>
|
||||
<OldToolsVersion>3.5</OldToolsVersion>
|
||||
<UpgradeBackupLocation />
|
||||
</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="Forms\ImmioForm.cs" />
|
||||
<Compile Include="Forms\SettingsForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Forms\SettingsForm.Designer.cs">
|
||||
<DependentUpon>SettingsForm.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ImmioDestination.cs" />
|
||||
<Compile Include="ImmioPlugin.cs" />
|
||||
<Compile Include="ImmioConfiguration.cs" />
|
||||
<Compile Include="ImmioUtils.cs" />
|
||||
<Compile Include="LanguageKeys.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<None Include="Languages\language_immioplugin-en-US.xml">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Include="Properties\AssemblyInfo.cs.template" />
|
||||
<EmbeddedResource Include="ImmioPlugin.resx">
|
||||
<DependentUpon>ImmioPlugin.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\GreenshotPlugin\GreenshotPlugin.csproj">
|
||||
<Project>{5B924697-4DCD-4F98-85F1-105CB84B7341}</Project>
|
||||
<Name>GreenshotPlugin</Name>
|
||||
</ProjectReference>
|
||||
</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)\$(ProjectName).pdb" "$(SolutionDir)bin\$(Configuration)\Plugins\$(ProjectName)\"
|
||||
mkdir "$(SolutionDir)bin\$(Configuration)\Languages\Plugins\$(ProjectName)"
|
||||
copy "$(ProjectDir)\Languages\*.xml" "$(SolutionDir)bin\$(Configuration)\Languages\Plugins\$(ProjectName)\"
|
||||
</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||
<Optimize>True</Optimize>
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
<DebugType>Full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<BaseAddress>4194304</BaseAddress>
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Platform)' == 'x86' ">
|
||||
<RegisterForComInterop>False</RegisterForComInterop>
|
||||
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
|
||||
<BaseAddress>4194304</BaseAddress>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<FileAlignment>4096</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
|
||||
<Optimize>False</Optimize>
|
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
|
||||
<DebugType>Full</DebugType>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</Project>
|
63
GreenshotImmioPlugin/ImmioConfiguration.cs
Normal file
63
GreenshotImmioPlugin/ImmioConfiguration.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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.Windows.Forms;
|
||||
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
|
||||
namespace GreenshotImmioPlugin {
|
||||
/// <summary>
|
||||
/// Description of ImmioConfiguration.
|
||||
/// </summary>
|
||||
[IniSection("Immio", Description="Greenshot Immio Plugin configuration")]
|
||||
public class ImmioConfiguration : IniSection {
|
||||
[IniProperty("UploadFormat", Description="What file type to use for uploading", DefaultValue="png")]
|
||||
public OutputFormat UploadFormat;
|
||||
[IniProperty("UploadJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")]
|
||||
public int UploadJpegQuality;
|
||||
[IniProperty("UploadReduceColors", Description="Reduce color amount of the uploaded image to 256", DefaultValue="False")]
|
||||
public bool UploadReduceColors;
|
||||
[IniProperty("UsePageLink", Description = "Use pagelink instead of direct link on the clipboard", DefaultValue = "False")]
|
||||
public bool UsePageLink;
|
||||
|
||||
/// <summary>
|
||||
/// A form for username/password
|
||||
/// </summary>
|
||||
/// <returns>bool true if OK was pressed, false if cancel</returns>
|
||||
public bool ShowConfigDialog() {
|
||||
SettingsForm settingsForm = null;
|
||||
|
||||
new PleaseWaitForm().ShowAndWait(ImmioPlugin.Attributes.Name, Language.GetString("immio", LangKey.communication_wait),
|
||||
delegate() {
|
||||
settingsForm = new SettingsForm(this);
|
||||
}
|
||||
);
|
||||
DialogResult result = settingsForm.ShowDialog();
|
||||
if (result == DialogResult.OK) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
76
GreenshotImmioPlugin/ImmioDestination.cs
Normal file
76
GreenshotImmioPlugin/ImmioDestination.cs
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
|
||||
namespace GreenshotImmioPlugin {
|
||||
/// <summary>
|
||||
/// Description of ImmioDestination.
|
||||
/// </summary>
|
||||
public class ImmioDestination : AbstractDestination {
|
||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImmioDestination));
|
||||
private static ImmioConfiguration config = IniConfig.GetIniSection<ImmioConfiguration>();
|
||||
private ImmioPlugin plugin = null;
|
||||
|
||||
public ImmioDestination(ImmioPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public override string Designation {
|
||||
get {
|
||||
return "Immio";
|
||||
}
|
||||
}
|
||||
|
||||
public override string Description {
|
||||
get {
|
||||
return Language.GetString("immio", LangKey.upload_menu_item);
|
||||
}
|
||||
}
|
||||
|
||||
public override Image DisplayIcon {
|
||||
get {
|
||||
ComponentResourceManager resources = new ComponentResourceManager(typeof(ImmioPlugin));
|
||||
return (Image)resources.GetObject("Immio");
|
||||
}
|
||||
}
|
||||
|
||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
|
||||
using (Image image = surface.GetImageForExport()) {
|
||||
string uploadURL = null;
|
||||
exportInformation.ExportMade = plugin.Upload(captureDetails, image, out uploadURL);
|
||||
exportInformation.Uri = uploadURL;
|
||||
}
|
||||
ProcessExport(exportInformation, surface);
|
||||
return exportInformation;
|
||||
}
|
||||
}
|
||||
}
|
138
GreenshotImmioPlugin/ImmioPlugin.cs
Normal file
138
GreenshotImmioPlugin/ImmioPlugin.cs
Normal file
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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.IO;
|
||||
using System.Windows.Forms;
|
||||
using System.Threading;
|
||||
|
||||
using Greenshot.Plugin;
|
||||
using GreenshotPlugin.Controls;
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
|
||||
namespace GreenshotImmioPlugin {
|
||||
/// <summary>
|
||||
/// This is the ImmioPlugin code
|
||||
/// </summary>
|
||||
public class ImmioPlugin : IGreenshotPlugin {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImmioPlugin));
|
||||
private static ImmioConfiguration config;
|
||||
public static PluginAttribute Attributes;
|
||||
private IGreenshotHost host;
|
||||
private ComponentResourceManager resources;
|
||||
|
||||
public ImmioPlugin() {
|
||||
}
|
||||
|
||||
public IEnumerable<IDestination> Destinations() {
|
||||
yield return new ImmioDestination(this);
|
||||
}
|
||||
|
||||
public IEnumerable<IProcessor> Processors() {
|
||||
yield break;
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <returns>true if plugin is initialized, false if not (doesn't show)</returns>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
this.host = (IGreenshotHost)pluginHost;
|
||||
Attributes = myAttributes;
|
||||
|
||||
// Get configuration
|
||||
config = IniConfig.GetIniSection<ImmioConfiguration>();
|
||||
resources = new ComponentResourceManager(typeof(ImmioPlugin));
|
||||
|
||||
ToolStripMenuItem itemPlugInRoot = new ToolStripMenuItem(Language.GetString("immio", LangKey.configure));
|
||||
itemPlugInRoot.Image = (Image)resources.GetObject("Immio");
|
||||
itemPlugInRoot.Click += delegate {
|
||||
config.ShowConfigDialog();
|
||||
};
|
||||
|
||||
PluginUtils.AddToContextMenu(host, itemPlugInRoot);
|
||||
return true;
|
||||
}
|
||||
|
||||
public virtual void Shutdown() {
|
||||
LOG.Debug("Immio Plugin shutdown.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implementation of the IPlugin.Configure
|
||||
/// </summary>
|
||||
public virtual void Configure() {
|
||||
config.ShowConfigDialog();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This will be called when Greenshot is shutting down
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
public void Closing(object sender, FormClosingEventArgs e) {
|
||||
LOG.Debug("Application closing, de-registering Immio Plugin!");
|
||||
Shutdown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Upload the capture to Immio
|
||||
/// </summary>
|
||||
/// <param name="captureDetails"></param>
|
||||
/// <param name="image"></param>
|
||||
/// <param name="uploadURL">out string for the url</param>
|
||||
/// <returns>true if the upload succeeded</returns>
|
||||
public bool Upload(ICaptureDetails captureDetails, Image image, out string uploadURL) {
|
||||
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||
uploadURL = null;
|
||||
try {
|
||||
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||
string url = null;
|
||||
|
||||
// Run upload in the background
|
||||
new PleaseWaitForm().ShowAndWait(Attributes.Name, Language.GetString("immio", LangKey.communication_wait),
|
||||
delegate() {
|
||||
url = ImmioUtils.UploadToImmio(image, outputSettings, captureDetails.Title, filename);
|
||||
}
|
||||
);
|
||||
uploadURL = url;
|
||||
|
||||
IniConfig.Save();
|
||||
try {
|
||||
Clipboard.SetText(url);
|
||||
} catch (Exception ex) {
|
||||
LOG.Error("Can't write to clipboard: ", ex);
|
||||
}
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
LOG.Error(e);
|
||||
MessageBox.Show(Language.GetString("immio", LangKey.upload_failure) + " " + e.Message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
131
GreenshotImmioPlugin/ImmioPlugin.resx
Normal file
131
GreenshotImmioPlugin/ImmioPlugin.resx
Normal file
|
@ -0,0 +1,131 @@
|
|||
<?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="Immio" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAgY0hSTQAAeiYAAICEAAD6AAAAgOgAAHUwAADqYAAAOpgAABdwnLpRPAAAAMVJREFUOE9jDA0J
|
||||
ZSAJADW8ffeOSAQyHaJhzvHXaGjR6TdoCKgMi4Zzj79+/vH3Pxg8ePfz2cdfQBGgTqBx2DVAlKKB9Zfe
|
||||
49QAlIOofvP1N9BsINp69QPEtdhtAEoAHbDi3FtMX+HUgKkUiw29m6e0rshsWORfO88WSLatyp+4fRqa
|
||||
ThQbgKqBStuWO6ChpcdTFx+vXnh8IbofkFUvPOKDhhYciVlwtATFBojBmEqRRdA14FcNlEXRQFA1ugbS
|
||||
Eh8wSRGPAL2C6QdnoO9oAAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
71
GreenshotImmioPlugin/ImmioUtils.cs
Normal file
71
GreenshotImmioPlugin/ImmioUtils.cs
Normal file
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
|
||||
using GreenshotPlugin.Core;
|
||||
using Greenshot.IniFile;
|
||||
using Greenshot.Plugin;
|
||||
|
||||
namespace GreenshotImmioPlugin {
|
||||
/// <summary>
|
||||
/// Description of ImmioUtils.
|
||||
/// </summary>
|
||||
public class ImmioUtils {
|
||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImmioUtils));
|
||||
private static ImmioConfiguration config = IniConfig.GetIniSection<ImmioConfiguration>();
|
||||
|
||||
private ImmioUtils() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do the actual upload to Immio
|
||||
/// </summary>
|
||||
/// <param name="image">Image to upload</param>
|
||||
/// <param name="outputSettings">OutputSettings for the image file format</param>
|
||||
/// <param name="title">Title</param>
|
||||
/// <param name="filename">Filename</param>
|
||||
/// <returns>ImmioInfo with details</returns>
|
||||
public static string UploadToImmio(Image image, OutputSettings outputSettings, string title, string filename) {
|
||||
|
||||
string responseString = null;
|
||||
HttpWebRequest webRequest = (HttpWebRequest)NetworkHelper.CreateWebRequest("http://imm.io/store/");
|
||||
webRequest.Method = "POST";
|
||||
webRequest.ServicePoint.Expect100Continue = false;
|
||||
|
||||
IDictionary<string, object> uploadParameters = new Dictionary<string, object>();
|
||||
uploadParameters.Add("name", filename);
|
||||
uploadParameters.Add("image", new ImageContainer(image, outputSettings, null));
|
||||
NetworkHelper.WriteMultipartFormData(webRequest, uploadParameters);
|
||||
|
||||
responseString = NetworkHelper.GetResponse(webRequest);
|
||||
|
||||
IDictionary<string, object> parsedResponse = JSONHelper.JsonDecode(responseString);
|
||||
return (string)parsedResponse["uri"];
|
||||
}
|
||||
}
|
||||
}
|
36
GreenshotImmioPlugin/LanguageKeys.cs
Normal file
36
GreenshotImmioPlugin/LanguageKeys.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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 GreenshotImmioPlugin {
|
||||
public enum LangKey {
|
||||
upload_menu_item,
|
||||
settings_title,
|
||||
label_url,
|
||||
label_upload_format,
|
||||
OK,
|
||||
CANCEL,
|
||||
upload_success,
|
||||
upload_failure,
|
||||
communication_wait,
|
||||
configure
|
||||
}
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<language description="English" ietf="en-US" version="1.0.0">
|
||||
<resources>
|
||||
<resource name="upload_menu_item">
|
||||
Upload to Immio
|
||||
</resource>
|
||||
<resource name="settings_title">
|
||||
Immio settings
|
||||
</resource>
|
||||
<resource name="OK">
|
||||
OK
|
||||
</resource>
|
||||
<resource name="CANCEL">
|
||||
Cancel
|
||||
</resource>
|
||||
<resource name="upload_success">
|
||||
Successfully uploaded image to Immio!
|
||||
</resource>
|
||||
<resource name="upload_failure">
|
||||
An error occured while uploading to Immio:
|
||||
</resource>
|
||||
<resource name="label_upload_format">
|
||||
Image format
|
||||
</resource>
|
||||
<resource name="communication_wait">
|
||||
Communicating with Immio. Please wait...
|
||||
</resource>
|
||||
<resource name="configure">
|
||||
Configure Immio
|
||||
</resource>
|
||||
</resources>
|
||||
</language>
|
54
GreenshotImmioPlugin/Properties/AssemblyInfo.cs.template
Normal file
54
GreenshotImmioPlugin/Properties/AssemblyInfo.cs.template
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on 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("GreenshotImmioPlugin")]
|
||||
[assembly: AssemblyDescription("A plugin to upload images to Imm.io")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Greenshot")]
|
||||
[assembly: AssemblyProduct("Immio Plugin")]
|
||||
[assembly: AssemblyCopyright("Copyright (C) 2007-2012")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
// The PluginAttribute describes the "entryType" and if the plugin is configurable
|
||||
[assembly: PluginAttribute("GreenshotImmioPlugin.ImmioPlugin", 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.3.$WCREV$")]
|
Loading…
Add table
Add a link
Reference in a new issue