mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 01:23:47 -07:00
Refactoring some more classes, making easier code in plug-ins possible. Needed this for better testing some problems with the CreateShadow function.
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2094 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
017b874de3
commit
9488200886
20 changed files with 128 additions and 190 deletions
|
@ -162,7 +162,6 @@
|
||||||
<Compile Include="Forms\PrintOptionsDialog.Designer.cs">
|
<Compile Include="Forms\PrintOptionsDialog.Designer.cs">
|
||||||
<DependentUpon>PrintOptionsDialog.cs</DependentUpon>
|
<DependentUpon>PrintOptionsDialog.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Forms\SaveImageFileDialog.cs" />
|
|
||||||
<Compile Include="Forms\SettingsForm.cs">
|
<Compile Include="Forms\SettingsForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -187,7 +186,6 @@
|
||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
<None Include="Helpers\AviHelper.cs" />
|
<None Include="Helpers\AviHelper.cs" />
|
||||||
<Compile Include="Helpers\CaptureHelper.cs" />
|
<Compile Include="Helpers\CaptureHelper.cs" />
|
||||||
<Compile Include="Helpers\ClipboardHelper.cs" />
|
|
||||||
<Compile Include="Helpers\Colors.cs" />
|
<Compile Include="Helpers\Colors.cs" />
|
||||||
<Compile Include="Helpers\CopyData.cs" />
|
<Compile Include="Helpers\CopyData.cs" />
|
||||||
<Compile Include="Helpers\GeometryHelper.cs" />
|
<Compile Include="Helpers\GeometryHelper.cs" />
|
||||||
|
@ -216,7 +214,6 @@
|
||||||
<Compile Include="Helpers\MailHelper.cs" />
|
<Compile Include="Helpers\MailHelper.cs" />
|
||||||
<Compile Include="Helpers\PluginHelper.cs" />
|
<Compile Include="Helpers\PluginHelper.cs" />
|
||||||
<Compile Include="Helpers\PrintHelper.cs" />
|
<Compile Include="Helpers\PrintHelper.cs" />
|
||||||
<Compile Include="Helpers\ImageOutput.cs" />
|
|
||||||
<Compile Include="Helpers\ScaleHelper.cs" />
|
<Compile Include="Helpers\ScaleHelper.cs" />
|
||||||
<Compile Include="Helpers\SoundHelper.cs" />
|
<Compile Include="Helpers\SoundHelper.cs" />
|
||||||
<Compile Include="Helpers\StartupHelper.cs" />
|
<Compile Include="Helpers\StartupHelper.cs" />
|
||||||
|
@ -370,13 +367,6 @@
|
||||||
<None Include="log4net.xml">
|
<None Include="log4net.xml">
|
||||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
<Compile Include="Helpers\FilenameHelper.cs" />
|
|
||||||
<Compile Include="Forms\QualityDialog.Designer.cs">
|
|
||||||
<DependentUpon>QualityDialog.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Forms\QualityDialog.cs">
|
|
||||||
<SubType>Form</SubType>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Forms\ColorDialog.Designer.cs">
|
<Compile Include="Forms\ColorDialog.Designer.cs">
|
||||||
<DependentUpon>ColorDialog.cs</DependentUpon>
|
<DependentUpon>ColorDialog.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
|
|
@ -301,7 +301,10 @@ namespace Greenshot.Helpers {
|
||||||
if (!string.IsNullOrEmpty(filename)) {
|
if (!string.IsNullOrEmpty(filename)) {
|
||||||
try {
|
try {
|
||||||
if (filename.EndsWith(".gsf")) {
|
if (filename.EndsWith(".gsf")) {
|
||||||
ISurface surface = ImageOutput.LoadGreenshotSurface(filename);
|
|
||||||
|
ISurface surface = new Surface();
|
||||||
|
|
||||||
|
surface = ImageOutput.LoadGreenshotSurface(filename, surface);
|
||||||
DestinationHelper.GetDestination(EditorDestination.DESIGNATION).ExportCapture(true, surface, capture.CaptureDetails);
|
DestinationHelper.GetDestination(EditorDestination.DESIGNATION).ExportCapture(true, surface, capture.CaptureDetails);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,26 +95,6 @@ namespace Greenshot.Helpers {
|
||||||
#region Implementation of IGreenshotPluginHost
|
#region Implementation of IGreenshotPluginHost
|
||||||
private ContextMenuStrip mainMenu = null;
|
private ContextMenuStrip mainMenu = null;
|
||||||
|
|
||||||
public void SaveToStream(Image img, Stream stream, OutputSettings outputSettings) {
|
|
||||||
ImageOutput.SaveToStream(img, stream, outputSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SaveToTmpFile(Image img, OutputSettings outputSettings, string destinationPath) {
|
|
||||||
return ImageOutput.SaveToTmpFile(img, outputSettings, destinationPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputSettings outputSettings) {
|
|
||||||
return ImageOutput.SaveNamedTmpFile(image, captureDetails, outputSettings);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string GetFilename(OutputFormat format, ICaptureDetails captureDetails) {
|
|
||||||
string pattern = conf.OutputFileFilenamePattern;
|
|
||||||
if (pattern == null || string.IsNullOrEmpty(pattern.Trim())) {
|
|
||||||
pattern = "greenshot ${capturetime}";
|
|
||||||
}
|
|
||||||
return FilenameHelper.GetFilenameFromPattern(pattern, format, captureDetails);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a Thumbnail
|
/// Create a Thumbnail
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -123,7 +123,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
|
|
||||||
Page selectedPage = page;
|
Page selectedPage = page;
|
||||||
bool openPage = (page == null) && config.OpenPageAfterUpload;
|
bool openPage = (page == null) && config.OpenPageAfterUpload;
|
||||||
string filename = ConfluencePlugin.Host.GetFilename(config.UploadFormat, captureDetails);
|
string filename = FilenameHelper.GetFilename(config.UploadFormat, captureDetails);
|
||||||
if (selectedPage == null) {
|
if (selectedPage == null) {
|
||||||
ConfluenceUpload confluenceUpload = new ConfluenceUpload(filename);
|
ConfluenceUpload confluenceUpload = new ConfluenceUpload(filename);
|
||||||
Nullable<bool> dialogResult = confluenceUpload.ShowDialog();
|
Nullable<bool> dialogResult = confluenceUpload.ShowDialog();
|
||||||
|
@ -160,7 +160,7 @@ namespace GreenshotConfluencePlugin {
|
||||||
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||||
byte[] buffer;
|
byte[] buffer;
|
||||||
using (MemoryStream stream = new MemoryStream()) {
|
using (MemoryStream stream = new MemoryStream()) {
|
||||||
ConfluencePlugin.Host.SaveToStream(image, stream, outputSettings);
|
ImageOutput.SaveToStream(image, stream, outputSettings);
|
||||||
// COPY buffer to array
|
// COPY buffer to array
|
||||||
buffer = stream.ToArray();
|
buffer = stream.ToArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,12 +75,6 @@ namespace GreenshotConfluencePlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IGreenshotHost Host {
|
|
||||||
get {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ConfluencePlugin() {
|
public ConfluencePlugin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,9 @@ namespace ExternalCommand {
|
||||||
public class ExternalCommandDestination : AbstractDestination {
|
public class ExternalCommandDestination : AbstractDestination {
|
||||||
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandDestination));
|
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ExternalCommandDestination));
|
||||||
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
private static ExternalCommandConfiguration config = IniConfig.GetIniSection<ExternalCommandConfiguration>();
|
||||||
private IGreenshotHost host;
|
|
||||||
private string presetCommand;
|
private string presetCommand;
|
||||||
|
|
||||||
public ExternalCommandDestination(IGreenshotHost host, string commando) {
|
public ExternalCommandDestination(string commando) {
|
||||||
this.host = host;
|
|
||||||
this.presetCommand = commando;
|
this.presetCommand = commando;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +77,7 @@ namespace ExternalCommand {
|
||||||
string fullPath = captureDetails.Filename;
|
string fullPath = captureDetails.Filename;
|
||||||
if (fullPath == null) {
|
if (fullPath == null) {
|
||||||
using (Image image = surface.GetImageForExport()) {
|
using (Image image = surface.GetImageForExport()) {
|
||||||
fullPath = host.SaveNamedTmpFile(image, captureDetails, outputSettings);
|
fullPath = ImageOutput.SaveNamedTmpFile(image, captureDetails, outputSettings);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace ExternalCommand {
|
||||||
|
|
||||||
public IEnumerable<IDestination> Destinations() {
|
public IEnumerable<IDestination> Destinations() {
|
||||||
foreach(string command in config.commands) {
|
foreach(string command in config.commands) {
|
||||||
yield return new ExternalCommandDestination(host, command);
|
yield return new ExternalCommandDestination(command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,9 +139,9 @@ namespace GreenshotImgurPlugin {
|
||||||
public bool Upload(ICaptureDetails captureDetails, Image image, out string uploadURL) {
|
public bool Upload(ICaptureDetails captureDetails, Image image, out string uploadURL) {
|
||||||
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||||
using (MemoryStream stream = new MemoryStream()) {
|
using (MemoryStream stream = new MemoryStream()) {
|
||||||
host.SaveToStream(image, stream, outputSettings);
|
ImageOutput.SaveToStream(image, stream, outputSettings);
|
||||||
try {
|
try {
|
||||||
string filename = Path.GetFileName(host.GetFilename(config.UploadFormat, captureDetails));
|
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||||
ImgurInfo imgurInfo = null;
|
ImgurInfo imgurInfo = null;
|
||||||
|
|
||||||
// Run upload in the background
|
// Run upload in the background
|
||||||
|
|
|
@ -103,13 +103,13 @@ namespace GreenshotJiraPlugin {
|
||||||
|
|
||||||
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
public override ExportInformation ExportCapture(bool manuallyInitiated, ISurface surface, ICaptureDetails captureDetails) {
|
||||||
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
|
ExportInformation exportInformation = new ExportInformation(this.Designation, this.Description);
|
||||||
string filename = Path.GetFileName(jiraPlugin.Host.GetFilename(config.UploadFormat, captureDetails));
|
string filename = Path.GetFileName(FilenameHelper.GetFilename(config.UploadFormat, captureDetails));
|
||||||
byte[] buffer;
|
byte[] buffer;
|
||||||
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
OutputSettings outputSettings = new OutputSettings(config.UploadFormat, config.UploadJpegQuality, config.UploadReduceColors);
|
||||||
if (jira != null) {
|
if (jira != null) {
|
||||||
using (MemoryStream stream = new MemoryStream()) {
|
using (MemoryStream stream = new MemoryStream()) {
|
||||||
using (Image image = surface.GetImageForExport()) {
|
using (Image image = surface.GetImageForExport()) {
|
||||||
jiraPlugin.Host.SaveToStream(image, stream, outputSettings);
|
ImageOutput.SaveToStream(image, stream, outputSettings);
|
||||||
}
|
}
|
||||||
// COPY stream to buffer
|
// COPY stream to buffer
|
||||||
buffer = stream.ToArray();
|
buffer = stream.ToArray();
|
||||||
|
@ -136,7 +136,7 @@ namespace GreenshotJiraPlugin {
|
||||||
if (result == DialogResult.OK) {
|
if (result == DialogResult.OK) {
|
||||||
using (MemoryStream stream = new MemoryStream()) {
|
using (MemoryStream stream = new MemoryStream()) {
|
||||||
using (Image image = surface.GetImageForExport()) {
|
using (Image image = surface.GetImageForExport()) {
|
||||||
jiraPlugin.Host.SaveToStream(image, stream, outputSettings);
|
ImageOutput.SaveToStream(image, stream, outputSettings);
|
||||||
}
|
}
|
||||||
// COPY stream to buffer
|
// COPY stream to buffer
|
||||||
buffer = stream.ToArray();
|
buffer = stream.ToArray();
|
||||||
|
|
|
@ -60,12 +60,6 @@ namespace GreenshotJiraPlugin {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public IGreenshotHost Host {
|
|
||||||
get {
|
|
||||||
return host;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<IDestination> Destinations() {
|
public IEnumerable<IDestination> Destinations() {
|
||||||
yield return new JiraDestination(this);
|
yield return new JiraDestination(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,10 +153,10 @@ namespace GreenshotOCR {
|
||||||
graphics.Clear(Color.White);
|
graphics.Clear(Color.White);
|
||||||
graphics.DrawImage(capturedImage, Point.Empty);
|
graphics.DrawImage(capturedImage, Point.Empty);
|
||||||
}
|
}
|
||||||
filePath = host.SaveToTmpFile(tmpImage, outputSettings, null);
|
filePath = ImageOutput.SaveToTmpFile(tmpImage, outputSettings, null);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
filePath = host.SaveToTmpFile(capturedImage, outputSettings, null);
|
filePath = ImageOutput.SaveToTmpFile(capturedImage, outputSettings, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.Debug("Saved tmp file to: " + filePath);
|
LOG.Debug("Saved tmp file to: " + filePath);
|
||||||
|
|
|
@ -18,8 +18,8 @@
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
namespace Greenshot {
|
namespace GreenshotPlugin.Controls {
|
||||||
partial class QualityDialog : System.Windows.Forms.Form {
|
partial class QualityDialog {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Designer variable used to keep track of non-visual components.
|
/// Designer variable used to keep track of non-visual components.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -46,11 +46,11 @@ namespace Greenshot {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.label_choosejpegquality = new System.Windows.Forms.Label();
|
this.label_choosejpegquality = new GreenshotPlugin.Controls.GreenshotLabel();
|
||||||
this.textBoxJpegQuality = new System.Windows.Forms.TextBox();
|
this.textBoxJpegQuality = new System.Windows.Forms.TextBox();
|
||||||
this.trackBarJpegQuality = new System.Windows.Forms.TrackBar();
|
this.trackBarJpegQuality = new System.Windows.Forms.TrackBar();
|
||||||
this.checkbox_dontaskagain = new System.Windows.Forms.CheckBox();
|
this.checkbox_dontaskagain = new GreenshotPlugin.Controls.GreenshotCheckBox();
|
||||||
this.button_ok = new System.Windows.Forms.Button();
|
this.button_ok = new GreenshotPlugin.Controls.GreenshotButton();
|
||||||
this.checkBox_reduceColors = new System.Windows.Forms.CheckBox();
|
this.checkBox_reduceColors = new System.Windows.Forms.CheckBox();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.trackBarJpegQuality)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.trackBarJpegQuality)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
|
@ -61,7 +61,7 @@ namespace Greenshot {
|
||||||
this.label_choosejpegquality.Name = "label_choosejpegquality";
|
this.label_choosejpegquality.Name = "label_choosejpegquality";
|
||||||
this.label_choosejpegquality.Size = new System.Drawing.Size(268, 19);
|
this.label_choosejpegquality.Size = new System.Drawing.Size(268, 19);
|
||||||
this.label_choosejpegquality.TabIndex = 15;
|
this.label_choosejpegquality.TabIndex = 15;
|
||||||
this.label_choosejpegquality.Text = "Choose JPEG Quality";
|
this.label_choosejpegquality.LanguageKey = "jpegqualitydialog_choosejpegquality";
|
||||||
//
|
//
|
||||||
// textBoxJpegQuality
|
// textBoxJpegQuality
|
||||||
//
|
//
|
||||||
|
@ -89,9 +89,9 @@ namespace Greenshot {
|
||||||
this.checkbox_dontaskagain.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
|
this.checkbox_dontaskagain.ImageAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||||
this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 106);
|
this.checkbox_dontaskagain.Location = new System.Drawing.Point(12, 106);
|
||||||
this.checkbox_dontaskagain.Name = "checkbox_dontaskagain";
|
this.checkbox_dontaskagain.Name = "checkbox_dontaskagain";
|
||||||
|
this.checkbox_dontaskagain.LanguageKey = "qualitydialog_dontaskagain";
|
||||||
this.checkbox_dontaskagain.Size = new System.Drawing.Size(268, 37);
|
this.checkbox_dontaskagain.Size = new System.Drawing.Size(268, 37);
|
||||||
this.checkbox_dontaskagain.TabIndex = 17;
|
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.TextAlign = System.Drawing.ContentAlignment.TopLeft;
|
||||||
this.checkbox_dontaskagain.UseVisualStyleBackColor = true;
|
this.checkbox_dontaskagain.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
|
@ -102,7 +102,7 @@ namespace Greenshot {
|
||||||
this.button_ok.Name = "button_ok";
|
this.button_ok.Name = "button_ok";
|
||||||
this.button_ok.Size = new System.Drawing.Size(75, 23);
|
this.button_ok.Size = new System.Drawing.Size(75, 23);
|
||||||
this.button_ok.TabIndex = 18;
|
this.button_ok.TabIndex = 18;
|
||||||
this.button_ok.Text = "OK";
|
this.button_ok.LanguageKey = "OK";
|
||||||
this.button_ok.UseVisualStyleBackColor = true;
|
this.button_ok.UseVisualStyleBackColor = true;
|
||||||
this.button_ok.Click += new System.EventHandler(this.Button_okClick);
|
this.button_ok.Click += new System.EventHandler(this.Button_okClick);
|
||||||
//
|
//
|
||||||
|
@ -113,7 +113,7 @@ namespace Greenshot {
|
||||||
this.checkBox_reduceColors.Name = "checkBox_reduceColors";
|
this.checkBox_reduceColors.Name = "checkBox_reduceColors";
|
||||||
this.checkBox_reduceColors.Size = new System.Drawing.Size(95, 17);
|
this.checkBox_reduceColors.Size = new System.Drawing.Size(95, 17);
|
||||||
this.checkBox_reduceColors.TabIndex = 19;
|
this.checkBox_reduceColors.TabIndex = 19;
|
||||||
this.checkBox_reduceColors.Text = "Reduce colors";
|
this.checkBox_reduceColors.Text = "settings_reducecolors";
|
||||||
this.checkBox_reduceColors.UseVisualStyleBackColor = true;
|
this.checkBox_reduceColors.UseVisualStyleBackColor = true;
|
||||||
//
|
//
|
||||||
// QualityDialog
|
// QualityDialog
|
||||||
|
@ -132,17 +132,17 @@ namespace Greenshot {
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "QualityDialog";
|
this.Name = "QualityDialog";
|
||||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
this.Text = "QualityDialog";
|
this.LanguageKey = "qualitydialog_title";
|
||||||
((System.ComponentModel.ISupportInitialize)(this.trackBarJpegQuality)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.trackBarJpegQuality)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
this.PerformLayout();
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
private System.Windows.Forms.Button button_ok;
|
private GreenshotPlugin.Controls.GreenshotButton button_ok;
|
||||||
private System.Windows.Forms.CheckBox checkbox_dontaskagain;
|
private GreenshotPlugin.Controls.GreenshotCheckBox checkbox_dontaskagain;
|
||||||
private System.Windows.Forms.TrackBar trackBarJpegQuality;
|
private System.Windows.Forms.TrackBar trackBarJpegQuality;
|
||||||
private System.Windows.Forms.TextBox textBoxJpegQuality;
|
private System.Windows.Forms.TextBox textBoxJpegQuality;
|
||||||
private System.Windows.Forms.Label label_choosejpegquality;
|
private GreenshotPlugin.Controls.GreenshotLabel label_choosejpegquality;
|
||||||
private System.Windows.Forms.CheckBox checkBox_reduceColors;
|
private System.Windows.Forms.CheckBox checkBox_reduceColors;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,21 +20,21 @@
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Greenshot.Configuration;
|
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
|
|
||||||
namespace Greenshot {
|
namespace GreenshotPlugin.Controls {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of JpegQualityDialog.
|
/// Description of JpegQualityDialog.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class QualityDialog : Form {
|
public partial class QualityDialog : GreenshotForm {
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
public OutputSettings Settings {
|
public OutputSettings Settings {
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QualityDialog(OutputSettings outputSettings) {
|
public QualityDialog(OutputSettings outputSettings) {
|
||||||
Settings = outputSettings;
|
Settings = outputSettings;
|
||||||
//
|
//
|
||||||
|
@ -48,7 +48,6 @@ namespace Greenshot {
|
||||||
this.trackBarJpegQuality.Value = Settings.JPGQuality;
|
this.trackBarJpegQuality.Value = Settings.JPGQuality;
|
||||||
this.textBoxJpegQuality.Enabled = OutputFormat.jpg.Equals(outputSettings.Format);
|
this.textBoxJpegQuality.Enabled = OutputFormat.jpg.Equals(outputSettings.Format);
|
||||||
this.textBoxJpegQuality.Text = Settings.JPGQuality.ToString();
|
this.textBoxJpegQuality.Text = Settings.JPGQuality.ToString();
|
||||||
UpdateUI();
|
|
||||||
WindowDetails.ToForeground(Handle);
|
WindowDetails.ToForeground(Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,13 +62,6 @@ namespace Greenshot {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateUI() {
|
|
||||||
this.Text = Language.GetString(LangKey.qualitydialog_title);
|
|
||||||
this.label_choosejpegquality.Text = Language.GetString(LangKey.jpegqualitydialog_choosejpegquality);
|
|
||||||
this.checkbox_dontaskagain.Text = Language.GetString(LangKey.qualitydialog_dontaskagain);
|
|
||||||
this.checkBox_reduceColors.Text = Language.GetString(LangKey.settings_reducecolors);
|
|
||||||
}
|
|
||||||
|
|
||||||
void TrackBarJpegQualityScroll(object sender, System.EventArgs e) {
|
void TrackBarJpegQualityScroll(object sender, System.EventArgs e) {
|
||||||
textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString();
|
textBoxJpegQuality.Text = trackBarJpegQuality.Value.ToString();
|
||||||
}
|
}
|
|
@ -22,12 +22,11 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using Greenshot.Helpers;
|
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
|
||||||
namespace Greenshot.Forms {
|
namespace GreenshotPlugin.Controls {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Custom dialog for saving images, wraps SaveFileDialog.
|
/// Custom dialog for saving images, wraps SaveFileDialog.
|
||||||
/// For some reason SFD is sealed :(
|
/// For some reason SFD is sealed :(
|
|
@ -28,13 +28,12 @@ using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using Greenshot.Configuration;
|
|
||||||
using GreenshotPlugin.UnmanagedHelpers;
|
using GreenshotPlugin.UnmanagedHelpers;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
|
|
||||||
namespace Greenshot.Helpers {
|
namespace GreenshotPlugin.Core {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of ClipboardHelper.
|
/// Description of ClipboardHelper.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -141,9 +140,9 @@ EndSelection:<<<<<<<4
|
||||||
string messageText = null;
|
string messageText = null;
|
||||||
string clipboardOwner = GetClipboardOwner();
|
string clipboardOwner = GetClipboardOwner();
|
||||||
if (clipboardOwner != null) {
|
if (clipboardOwner != null) {
|
||||||
messageText = Language.GetFormattedString(LangKey.clipboard_inuse, clipboardOwner);
|
messageText = Language.GetFormattedString("clipboard_inuse", clipboardOwner);
|
||||||
} else {
|
} else {
|
||||||
messageText = Language.GetString(LangKey.clipboard_error);
|
messageText = Language.GetString("clipboard_error");
|
||||||
}
|
}
|
||||||
LOG.Error(messageText, ee);
|
LOG.Error(messageText, ee);
|
||||||
} else {
|
} else {
|
||||||
|
@ -172,9 +171,9 @@ EndSelection:<<<<<<<4
|
||||||
string messageText = null;
|
string messageText = null;
|
||||||
string clipboardOwner = GetClipboardOwner();
|
string clipboardOwner = GetClipboardOwner();
|
||||||
if (clipboardOwner != null) {
|
if (clipboardOwner != null) {
|
||||||
messageText = Language.GetFormattedString(LangKey.clipboard_inuse, clipboardOwner);
|
messageText = Language.GetFormattedString("clipboard_inuse", clipboardOwner);
|
||||||
} else {
|
} else {
|
||||||
messageText = Language.GetString(LangKey.clipboard_error);
|
messageText = Language.GetString("clipboard_error");
|
||||||
}
|
}
|
||||||
LOG.Error(messageText, ee);
|
LOG.Error(messageText, ee);
|
||||||
} else {
|
} else {
|
||||||
|
@ -204,9 +203,9 @@ EndSelection:<<<<<<<4
|
||||||
string messageText = null;
|
string messageText = null;
|
||||||
string clipboardOwner = GetClipboardOwner();
|
string clipboardOwner = GetClipboardOwner();
|
||||||
if (clipboardOwner != null) {
|
if (clipboardOwner != null) {
|
||||||
messageText = Language.GetFormattedString(LangKey.clipboard_inuse, clipboardOwner);
|
messageText = Language.GetFormattedString("clipboard_inuse", clipboardOwner);
|
||||||
} else {
|
} else {
|
||||||
messageText = Language.GetString(LangKey.clipboard_error);
|
messageText = Language.GetString("clipboard_error");
|
||||||
}
|
}
|
||||||
LOG.Error(messageText, ee);
|
LOG.Error(messageText, ee);
|
||||||
} else {
|
} else {
|
||||||
|
@ -247,9 +246,9 @@ EndSelection:<<<<<<<4
|
||||||
string messageText = null;
|
string messageText = null;
|
||||||
string clipboardOwner = GetClipboardOwner();
|
string clipboardOwner = GetClipboardOwner();
|
||||||
if (clipboardOwner != null) {
|
if (clipboardOwner != null) {
|
||||||
messageText = Language.GetFormattedString(LangKey.clipboard_inuse, clipboardOwner);
|
messageText = Language.GetFormattedString("clipboard_inuse", clipboardOwner);
|
||||||
} else {
|
} else {
|
||||||
messageText = Language.GetString(LangKey.clipboard_error);
|
messageText = Language.GetString("clipboard_error");
|
||||||
}
|
}
|
||||||
LOG.Error(messageText, ee);
|
LOG.Error(messageText, ee);
|
||||||
} else {
|
} else {
|
||||||
|
@ -279,9 +278,9 @@ EndSelection:<<<<<<<4
|
||||||
string messageText = null;
|
string messageText = null;
|
||||||
string clipboardOwner = GetClipboardOwner();
|
string clipboardOwner = GetClipboardOwner();
|
||||||
if (clipboardOwner != null) {
|
if (clipboardOwner != null) {
|
||||||
messageText = Language.GetFormattedString(LangKey.clipboard_inuse, clipboardOwner);
|
messageText = Language.GetFormattedString("clipboard_inuse", clipboardOwner);
|
||||||
} else {
|
} else {
|
||||||
messageText = Language.GetString(LangKey.clipboard_error);
|
messageText = Language.GetString("clipboard_error");
|
||||||
}
|
}
|
||||||
LOG.Error(messageText, ee);
|
LOG.Error(messageText, ee);
|
||||||
} else {
|
} else {
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* Greenshot - a free and open source screenshot tool
|
* Greenshot - a free and open source screenshot tool
|
||||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||||
*
|
*
|
||||||
|
@ -28,7 +28,7 @@ using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
|
|
||||||
namespace Greenshot.Helpers {
|
namespace GreenshotPlugin.Core {
|
||||||
public static class FilenameHelper {
|
public static class FilenameHelper {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(FilenameHelper));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(FilenameHelper));
|
||||||
private static readonly Regex VAR_REGEXP = new Regex(@"\${(?<variable>[^:}]+)[:]?(?<parameters>[^}]*)}", RegexOptions.Compiled);
|
private static readonly Regex VAR_REGEXP = new Regex(@"\${(?<variable>[^:}]+)[:]?(?<parameters>[^}]*)}", RegexOptions.Compiled);
|
||||||
|
@ -58,7 +58,7 @@ namespace Greenshot.Helpers {
|
||||||
// Make the filename save!
|
// Make the filename save!
|
||||||
if (filename != null) {
|
if (filename != null) {
|
||||||
foreach (char disallowed in Path.GetInvalidFileNameChars()) {
|
foreach (char disallowed in Path.GetInvalidFileNameChars()) {
|
||||||
filename = filename.Replace( disallowed.ToString(), UNSAFE_REPLACEMENT );
|
filename = filename.Replace(disallowed.ToString(), UNSAFE_REPLACEMENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return filename;
|
return filename;
|
||||||
|
@ -73,7 +73,7 @@ namespace Greenshot.Helpers {
|
||||||
// Make the path save!
|
// Make the path save!
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
foreach (char disallowed in Path.GetInvalidPathChars()) {
|
foreach (char disallowed in Path.GetInvalidPathChars()) {
|
||||||
path = path.Replace( disallowed.ToString(), UNSAFE_REPLACEMENT );
|
path = path.Replace(disallowed.ToString(), UNSAFE_REPLACEMENT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
|
@ -95,6 +95,21 @@ namespace Greenshot.Helpers {
|
||||||
return FillPattern(pattern, captureDetails, true) + "." + imageFormat.ToString().ToLower();
|
return FillPattern(pattern, captureDetails, true) + "." + imageFormat.ToString().ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Return a filename for the current image format (png,jpg etc) with the default file pattern
|
||||||
|
/// that is specified in the configuration
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="format">A string with the format</param>
|
||||||
|
/// <returns>The filename which should be used to save the image</returns>
|
||||||
|
public static string GetFilename(OutputFormat format, ICaptureDetails captureDetails) {
|
||||||
|
string pattern = conf.OutputFileFilenamePattern;
|
||||||
|
if (pattern == null || string.IsNullOrEmpty(pattern.Trim())) {
|
||||||
|
pattern = "greenshot ${capturetime}";
|
||||||
|
}
|
||||||
|
return FilenameHelper.GetFilenameFromPattern(pattern, format, captureDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method will be called by the regexp.replace as a MatchEvaluator delegate!
|
/// This method will be called by the regexp.replace as a MatchEvaluator delegate!
|
||||||
/// Will delegate this to the MatchVarEvaluatorInternal and catch any exceptions
|
/// Will delegate this to the MatchVarEvaluatorInternal and catch any exceptions
|
||||||
|
@ -132,14 +147,15 @@ namespace Greenshot.Helpers {
|
||||||
string parameters = match.Groups["parameters"].Value;
|
string parameters = match.Groups["parameters"].Value;
|
||||||
|
|
||||||
if (parameters != null && parameters.Length > 0) {
|
if (parameters != null && parameters.Length > 0) {
|
||||||
string []parms = SPLIT_REGEXP.Split(parameters);
|
string[] parms = SPLIT_REGEXP.Split(parameters);
|
||||||
foreach(string parameter in parms) {
|
foreach (string parameter in parms) {
|
||||||
switch (parameter.Substring(0,1)) {
|
switch (parameter.Substring(0, 1)) {
|
||||||
case "p":
|
case "p":
|
||||||
string []padParams = parameter.Substring(1).Split(new char[] {','});
|
string[] padParams = parameter.Substring(1).Split(new char[] { ',' });
|
||||||
try {
|
try {
|
||||||
padWidth = int.Parse(padParams[0]);
|
padWidth = int.Parse(padParams[0]);
|
||||||
} catch {};
|
} catch {
|
||||||
|
};
|
||||||
if (padParams.Length > 1) {
|
if (padParams.Length > 1) {
|
||||||
padChar = padParams[1][0];
|
padChar = padParams[1][0];
|
||||||
}
|
}
|
||||||
|
@ -150,12 +166,12 @@ namespace Greenshot.Helpers {
|
||||||
dateFormat = dateFormat.Substring(1);
|
dateFormat = dateFormat.Substring(1);
|
||||||
}
|
}
|
||||||
if (dateFormat.EndsWith("\"")) {
|
if (dateFormat.EndsWith("\"")) {
|
||||||
dateFormat = dateFormat.Substring(0, dateFormat.Length-1);
|
dateFormat = dateFormat.Substring(0, dateFormat.Length - 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "s":
|
case "s":
|
||||||
string range=parameter.Substring(1);
|
string range = parameter.Substring(1);
|
||||||
string []rangelist = range.Split(new char[] {','});
|
string[] rangelist = range.Split(new char[] { ',' });
|
||||||
if (rangelist.Length > 0) {
|
if (rangelist.Length > 0) {
|
||||||
try {
|
try {
|
||||||
startIndex = int.Parse(rangelist[0]);
|
startIndex = int.Parse(rangelist[0]);
|
||||||
|
@ -196,7 +212,7 @@ namespace Greenshot.Helpers {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Handle other variables
|
// Handle other variables
|
||||||
// Default use "now" for the capture take´n
|
// Default use "now" for the capture take´n
|
||||||
DateTime capturetime = DateTime.Now;
|
DateTime capturetime = DateTime.Now;
|
||||||
// Use default application name for title
|
// Use default application name for title
|
||||||
string title = Application.ProductName;
|
string title = Application.ProductName;
|
||||||
|
@ -211,7 +227,7 @@ namespace Greenshot.Helpers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
switch(variable) {
|
switch (variable) {
|
||||||
case "domain":
|
case "domain":
|
||||||
replaceValue = Environment.UserDomainName;
|
replaceValue = Environment.UserDomainName;
|
||||||
break;
|
break;
|
||||||
|
@ -277,7 +293,7 @@ namespace Greenshot.Helpers {
|
||||||
break;
|
break;
|
||||||
case "NUM":
|
case "NUM":
|
||||||
conf.OutputFileIncrementingNumber++;
|
conf.OutputFileIncrementingNumber++;
|
||||||
IniConfig.Save();
|
IniConfig.Save();
|
||||||
replaceValue = conf.OutputFileIncrementingNumber.ToString();
|
replaceValue = conf.OutputFileIncrementingNumber.ToString();
|
||||||
if (padWidth == 0) {
|
if (padWidth == 0) {
|
||||||
padWidth = -6;
|
padWidth = -6;
|
||||||
|
@ -294,7 +310,7 @@ namespace Greenshot.Helpers {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// do padding
|
// do padding
|
||||||
if (padWidth >0) {
|
if (padWidth > 0) {
|
||||||
replaceValue = replaceValue.PadRight(padWidth, padChar);
|
replaceValue = replaceValue.PadRight(padWidth, padChar);
|
||||||
} else if (padWidth < 0) {
|
} else if (padWidth < 0) {
|
||||||
replaceValue = replaceValue.PadLeft(-padWidth, padChar);
|
replaceValue = replaceValue.PadLeft(-padWidth, padChar);
|
||||||
|
@ -355,8 +371,10 @@ namespace Greenshot.Helpers {
|
||||||
}
|
}
|
||||||
|
|
||||||
return VAR_REGEXP.Replace(pattern,
|
return VAR_REGEXP.Replace(pattern,
|
||||||
new MatchEvaluator(delegate(Match m) { return MatchVarEvaluator(m, null, processVars, userVars, machineVars, filenameSafeMode); })
|
new MatchEvaluator(delegate(Match m) {
|
||||||
);
|
return MatchVarEvaluator(m, null, processVars, userVars, machineVars, filenameSafeMode);
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -390,8 +408,10 @@ namespace Greenshot.Helpers {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return VAR_REGEXP.Replace(pattern,
|
return VAR_REGEXP.Replace(pattern,
|
||||||
new MatchEvaluator(delegate(Match m) { return MatchVarEvaluator(m, captureDetails, processVars, userVars, machineVars, filenameSafeMode); })
|
new MatchEvaluator(delegate(Match m) {
|
||||||
);
|
return MatchVarEvaluator(m, captureDetails, processVars, userVars, machineVars, filenameSafeMode);
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// adding additional data for bug tracking
|
// adding additional data for bug tracking
|
||||||
e.Data.Add("title", captureDetails.Title);
|
e.Data.Add("title", captureDetails.Title);
|
|
@ -1,4 +1,4 @@
|
||||||
/*
|
/*
|
||||||
* Greenshot - a free and open source screenshot tool
|
* Greenshot - a free and open source screenshot tool
|
||||||
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
* Copyright (C) 2007-2012 Thomas Braun, Jens Klingen, Robin Krom
|
||||||
*
|
*
|
||||||
|
@ -26,14 +26,12 @@ using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using Greenshot.Configuration;
|
|
||||||
using Greenshot.Forms;
|
|
||||||
using Greenshot.Plugin;
|
using Greenshot.Plugin;
|
||||||
using GreenshotPlugin.Core;
|
using GreenshotPlugin.Core;
|
||||||
using Greenshot.IniFile;
|
using Greenshot.IniFile;
|
||||||
using Greenshot.Drawing;
|
using GreenshotPlugin.Controls;
|
||||||
|
|
||||||
namespace Greenshot.Helpers {
|
namespace GreenshotPlugin.Core {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Description of ImageOutput.
|
/// Description of ImageOutput.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -41,7 +39,7 @@ namespace Greenshot.Helpers {
|
||||||
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageOutput));
|
private static readonly log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(ImageOutput));
|
||||||
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
private static CoreConfiguration conf = IniConfig.GetIniSection<CoreConfiguration>();
|
||||||
private static readonly int PROPERTY_TAG_SOFTWARE_USED = 0x0131;
|
private static readonly int PROPERTY_TAG_SOFTWARE_USED = 0x0131;
|
||||||
private static Cache<string, string> tmpFileCache = new Cache<string, string>(10*60*60, new Cache<string, string>.CacheObjectExpired(RemoveExpiredTmpFile));
|
private static Cache<string, string> tmpFileCache = new Cache<string, string>(10 * 60 * 60, new Cache<string, string>.CacheObjectExpired(RemoveExpiredTmpFile));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a PropertyItem (Metadata) to store with the image.
|
/// Creates a PropertyItem (Metadata) to store with the image.
|
||||||
|
@ -54,16 +52,16 @@ namespace Greenshot.Helpers {
|
||||||
private static PropertyItem CreatePropertyItem(int id, string text) {
|
private static PropertyItem CreatePropertyItem(int id, string text) {
|
||||||
PropertyItem propertyItem = null;
|
PropertyItem propertyItem = null;
|
||||||
try {
|
try {
|
||||||
ConstructorInfo ci = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public , null, new Type[] { }, null);
|
ConstructorInfo ci = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, new Type[] { }, null);
|
||||||
propertyItem = (PropertyItem)ci.Invoke(null);
|
propertyItem = (PropertyItem)ci.Invoke(null);
|
||||||
// Make sure it's of type string
|
// Make sure it's of type string
|
||||||
propertyItem.Type =2;
|
propertyItem.Type = 2;
|
||||||
// Set the ID
|
// Set the ID
|
||||||
propertyItem.Id = id;
|
propertyItem.Id = id;
|
||||||
// Set the text
|
// Set the text
|
||||||
byte [] byteString = System.Text.ASCIIEncoding.ASCII.GetBytes(text + " ");
|
byte[] byteString = System.Text.ASCIIEncoding.ASCII.GetBytes(text + " ");
|
||||||
// Set Zero byte for String end.
|
// Set Zero byte for String end.
|
||||||
byteString[byteString.Length-1] = 0;
|
byteString[byteString.Length - 1] = 0;
|
||||||
propertyItem.Value = byteString;
|
propertyItem.Value = byteString;
|
||||||
propertyItem.Len = text.Length + 1;
|
propertyItem.Len = text.Length + 1;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -167,7 +165,7 @@ namespace Greenshot.Helpers {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="surface">Surface to save</param>
|
/// <param name="surface">Surface to save</param>
|
||||||
/// <param name="fullPath">Path to file</param>
|
/// <param name="fullPath">Path to file</param>
|
||||||
public static void SaveGreenshotSurface(Surface surface, string fullPath) {
|
public static void SaveGreenshotSurface(ISurface surface, string fullPath) {
|
||||||
fullPath = FilenameHelper.MakeFQFilenameSafe(fullPath);
|
fullPath = FilenameHelper.MakeFQFilenameSafe(fullPath);
|
||||||
string path = Path.GetDirectoryName(fullPath);
|
string path = Path.GetDirectoryName(fullPath);
|
||||||
// Get output settings from the configuration
|
// Get output settings from the configuration
|
||||||
|
@ -192,8 +190,7 @@ namespace Greenshot.Helpers {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="fullPath"></param>
|
/// <param name="fullPath"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static Surface LoadGreenshotSurface(string fullPath) {
|
public static ISurface LoadGreenshotSurface(string fullPath, ISurface returnSurface) {
|
||||||
Surface returnSurface = null;
|
|
||||||
if (string.IsNullOrEmpty(fullPath)) {
|
if (string.IsNullOrEmpty(fullPath)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -210,12 +207,11 @@ namespace Greenshot.Helpers {
|
||||||
LOG.DebugFormat("Loaded {0} with Size {1}x{2} and PixelFormat {3}", fullPath, tmpImage.Width, tmpImage.Height, tmpImage.PixelFormat);
|
LOG.DebugFormat("Loaded {0} with Size {1}x{2} and PixelFormat {3}", fullPath, tmpImage.Width, tmpImage.Height, tmpImage.PixelFormat);
|
||||||
fileBitmap = ImageHelper.Clone(tmpImage);
|
fileBitmap = ImageHelper.Clone(tmpImage);
|
||||||
}
|
}
|
||||||
returnSurface = new Surface(fileBitmap);
|
|
||||||
imageFileStream.Seek(-8, SeekOrigin.End);
|
imageFileStream.Seek(-8, SeekOrigin.End);
|
||||||
long bytesWritten = 0;
|
long bytesWritten = 0;
|
||||||
using (BinaryReader reader = new BinaryReader(imageFileStream)) {
|
using (BinaryReader reader = new BinaryReader(imageFileStream)) {
|
||||||
bytesWritten = reader.ReadInt64();
|
bytesWritten = reader.ReadInt64();
|
||||||
imageFileStream.Seek(-(bytesWritten+8), SeekOrigin.End);
|
imageFileStream.Seek(-(bytesWritten + 8), SeekOrigin.End);
|
||||||
returnSurface.LoadElementsFromStream(imageFileStream);
|
returnSurface.LoadElementsFromStream(imageFileStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,7 +242,7 @@ namespace Greenshot.Helpers {
|
||||||
if (extension != null) {
|
if (extension != null) {
|
||||||
format = (OutputFormat)Enum.Parse(typeof(OutputFormat), extension.ToLower());
|
format = (OutputFormat)Enum.Parse(typeof(OutputFormat), extension.ToLower());
|
||||||
}
|
}
|
||||||
} catch(ArgumentException ae) {
|
} catch (ArgumentException ae) {
|
||||||
LOG.Warn("Couldn't parse extension: " + extension, ae);
|
LOG.Warn("Couldn't parse extension: " + extension, ae);
|
||||||
}
|
}
|
||||||
if (!allowOverwrite && File.Exists(fullPath)) {
|
if (!allowOverwrite && File.Exists(fullPath)) {
|
||||||
|
@ -309,8 +305,8 @@ namespace Greenshot.Helpers {
|
||||||
returnValue = fileNameWithExtension;
|
returnValue = fileNameWithExtension;
|
||||||
conf.OutputFileAsFullpath = fileNameWithExtension;
|
conf.OutputFileAsFullpath = fileNameWithExtension;
|
||||||
IniConfig.Save();
|
IniConfig.Save();
|
||||||
} catch(System.Runtime.InteropServices.ExternalException) {
|
} catch (System.Runtime.InteropServices.ExternalException) {
|
||||||
MessageBox.Show(Language.GetFormattedString(LangKey.error_nowriteaccess,saveImageFileDialog.FileName).Replace(@"\\",@"\"), Language.GetString(LangKey.error));
|
MessageBox.Show(Language.GetFormattedString("error_nowriteaccess", saveImageFileDialog.FileName).Replace(@"\\", @"\"), Language.GetString("error"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
|
@ -327,7 +323,7 @@ namespace Greenshot.Helpers {
|
||||||
filename = Regex.Replace(filename, @"[^\d\w\.]", "_");
|
filename = Regex.Replace(filename, @"[^\d\w\.]", "_");
|
||||||
// Remove multiple "_"
|
// Remove multiple "_"
|
||||||
filename = Regex.Replace(filename, @"_+", "_");
|
filename = Regex.Replace(filename, @"_+", "_");
|
||||||
string tmpFile = Path.Combine(Path.GetTempPath(),filename);
|
string tmpFile = Path.Combine(Path.GetTempPath(), filename);
|
||||||
|
|
||||||
LOG.Debug("Creating TMP File: " + tmpFile);
|
LOG.Debug("Creating TMP File: " + tmpFile);
|
||||||
|
|
||||||
|
@ -345,7 +341,7 @@ namespace Greenshot.Helpers {
|
||||||
return tmpFile;
|
return tmpFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Helper method to create a temp image file
|
/// Helper method to create a temp image file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="image"></param>
|
/// <param name="image"></param>
|
||||||
|
@ -373,7 +369,7 @@ namespace Greenshot.Helpers {
|
||||||
/// Cleanup all created tmpfiles
|
/// Cleanup all created tmpfiles
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void RemoveTmpFiles() {
|
public static void RemoveTmpFiles() {
|
||||||
foreach(string tmpFile in tmpFileCache.Elements) {
|
foreach (string tmpFile in tmpFileCache.Elements) {
|
||||||
if (File.Exists(tmpFile)) {
|
if (File.Exists(tmpFile)) {
|
||||||
LOG.DebugFormat("Removing old temp file {0}", tmpFile);
|
LOG.DebugFormat("Removing old temp file {0}", tmpFile);
|
||||||
File.Delete(tmpFile);
|
File.Delete(tmpFile);
|
|
@ -215,6 +215,13 @@
|
||||||
<Compile Include="Controls\PleaseWaitForm.Designer.cs">
|
<Compile Include="Controls\PleaseWaitForm.Designer.cs">
|
||||||
<DependentUpon>PleaseWaitForm.cs</DependentUpon>
|
<DependentUpon>PleaseWaitForm.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Controls\QualityDialog.cs">
|
||||||
|
<SubType>Form</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Controls\QualityDialog.Designer.cs">
|
||||||
|
<DependentUpon>QualityDialog.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Controls\SaveImageFileDialog.cs" />
|
||||||
<Compile Include="Controls\ThumbnailForm.cs">
|
<Compile Include="Controls\ThumbnailForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
@ -223,9 +230,12 @@
|
||||||
<Compile Include="Core\AccessibleHelper.cs" />
|
<Compile Include="Core\AccessibleHelper.cs" />
|
||||||
<Compile Include="Core\BitmapBuffer.cs" />
|
<Compile Include="Core\BitmapBuffer.cs" />
|
||||||
<Compile Include="Core\Cache.cs" />
|
<Compile Include="Core\Cache.cs" />
|
||||||
|
<Compile Include="Core\ClipboardHelper.cs" />
|
||||||
<Compile Include="Core\CoreConfiguration.cs" />
|
<Compile Include="Core\CoreConfiguration.cs" />
|
||||||
<Compile Include="Core\CredentialsHelper.cs" />
|
<Compile Include="Core\CredentialsHelper.cs" />
|
||||||
<Compile Include="Core\EncryptionHelper.cs" />
|
<Compile Include="Core\EncryptionHelper.cs" />
|
||||||
|
<Compile Include="Core\FilenameHelper.cs" />
|
||||||
|
<Compile Include="Core\ImageOutput.cs" />
|
||||||
<Compile Include="Core\InterfaceUtils.cs" />
|
<Compile Include="Core\InterfaceUtils.cs" />
|
||||||
<Compile Include="Core\DisplayKeyAttribute.cs" />
|
<Compile Include="Core\DisplayKeyAttribute.cs" />
|
||||||
<Compile Include="Core\EmailConfigHelper.cs" />
|
<Compile Include="Core\EmailConfigHelper.cs" />
|
||||||
|
@ -275,15 +285,7 @@
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="IniFile" />
|
<Folder Include="Interfaces\Drawing\Filters\" />
|
||||||
<Folder Include="Interfaces\Drawing" />
|
|
||||||
<Folder Include="Interfaces\Drawing\Filters" />
|
|
||||||
<Folder Include="Interfaces\Forms" />
|
|
||||||
<Folder Include="Interfaces" />
|
|
||||||
<Folder Include="Core" />
|
|
||||||
<Folder Include="Interfaces\Plugin" />
|
|
||||||
<Folder Include="Controls" />
|
|
||||||
<Folder Include="UnmanagedHelpers" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PreBuildEvent>rmdir /S /Q "$(SolutionDir)bin\$(Configuration)\Plugins"
|
<PreBuildEvent>rmdir /S /Q "$(SolutionDir)bin\$(Configuration)\Plugins"
|
||||||
|
|
|
@ -24,6 +24,7 @@ using System.Drawing.Imaging;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
using Greenshot.Plugin.Drawing;
|
using Greenshot.Plugin.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace Greenshot.Plugin {
|
namespace Greenshot.Plugin {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -111,6 +112,8 @@ namespace Greenshot.Plugin {
|
||||||
ICursorContainer AddCursorContainer(string filename, int x, int y);
|
ICursorContainer AddCursorContainer(string filename, int x, int y);
|
||||||
IIconContainer AddIconContainer(string filename, int x, int y);
|
IIconContainer AddIconContainer(string filename, int x, int y);
|
||||||
IMetafileContainer AddMetafileContainer(string filename, int x, int y);
|
IMetafileContainer AddMetafileContainer(string filename, int x, int y);
|
||||||
|
long SaveElementsToStream(Stream stream);
|
||||||
|
void LoadElementsFromStream(Stream stream);
|
||||||
|
|
||||||
bool HasSelectedElements();
|
bool HasSelectedElements();
|
||||||
void RemoveSelectedElements();
|
void RemoveSelectedElements();
|
||||||
|
|
|
@ -129,38 +129,6 @@ namespace Greenshot.Plugin {
|
||||||
get;
|
get;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves the image to the supplied stream using the specified extension as the format
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="image">The Image to save</param>
|
|
||||||
/// <param name="stream">The Stream to save to</param>
|
|
||||||
/// <param name="outputSettings">OutputSettings</param>
|
|
||||||
void SaveToStream(Image image, Stream stream, OutputSettings outputSettings);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves the image to a temp file (random name) using the specified outputformat
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="image">The Image to save</param>
|
|
||||||
/// <param name="outputSettings">OutputSettings</param>
|
|
||||||
/// <param name="destinationPath">destination path, can be empty</param>
|
|
||||||
string SaveToTmpFile(Image image, OutputSettings outputSettings, string destinationPath);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Saves the image to a temp file, but the name is build with the capture details & pattern
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="image">The Image to save</param>
|
|
||||||
/// <param name="captureDetails">captureDetails with the information to build the filename</param>
|
|
||||||
/// <param name="outputSettings">OutputSettings</param>
|
|
||||||
string SaveNamedTmpFile(Image image, ICaptureDetails captureDetails, OutputSettings outputSettings);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Return a filename for the current image format (png,jpg etc) with the default file pattern
|
|
||||||
/// that is specified in the configuration
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="format">A string with the format</param>
|
|
||||||
/// <returns>The filename which should be used to save the image</returns>
|
|
||||||
string GetFilename(OutputFormat format, ICaptureDetails captureDetails);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a Thumbnail
|
/// Create a Thumbnail
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue