mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 21:43:24 -07:00
Code quality changes [skip ci]
This commit is contained in:
parent
61cfe004c5
commit
798ca503a5
108 changed files with 1981 additions and 2258 deletions
|
@ -31,34 +31,34 @@ namespace ExternalCommand {
|
|||
[IniSection("ExternalCommand", Description="Greenshot ExternalCommand Plugin configuration")]
|
||||
public class ExternalCommandConfiguration : IniSection {
|
||||
[IniProperty("Commands", Description="The commands that are available.")]
|
||||
public List<string> commands;
|
||||
public List<string> Commands { get; set; }
|
||||
|
||||
[IniProperty("RedirectStandardError", Description = "Redirect the standard error of all external commands, used to output as warning to the greenshot.log.", DefaultValue = "true")]
|
||||
public bool RedirectStandardError;
|
||||
public bool RedirectStandardError { get; set; }
|
||||
|
||||
[IniProperty("RedirectStandardOutput", Description = "Redirect the standard output of all external commands, used for different other functions (more below).", DefaultValue = "true")]
|
||||
public bool RedirectStandardOutput;
|
||||
public bool RedirectStandardOutput { get; set; }
|
||||
|
||||
[IniProperty("ShowStandardOutputInLog", Description = "Depends on 'RedirectStandardOutput': Show standard output of all external commands to the Greenshot log, this can be usefull for debugging.", DefaultValue = "false")]
|
||||
public bool ShowStandardOutputInLog;
|
||||
public bool ShowStandardOutputInLog { get; set; }
|
||||
|
||||
[IniProperty("ParseForUri", Description = "Depends on 'RedirectStandardOutput': Parse the output and take the first found URI, if a URI is found than clicking on the notify bubble goes there.", DefaultValue = "true")]
|
||||
public bool ParseOutputForUri;
|
||||
public bool ParseOutputForUri { get; set; }
|
||||
|
||||
[IniProperty("OutputToClipboard", Description = "Depends on 'RedirectStandardOutput': Place the standard output on the clipboard.", DefaultValue = "false")]
|
||||
public bool OutputToClipboard;
|
||||
public bool OutputToClipboard { get; set; }
|
||||
|
||||
[IniProperty("UriToClipboard", Description = "Depends on 'RedirectStandardOutput' & 'ParseForUri': If an URI is found in the standard input, place it on the clipboard. (This overwrites the output from OutputToClipboard setting.)", DefaultValue = "true")]
|
||||
public bool UriToClipboard;
|
||||
public bool UriToClipboard { get; set; }
|
||||
|
||||
[IniProperty("Commandline", Description="The commandline for the output command.")]
|
||||
public Dictionary<string, string> commandlines;
|
||||
public Dictionary<string, string> commandlines { get; set; }
|
||||
|
||||
[IniProperty("Argument", Description="The arguments for the output command.")]
|
||||
public Dictionary<string, string> arguments;
|
||||
public Dictionary<string, string> arguments { get; set; }
|
||||
|
||||
[IniProperty("RunInbackground", Description = "Should the command be started in the background.")]
|
||||
public Dictionary<string, bool> runInbackground;
|
||||
public Dictionary<string, bool> runInbackground { get; set; }
|
||||
|
||||
private const string MSPAINT = "MS Paint";
|
||||
private static readonly string paintPath;
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace ExternalCommand {
|
|||
}
|
||||
|
||||
public IEnumerable<IDestination> Destinations() {
|
||||
foreach(string command in config.commands) {
|
||||
foreach(string command in config.Commands) {
|
||||
yield return new ExternalCommandDestination(command);
|
||||
}
|
||||
}
|
||||
|
@ -96,15 +96,14 @@ namespace ExternalCommand {
|
|||
/// <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>
|
||||
/// <param name="pluginHost">Use the IGreenshotPluginHost interface to register events</param>
|
||||
/// <param name="myAttributes">My own attributes</param>
|
||||
public virtual bool Initialize(IGreenshotHost pluginHost, PluginAttribute myAttributes) {
|
||||
LOG.DebugFormat("Initialize called of {0}", myAttributes.Name);
|
||||
|
||||
List<string> commandsToDelete = new List<string>();
|
||||
// Check configuration
|
||||
foreach(string command in config.commands) {
|
||||
foreach(string command in config.Commands) {
|
||||
if (!isCommandValid(command)) {
|
||||
commandsToDelete.Add(command);
|
||||
}
|
||||
|
@ -115,18 +114,17 @@ namespace ExternalCommand {
|
|||
config.runInbackground.Remove(command);
|
||||
config.commandlines.Remove(command);
|
||||
config.arguments.Remove(command);
|
||||
config.commands.Remove(command);
|
||||
config.Commands.Remove(command);
|
||||
}
|
||||
|
||||
_host = pluginHost;
|
||||
_myAttributes = myAttributes;
|
||||
|
||||
|
||||
_itemPlugInRoot = new ToolStripMenuItem();
|
||||
_itemPlugInRoot.Tag = _host;
|
||||
_itemPlugInRoot = new ToolStripMenuItem {Tag = _host};
|
||||
OnIconSizeChanged(this, new PropertyChangedEventArgs("IconSize"));
|
||||
OnLanguageChanged(this, null);
|
||||
_itemPlugInRoot.Click += new EventHandler(ConfigMenuClick);
|
||||
_itemPlugInRoot.Click += ConfigMenuClick;
|
||||
|
||||
PluginUtils.AddToContextMenu(_host, _itemPlugInRoot);
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace ExternalCommand {
|
|||
void ButtonDeleteClick(object sender, EventArgs e) {
|
||||
foreach(ListViewItem item in listView1.SelectedItems) {
|
||||
string commando = item.Tag as string;
|
||||
config.commands.Remove(commando);
|
||||
config.Commands.Remove(commando);
|
||||
config.commandlines.Remove(commando);
|
||||
config.arguments.Remove(commando);
|
||||
}
|
||||
|
@ -65,12 +65,12 @@ namespace ExternalCommand {
|
|||
|
||||
void UpdateView() {
|
||||
listView1.Items.Clear();
|
||||
if(config.commands != null) {
|
||||
if(config.Commands != null) {
|
||||
listView1.ListViewItemSorter = new ListviewComparer();
|
||||
ImageList imageList = new ImageList();
|
||||
listView1.SmallImageList = imageList;
|
||||
int imageNr = 0;
|
||||
foreach(string commando in config.commands) {
|
||||
foreach(string commando in config.Commands) {
|
||||
ListViewItem item = null;
|
||||
Image iconForExe = IconCache.IconForCommand(commando);
|
||||
if(iconForExe != null) {
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace ExternalCommand {
|
|||
textBox_name.Text = commando;
|
||||
textBox_commandline.Text = config.commandlines[commando];
|
||||
textBox_arguments.Text = config.arguments[commando];
|
||||
_commandIndex = config.commands.FindIndex(delegate(string s) { return s == commando; });
|
||||
_commandIndex = config.Commands.FindIndex(delegate(string s) { return s == commando; });
|
||||
} else {
|
||||
textBox_arguments.Text = "\"{0}\"";
|
||||
}
|
||||
|
@ -59,13 +59,13 @@ namespace ExternalCommand {
|
|||
string commandLine = textBox_commandline.Text;
|
||||
string arguments = textBox_arguments.Text;
|
||||
if(_commando != null) {
|
||||
config.commands[_commandIndex] = commandName;
|
||||
config.Commands[_commandIndex] = commandName;
|
||||
config.commandlines.Remove(_commando);
|
||||
config.commandlines.Add(commandName, commandLine);
|
||||
config.arguments.Remove(_commando);
|
||||
config.arguments.Add(commandName, arguments);
|
||||
} else {
|
||||
config.commands.Add(commandName);
|
||||
config.Commands.Add(commandName);
|
||||
config.commandlines.Add(commandName, commandLine);
|
||||
config.arguments.Add(commandName, arguments);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ namespace ExternalCommand {
|
|||
buttonOk.Enabled = false;
|
||||
}
|
||||
// Check if commandname is unique
|
||||
if(_commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.commands.Contains(textBox_name.Text)) {
|
||||
if(_commando == null && !string.IsNullOrEmpty(textBox_name.Text) && config.Commands.Contains(textBox_name.Text)) {
|
||||
buttonOk.Enabled = false;
|
||||
textBox_name.BackColor = Color.Red;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue