Added scripts list

This commit is contained in:
Jaex 2015-02-17 11:17:11 +02:00
parent f5903993f9
commit 806d55b5e1
7 changed files with 345 additions and 33 deletions

View file

@ -3,6 +3,7 @@
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="SteveCadwallader.CodeMaid.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="tomenglertde.ResXManager.View.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
@ -416,7 +417,7 @@
<value>0</value>
</setting>
<setting name="General_Multithread" serializeAs="String">
<value>False</value>
<value>True</value>
</setting>
<setting name="Cleaning_CommentSkipWrapOnLastWord" serializeAs="String">
<value>True</value>
@ -428,6 +429,135 @@
<setting name="General_CacheFiles" serializeAs="String">
<value>True</value>
</setting>
<setting name="Formatting_CommentXmlKeepTagsTogether" serializeAs="String">
<value>False</value>
</setting>
<setting name="Reorganizing_PrimaryOrderByAccessLevel" serializeAs="String">
<value>False</value>
</setting>
<setting name="Reorganizing_MemberTypeClasses" serializeAs="String">
<value>Classes||12||Classes</value>
</setting>
<setting name="Formatting_CommentRunDuringCleanup" serializeAs="String">
<value>False</value>
</setting>
<setting name="Cleaning_IncludeSCSS" serializeAs="String">
<value>True</value>
</setting>
<setting name="Reorganizing_RegionsInsertKeepEvenIfEmpty" serializeAs="String">
<value>False</value>
</setting>
<setting name="Cleaning_RemoveRegions" serializeAs="String">
<value>0</value>
</setting>
<setting name="Reorganizing_MemberTypeDestructors" serializeAs="String">
<value>Destructors||3||Destructors</value>
</setting>
<setting name="Reorganizing_MemberTypeIndexers" serializeAs="String">
<value>Indexers||9||Indexers</value>
</setting>
<setting name="ThirdParty_UseTelerikJustCodeCleanup" serializeAs="String">
<value>False</value>
</setting>
<setting name="Reorganizing_RegionsIncludeAccessLevel" serializeAs="String">
<value>False</value>
</setting>
<setting name="Formatting_CommentWrapColumn" serializeAs="String">
<value>100</value>
</setting>
<setting name="Formatting_CommentXmlTagsToLowerCase" serializeAs="String">
<value>False</value>
</setting>
<setting name="ThirdParty_OtherCleaningCommandsExpression" serializeAs="String">
<value />
</setting>
<setting name="ThirdParty_UseXAMLStylerCleanup" serializeAs="String">
<value>False</value>
</setting>
<setting name="General_LoadModelsAsynchronously" serializeAs="String">
<value>True</value>
</setting>
<setting name="Reorganizing_MemberTypeConstructors" serializeAs="String">
<value>Constructors||2||Constructors</value>
</setting>
<setting name="Formatting_CommentXmlValueIndent" serializeAs="String">
<value>0</value>
</setting>
<setting name="Reorganizing_RegionsInsertNewRegions" serializeAs="String">
<value>False</value>
</setting>
<setting name="Cleaning_InsertEndOfFileTrailingNewLine" serializeAs="String">
<value>False</value>
</setting>
<setting name="Formatting_CommentXmlSpaceTags" serializeAs="String">
<value>False</value>
</setting>
<setting name="Finding_TemporarilyOpenSolutionFolders" serializeAs="String">
<value>True</value>
</setting>
<setting name="Digging_PrimarySortOrder" serializeAs="String">
<value>0</value>
</setting>
<setting name="Reorganizing_MemberTypeEnums" serializeAs="String">
<value>Enums||6||Enums</value>
</setting>
<setting name="Formatting_CommentXmlSpaceSingleTags" serializeAs="String">
<value>False</value>
</setting>
<setting name="Reorganizing_MemberTypeProperties" serializeAs="String">
<value>Properties||8||Properties</value>
</setting>
<setting name="Reorganizing_RegionsRemoveExistingRegions" serializeAs="String">
<value>False</value>
</setting>
<setting name="Reorganizing_MemberTypeStructs" serializeAs="String">
<value>Structs||11||Structs</value>
</setting>
<setting name="Reorganizing_MemberTypeMethods" serializeAs="String">
<value>Methods||10||Methods</value>
</setting>
<setting name="Formatting_CommentXmlSplitSummaryTagToMultipleLines"
serializeAs="String">
<value>True</value>
</setting>
<setting name="ThirdParty_UseJetBrainsReSharperCleanup" serializeAs="String">
<value>False</value>
</setting>
<setting name="Formatting_CommentSkipWrapOnLastWord" serializeAs="String">
<value>True</value>
</setting>
<setting name="Formatting_CommentXmlSplitAllTags" serializeAs="String">
<value>False</value>
</setting>
<setting name="Reorganizing_MemberTypeFields" serializeAs="String">
<value>Fields||1||Fields</value>
</setting>
<setting name="Reorganizing_MemberTypeInterfaces" serializeAs="String">
<value>Interfaces||7||Interfaces</value>
</setting>
<setting name="Reorganizing_MemberTypeEvents" serializeAs="String">
<value>Events||5||Events</value>
</setting>
<setting name="Reorganizing_MemberTypeDelegates" serializeAs="String">
<value>Delegates||4||Delegates</value>
</setting>
<setting name="Formatting_CommentXmlAlignParamTags" serializeAs="String">
<value>False</value>
</setting>
</SteveCadwallader.CodeMaid.Properties.Settings>
<tomenglertde.ResXManager.View.Properties.Settings>
<setting name="ResourceFilter" serializeAs="String">
<value />
</setting>
<setting name="VisibleCommentColumns" serializeAs="String">
<value />
</setting>
<setting name="HiddenLanguageColumns" serializeAs="String">
<value>,.zh-CN,.hu,.cs,.fr</value>
</setting>
<setting name="NeutralCultureCountyOverrides" serializeAs="String">
<value>en=en-US,bn=bn-IN</value>
</setting>
</tomenglertde.ResXManager.View.Properties.Settings>
</userSettings>
</configuration>

View file

@ -34,15 +34,20 @@ private void InitializeComponent()
this.cbFunctions = new System.Windows.Forms.ComboBox();
this.lblFunctions = new System.Windows.Forms.Label();
this.btnLoadExample = new System.Windows.Forms.Button();
this.txtScriptName = new System.Windows.Forms.TextBox();
this.btnSaveScript = new System.Windows.Forms.Button();
this.lblScriptName = new System.Windows.Forms.Label();
this.btnRemoveScript = new System.Windows.Forms.Button();
this.lvScripts = new ShareX.HelpersLib.MyListView();
this.chScriptName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.pInput.SuspendLayout();
this.SuspendLayout();
//
// btnRun
//
this.btnRun.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnRun.Location = new System.Drawing.Point(8, 484);
this.btnRun.Location = new System.Drawing.Point(9, 9);
this.btnRun.Name = "btnRun";
this.btnRun.Size = new System.Drawing.Size(120, 24);
this.btnRun.Size = new System.Drawing.Size(120, 39);
this.btnRun.TabIndex = 1;
this.btnRun.Text = "Run";
this.btnRun.UseVisualStyleBackColor = true;
@ -52,43 +57,38 @@ private void InitializeComponent()
//
this.rtbInput.BorderStyle = System.Windows.Forms.BorderStyle.None;
this.rtbInput.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbInput.Font = new System.Drawing.Font("Verdana", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(162)));
this.rtbInput.Font = new System.Drawing.Font("Verdana", 12F);
this.rtbInput.Location = new System.Drawing.Point(3, 3);
this.rtbInput.Name = "rtbInput";
this.rtbInput.Size = new System.Drawing.Size(495, 460);
this.rtbInput.Size = new System.Drawing.Size(496, 416);
this.rtbInput.TabIndex = 0;
this.rtbInput.Text = "";
this.rtbInput.TextChanged += new System.EventHandler(this.rtbInput_TextChanged);
//
// pInput
//
this.pInput.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.pInput.BackColor = System.Drawing.Color.White;
this.pInput.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.pInput.Controls.Add(this.rtbInput);
this.pInput.Location = new System.Drawing.Point(8, 8);
this.pInput.Location = new System.Drawing.Point(8, 56);
this.pInput.Name = "pInput";
this.pInput.Padding = new System.Windows.Forms.Padding(3);
this.pInput.Size = new System.Drawing.Size(503, 468);
this.pInput.Size = new System.Drawing.Size(504, 424);
this.pInput.TabIndex = 0;
//
// cbFunctions
//
this.cbFunctions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.cbFunctions.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbFunctions.FormattingEnabled = true;
this.cbFunctions.Location = new System.Drawing.Point(343, 484);
this.cbFunctions.Location = new System.Drawing.Point(344, 24);
this.cbFunctions.Name = "cbFunctions";
this.cbFunctions.Size = new System.Drawing.Size(168, 21);
this.cbFunctions.TabIndex = 4;
//
// lblFunctions
//
this.lblFunctions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.lblFunctions.AutoSize = true;
this.lblFunctions.Location = new System.Drawing.Point(279, 488);
this.lblFunctions.Location = new System.Drawing.Point(341, 8);
this.lblFunctions.Name = "lblFunctions";
this.lblFunctions.Size = new System.Drawing.Size(56, 13);
this.lblFunctions.TabIndex = 3;
@ -96,20 +96,82 @@ private void InitializeComponent()
//
// btnLoadExample
//
this.btnLoadExample.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnLoadExample.Location = new System.Drawing.Point(136, 484);
this.btnLoadExample.Location = new System.Drawing.Point(137, 9);
this.btnLoadExample.Name = "btnLoadExample";
this.btnLoadExample.Size = new System.Drawing.Size(120, 24);
this.btnLoadExample.Size = new System.Drawing.Size(120, 39);
this.btnLoadExample.TabIndex = 2;
this.btnLoadExample.Text = "Load example";
this.btnLoadExample.UseVisualStyleBackColor = true;
this.btnLoadExample.Click += new System.EventHandler(this.btnLoadExample_Click);
//
// txtScriptName
//
this.txtScriptName.Location = new System.Drawing.Point(520, 24);
this.txtScriptName.Name = "txtScriptName";
this.txtScriptName.Size = new System.Drawing.Size(152, 20);
this.txtScriptName.TabIndex = 6;
//
// btnSaveScript
//
this.btnSaveScript.Location = new System.Drawing.Point(520, 48);
this.btnSaveScript.Name = "btnSaveScript";
this.btnSaveScript.Size = new System.Drawing.Size(152, 24);
this.btnSaveScript.TabIndex = 7;
this.btnSaveScript.Text = "Save";
this.btnSaveScript.UseVisualStyleBackColor = true;
this.btnSaveScript.Click += new System.EventHandler(this.btnSaveScript_Click);
//
// lblScriptName
//
this.lblScriptName.AutoSize = true;
this.lblScriptName.Location = new System.Drawing.Point(517, 8);
this.lblScriptName.Name = "lblScriptName";
this.lblScriptName.Size = new System.Drawing.Size(66, 13);
this.lblScriptName.TabIndex = 8;
this.lblScriptName.Text = "Script name:";
//
// btnRemoveScript
//
this.btnRemoveScript.Location = new System.Drawing.Point(520, 72);
this.btnRemoveScript.Name = "btnRemoveScript";
this.btnRemoveScript.Size = new System.Drawing.Size(152, 24);
this.btnRemoveScript.TabIndex = 9;
this.btnRemoveScript.Text = "Remove";
this.btnRemoveScript.UseVisualStyleBackColor = true;
this.btnRemoveScript.Click += new System.EventHandler(this.btnRemoveScript_Click);
//
// lvScripts
//
this.lvScripts.AutoFillColumn = true;
this.lvScripts.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
this.chScriptName});
this.lvScripts.FullRowSelect = true;
this.lvScripts.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
this.lvScripts.HideSelection = false;
this.lvScripts.Location = new System.Drawing.Point(520, 104);
this.lvScripts.MultiSelect = false;
this.lvScripts.Name = "lvScripts";
this.lvScripts.Size = new System.Drawing.Size(152, 376);
this.lvScripts.TabIndex = 5;
this.lvScripts.UseCompatibleStateImageBehavior = false;
this.lvScripts.View = System.Windows.Forms.View.Details;
this.lvScripts.SelectedIndexChanged += new System.EventHandler(this.lvScripts_SelectedIndexChanged);
//
// chScriptName
//
this.chScriptName.Text = "Name";
this.chScriptName.Width = 130;
//
// AutomateForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(520, 516);
this.ClientSize = new System.Drawing.Size(683, 489);
this.Controls.Add(this.btnRemoveScript);
this.Controls.Add(this.lblScriptName);
this.Controls.Add(this.btnSaveScript);
this.Controls.Add(this.txtScriptName);
this.Controls.Add(this.lvScripts);
this.Controls.Add(this.btnLoadExample);
this.Controls.Add(this.lblFunctions);
this.Controls.Add(this.cbFunctions);
@ -132,6 +194,12 @@ private void InitializeComponent()
private System.Windows.Forms.ComboBox cbFunctions;
private System.Windows.Forms.Label lblFunctions;
private System.Windows.Forms.Button btnLoadExample;
private ShareX.HelpersLib.MyListView lvScripts;
private System.Windows.Forms.TextBox txtScriptName;
private System.Windows.Forms.Button btnSaveScript;
private System.Windows.Forms.Label lblScriptName;
private System.Windows.Forms.Button btnRemoveScript;
private System.Windows.Forms.ColumnHeader chScriptName;

View file

@ -35,23 +35,13 @@ namespace ShareX.HelpersLib
{
public partial class AutomateForm : Form
{
public string Script
{
get
{
return rtbInput.Text;
}
set
{
rtbInput.Text = value;
}
}
public List<ScriptInfo> Scripts { get; private set; }
private FunctionManager functionManager = new FunctionManager();
private Tokenizer tokenizer = new Tokenizer();
private bool isWorking;
public AutomateForm()
public AutomateForm(List<ScriptInfo> scripts)
{
InitializeComponent();
Icon = ShareXResources.Icon;
@ -59,6 +49,23 @@ public AutomateForm()
cbFunctions.Items.AddRange(tokenizer.Keywords);
cbFunctions.SelectedIndex = 0;
Tokenize();
Scripts = scripts;
foreach (ScriptInfo scriptInfo in Scripts)
{
AddScript(scriptInfo);
}
if (lvScripts.Items.Count > 0)
{
lvScripts.Items[0].Selected = true;
}
}
private void AddScript(ScriptInfo scriptInfo)
{
lvScripts.Items.Add(scriptInfo.Name).Tag = scriptInfo;
}
private void rtbInput_TextChanged(object sender, EventArgs e)
@ -153,7 +160,7 @@ private void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
private void btnLoadExample_Click(object sender, EventArgs e)
{
Script = @"Wait 3000
rtbInput.Text = @"Wait 3000
Call KeyboardFunctions
Call MouseFunctions
3 Call LoopTest
@ -177,5 +184,56 @@ Func LoopTest
Wait 1000
KeyPressText ""Loop""";
}
private void btnSaveScript_Click(object sender, EventArgs e)
{
string scriptName = txtScriptName.Text;
if (string.IsNullOrEmpty(scriptName))
{
MessageBox.Show("Script name can't be empty.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
ScriptInfo scriptInfo = Scripts.FirstOrDefault(x => x.Name.Equals(scriptName, StringComparison.InvariantCultureIgnoreCase));
if (scriptInfo != null)
{
scriptInfo.Script = rtbInput.Text;
}
else
{
scriptInfo = new ScriptInfo(scriptName, rtbInput.Text);
Scripts.Add(scriptInfo);
AddScript(scriptInfo);
}
}
private void btnRemoveScript_Click(object sender, EventArgs e)
{
if (lvScripts.SelectedIndices.Count > 0)
{
int index = lvScripts.SelectedIndices[0];
Scripts.RemoveAt(index);
lvScripts.Items.RemoveAt(index);
rtbInput.Clear();
txtScriptName.Clear();
}
}
private void lvScripts_SelectedIndexChanged(object sender, EventArgs e)
{
if (lvScripts.SelectedItems.Count > 0)
{
ListViewItem lvi = lvScripts.SelectedItems[0];
ScriptInfo scriptInfo = lvi.Tag as ScriptInfo;
if (scriptInfo != null)
{
txtScriptName.Text = scriptInfo.Name;
rtbInput.Text = scriptInfo.Script;
Tokenize();
}
}
}
}
}

View file

@ -0,0 +1,44 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright © 2007-2015 ShareX Developers
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 2
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ShareX.HelpersLib
{
public class ScriptInfo
{
public string Name { get; set; }
public string Script { get; set; }
public ScriptInfo(string name, string script)
{
Name = name;
Script = script;
}
}
}

View file

@ -85,6 +85,7 @@
</Compile>
<Compile Include="Automate\Function.cs" />
<Compile Include="Automate\FunctionManager.cs" />
<Compile Include="Automate\ScriptInfo.cs" />
<Compile Include="ClipboardFormat.cs" />
<Compile Include="CodeMenu.cs" />
<Compile Include="ColorMatrixManager.cs" />

View file

@ -201,5 +201,11 @@ public ApplicationConfig()
public Rectangle ScreenRecordRegion = Rectangle.Empty;
#endregion ScreenRecord Form
#region Automate Form
public List<ScriptInfo> AutomateScripts = new List<ScriptInfo>();
#endregion Automate Form
}
}

View file

@ -548,7 +548,12 @@ public static void OpenRuler()
public static void OpenAutomate()
{
new AutomateForm().Show();
if (Program.Settings.AutomateScripts == null)
{
Program.Settings.AutomateScripts = new List<ScriptInfo>();
}
new AutomateForm(Program.Settings.AutomateScripts).Show();
}
public static void OpenHashCheck()