diff --git a/Greenshot-RunAtOutput-Plugin/Configuration.cs b/Greenshot-RunAtOutput-Plugin/Configuration.cs
deleted file mode 100644
index 2919f8872..000000000
--- a/Greenshot-RunAtOutput-Plugin/Configuration.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2010 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 .
- */
-using System;
-using System.Collections.Generic;
-using System.Xml;
-using System.Xml.Serialization;
-
-namespace RunAtOutput {
- ///
- /// Description of Configuration.
- ///
- [XmlRoot("RunAtOutput")]
- public class Configuration {
- public Configuration() {
- Commands = new List();
- }
- [XmlElement("Commando")]
- public List Commands {
- get;
- set;
- }
- }
-
- public class Commando {
- public Commando() {
- }
- [XmlAttribute("Name")]
- public string Name {
- get;
- set;
- }
- [XmlElement("Commandline")]
- public string Commandline {
- get;
- set;
- }
- [XmlElement("Arguments")]
- public string Arguments {
- get;
- set;
- }
- [XmlAttribute("Active")]
- public bool Active{
- get;
- set;
- }
- }
-}
diff --git a/Greenshot-RunAtOutput-Plugin/Greenshot-RunAtOutput-Plugin.csproj b/Greenshot-RunAtOutput-Plugin/Greenshot-RunAtOutput-Plugin.csproj
index 9507582c3..5b7e183f7 100644
--- a/Greenshot-RunAtOutput-Plugin/Greenshot-RunAtOutput-Plugin.csproj
+++ b/Greenshot-RunAtOutput-Plugin/Greenshot-RunAtOutput-Plugin.csproj
@@ -49,15 +49,14 @@
-
+
SettingsForm.cs
-
"$(SolutionDir)\tools\TortoiseSVN\SubWCRev.exe" "$(ProjectDir)\" "$(ProjectDir)\Properties\AssemblyInfo.cs.template" "$(ProjectDir)\Properties\AssemblyInfo.cs"
diff --git a/Greenshot-RunAtOutput-Plugin/RunAtOutput.cs b/Greenshot-RunAtOutput-Plugin/RunAtOutput.cs
index 160023fb0..6ac5f8cd0 100644
--- a/Greenshot-RunAtOutput-Plugin/RunAtOutput.cs
+++ b/Greenshot-RunAtOutput-Plugin/RunAtOutput.cs
@@ -29,6 +29,7 @@ using System.Windows.Forms;
using System.Xml.Serialization;
using Greenshot.Capturing;
+using Greenshot.Core;
using Greenshot.Plugin;
namespace RunAtOutput {
@@ -40,7 +41,7 @@ namespace RunAtOutput {
private IGreenshotPluginHost host;
private ICaptureHost captureHost = null;
private PluginAttribute myAttributes;
- private Configuration config = new Configuration();
+ private RunAtOutputConfiguration config;
public RunAtOutputPlugin() {
}
@@ -59,7 +60,7 @@ namespace RunAtOutput {
this.myAttributes = myAttributes;
this.host.OnImageOutput += new OnImageOutputHandler(ImageOutput);
- LoadConfig();
+ this.config = IniConfig.GetIniSection();
}
public virtual void Shutdown() {
@@ -72,29 +73,7 @@ namespace RunAtOutput {
///
public virtual void Configure() {
LOG.Debug("Configure called");
- SettingsForm settingsForm = new SettingsForm(config);
- if (settingsForm.ShowDialog() == DialogResult.OK) {
- SaveConfig();
- }
- settingsForm.Dispose();
- }
-
- private void LoadConfig() {
- XmlSerializer xmlSerializer = new XmlSerializer(typeof(Configuration));
- string filename = Path.Combine(host.ConfigurationPath, "RunAtOutputPlugin.xml");
- if (File.Exists(filename)) {
- using (TextReader reader = new StreamReader(filename)) {
- config = (Configuration)xmlSerializer.Deserialize(reader);
- }
- }
- }
-
- private void SaveConfig() {
- XmlSerializer xmlSerializer = new XmlSerializer(typeof(Configuration));
- string filename = Path.Combine(host.ConfigurationPath, "RunAtOutputPlugin.xml");
- using (TextWriter writer = new StreamWriter(filename)) {
- xmlSerializer.Serialize(writer, config);
- }
+ new SettingsForm().ShowDialog();
}
///
@@ -103,23 +82,23 @@ namespace RunAtOutput {
/// Has the FullPath to the image
private void ImageOutput(object sender, ImageOutputEventArgs eventArgs) {
LOG.Debug("ImageOutput called with full path: " + eventArgs.FullPath);
- foreach(Commando commando in config.Commands) {
- if (commando.Active) {
- if (commando.Commandline != null && commando.Commandline.Length > 0) {
- Process p = new Process();
- p.StartInfo.FileName = commando.Commandline;
- p.StartInfo.Arguments = String.Format(commando.Arguments, eventArgs.FullPath);
- p.StartInfo.UseShellExecute = false;
- p.StartInfo.RedirectStandardOutput = true;
- LOG.Info("Starting : " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
- p.Start();
- string output = p.StandardOutput.ReadToEnd();
- if (output != null && output.Trim().Length > 0) {
- LOG.Info("Output:\n" + output);
- }
- LOG.Info("Finished : " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
- }
- }
+ foreach(string commando in config.active) {
+ string commandline = config.commandlines[commando];
+ string arguments = config.arguments[commando];
+ if (commandline != null && commandline.Length > 0) {
+ Process p = new Process();
+ p.StartInfo.FileName = commandline;
+ p.StartInfo.Arguments = String.Format(arguments, eventArgs.FullPath);
+ p.StartInfo.UseShellExecute = false;
+ p.StartInfo.RedirectStandardOutput = true;
+ LOG.Info("Starting : " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
+ p.Start();
+ string output = p.StandardOutput.ReadToEnd();
+ if (output != null && output.Trim().Length > 0) {
+ LOG.Info("Output:\n" + output);
+ }
+ LOG.Info("Finished : " + p.StartInfo.FileName + " " + p.StartInfo.Arguments);
+ }
}
}
}
diff --git a/Greenshot-RunAtOutput-Plugin/RunAtOutputConfiguration.cs b/Greenshot-RunAtOutput-Plugin/RunAtOutputConfiguration.cs
new file mode 100644
index 000000000..ec759d562
--- /dev/null
+++ b/Greenshot-RunAtOutput-Plugin/RunAtOutputConfiguration.cs
@@ -0,0 +1,75 @@
+/*
+ * Greenshot - a free and open source screenshot tool
+ * Copyright (C) 2007-2010 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 .
+ */
+using System;
+using System.Collections.Generic;
+using Greenshot.Core;
+
+namespace RunAtOutput {
+ ///
+ /// Description of FlickrConfiguration.
+ ///
+ [IniSection("RunAtOutput", Description="Greenshot TitRunAtOutputleFix Plugin configuration")]
+ public class RunAtOutputConfiguration : IniSection {
+ [IniProperty("Commands", Description="The commands that are available.")]
+ public List commands;
+
+ //[IniProperty("Matcher", Description="Match filenames or types.")]
+ //public Dictionary matchers;
+
+ [IniProperty("Commandline", Description="The commandline for the output command.")]
+ public Dictionary commandlines;
+
+ [IniProperty("Argument", Description="The arguments for the output command.")]
+ public Dictionary arguments;
+
+ [IniProperty("ActiveCommands", Description="The commands that are active.")]
+ public List active;
+
+ ///
+ /// Supply values we can't put as defaults
+ ///
+ /// The property to return a default for
+ /// object with the default value for the supplied property
+ public override object GetDefault(string property) {
+ switch(property) {
+ case "Commands":
+ List commandDefaults = new List();
+ commandDefaults.Add("Paint.NET");
+ return commandDefaults;
+ case "Commandline":
+ Dictionary commandlineDefaults = new Dictionary();
+ commandlineDefaults.Add("Paint.NET", @"C:\Programme\Paint.NET\PaintDotNet.exe");
+ return commandlineDefaults;
+// case "Matcher":
+// Dictionary matcherDefaults = new Dictionary();
+// matcherDefaults.Add("Paint.NET", "*");
+// return matcherDefaults;
+ case "ActiveCommands":
+ return new List();
+ case "Argument":
+ Dictionary argumentDefaults = new Dictionary();
+ argumentDefaults.Add("Paint.NET", "\"{0}\"");
+ return argumentDefaults;
+ }
+ return null;
+ }
+ }
+}
diff --git a/Greenshot-RunAtOutput-Plugin/SettingsForm.cs b/Greenshot-RunAtOutput-Plugin/SettingsForm.cs
index 258f66fa7..fdeb0e220 100644
--- a/Greenshot-RunAtOutput-Plugin/SettingsForm.cs
+++ b/Greenshot-RunAtOutput-Plugin/SettingsForm.cs
@@ -22,16 +22,18 @@ using System;
using System.Drawing;
using System.Windows.Forms;
+using Greenshot.Core;
+
namespace RunAtOutput {
///
/// Description of SettingsForm.
///
public partial class SettingsForm : Form {
private static log4net.ILog LOG = log4net.LogManager.GetLogger(typeof(SettingsForm));
- private Configuration config;
+ private RunAtOutputConfiguration config;
- public SettingsForm(Configuration config) {
- this.config = config;
+ public SettingsForm() {
+ this.config = IniConfig.GetIniSection();
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
@@ -40,6 +42,7 @@ namespace RunAtOutput {
}
void ButtonOkClick(object sender, EventArgs e) {
+ IniConfig.Save();
DialogResult = DialogResult.OK;
}
@@ -49,38 +52,43 @@ namespace RunAtOutput {
void ShowSelectedItem() {
foreach ( ListViewItem item in listView1.SelectedItems ) {
- Commando commando = item.Tag as Commando;
- textBox_arguments.Text = commando.Arguments;
- textBox_commandline.Text = commando.Commandline;
- textBox_name.Text = commando.Name;
+ string commando = item.Tag as string;
+ textBox_name.Text = commando;
+ textBox_commandline.Text = config.commandlines[commando];
+ textBox_arguments.Text = config.arguments[commando];
}
}
void ButtonAddClick(object sender, EventArgs e) {
- Commando commando = new Commando();
- commando.Arguments = textBox_arguments.Text;
- commando.Commandline = textBox_commandline.Text;
- commando.Name = textBox_name.Text;
- config.Commands.Add(commando);
+ config.commands.Add(textBox_name.Text);
+ config.commandlines.Add(textBox_name.Text, textBox_commandline.Text);
+ config.arguments.Add(textBox_name.Text, textBox_arguments.Text);
UpdateView();
}
void ButtonDeleteClick(object sender, EventArgs e) {
foreach ( ListViewItem item in listView1.SelectedItems ) {
- Commando commando = item.Tag as Commando;
- config.Commands.Remove(commando);
+ string commando = item.Tag as string;
+ config.active.Remove(textBox_name.Text);
+ config.commands.Remove(textBox_name.Text);
+ config.commandlines.Remove(textBox_name.Text);
+ config.arguments.Remove(textBox_name.Text);
}
UpdateView();
}
void UpdateView() {
listView1.Items.Clear();
- foreach(Commando commando in config.Commands) {
- ListViewItem item = new ListViewItem("");
- item.SubItems.Add(commando.Name);
- item.Checked = commando.Active;
- item.Tag = commando;
- listView1.Items.Add(item);
+ if (config.commands != null) {
+ foreach(string commando in config.commands) {
+ ListViewItem item = new ListViewItem("");
+ item.SubItems.Add(commando);
+ if (config.active != null) {
+ item.Checked = config.active.Contains(commando);
+ }
+ item.Tag = commando;
+ listView1.Items.Add(item);
+ }
}
}
@@ -90,9 +98,14 @@ namespace RunAtOutput {
}
void ListView1ItemChecked(object sender, ItemCheckedEventArgs e) {
- Commando commando = e.Item.Tag as Commando;
- LOG.Debug("ItemChecked " + commando.Name + " to " + e.Item.Checked);
- commando.Active = e.Item.Checked;
+ string commando = e.Item.Tag as string;
+ LOG.Debug("ItemChecked " + commando + " to " + e.Item.Checked);
+ if (e.Item.Checked && !config.active.Contains(commando)) {
+ config.active.Add(commando);
+ }
+ if (!e.Item.Checked) {
+ config.active.Remove(commando);
+ }
}
}
}
diff --git a/Greenshot-RunAtOutput-Plugin/runatoutput.properties b/Greenshot-RunAtOutput-Plugin/runatoutput.properties
deleted file mode 100644
index 826cb81e5..000000000
--- a/Greenshot-RunAtOutput-Plugin/runatoutput.properties
+++ /dev/null
@@ -1,4 +0,0 @@
-active=OptiPNG,Paint.NET
-command.Paint.NET=C:\Programme\Paint.NET\PaintDotNet.exe {0}
-pattern.OptiPNG=*.png
-command.OptiPNG=D:\05018085\downloads\optipng-0.6.4-exe\optipng.exe {0}