forked from saucepleez/taskt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Show Engine Context Command for easy display of engine context …
…data
- Loading branch information
1 parent
cf77fc2
commit 4159b87
Showing
10 changed files
with
1,063 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
taskt/Core/Automation/Commands/ShowEngineContextCommand.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
using System.Xml.Serialization; | ||
using taskt.UI.CustomControls; | ||
using taskt.UI.Forms; | ||
|
||
namespace taskt.Core.Automation.Commands | ||
{ | ||
[Serializable] | ||
[Attributes.ClassAttributes.Group("Engine Commands")] | ||
[Attributes.ClassAttributes.Description("This command allows you to show a message to the user.")] | ||
[Attributes.ClassAttributes.UsesDescription("Use this command when you want to present or display a value on screen to the user.")] | ||
[Attributes.ClassAttributes.ImplementationDescription("This command implements 'MessageBox' and invokes VariableCommand to find variable data.")] | ||
public class ShowEngineContextCommand : ScriptCommand | ||
{ | ||
|
||
[XmlAttribute] | ||
[Attributes.PropertyAttributes.PropertyDescription("Close After X (Seconds) - 0 to bypass")] | ||
[Attributes.PropertyAttributes.InputSpecification("Specify how many seconds to display on screen. After the amount of seconds passes, the message box will be automatically closed and script will resume execution.")] | ||
[Attributes.PropertyAttributes.SampleUsage("**0** to remain open indefinitely or **5** to stay open for 5 seconds.")] | ||
[Attributes.PropertyAttributes.Remarks("")] | ||
public int v_AutoCloseAfter { get; set; } | ||
public ShowEngineContextCommand() | ||
{ | ||
this.CommandName = "ShowEngineContextCommand"; | ||
this.SelectionName = "Show Engine Context"; | ||
this.CommandEnabled = true; | ||
this.v_AutoCloseAfter = 0; | ||
this.CustomRendering = true; | ||
} | ||
|
||
public override void RunCommand(object sender) | ||
{ | ||
var engine = (Core.Automation.Engine.AutomationEngineInstance)sender; | ||
|
||
|
||
if (engine.tasktEngineUI == null) | ||
{ | ||
return; | ||
} | ||
|
||
//automatically close messageboxes for server requests | ||
if (engine.serverExecution && v_AutoCloseAfter <= 0) | ||
{ | ||
v_AutoCloseAfter = 10; | ||
} | ||
|
||
var result = engine.tasktEngineUI.Invoke(new Action(() => | ||
{ | ||
engine.tasktEngineUI.ShowEngineContext(engine.GetEngineContext(), v_AutoCloseAfter); | ||
} | ||
|
||
)); | ||
|
||
} | ||
public override List<Control> Render(frmCommandEditor editor) | ||
{ | ||
base.Render(editor); | ||
|
||
|
||
//create auto close control set | ||
var autocloseControlSet = CommandControls.CreateDefaultInputGroupFor("v_AutoCloseAfter", this, editor); | ||
RenderedControls.AddRange(autocloseControlSet); | ||
|
||
|
||
return RenderedControls; | ||
|
||
} | ||
|
||
public override string GetDisplayValue() | ||
{ | ||
return base.GetDisplayValue(); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
taskt/UI/Forms/Supplement Forms/frmEngineContextViewer.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Data; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Forms; | ||
|
||
namespace taskt.UI.Forms.Supplement_Forms | ||
{ | ||
public partial class frmEngineContextViewer : ThemedForm | ||
{ | ||
public frmEngineContextViewer(string context, int closeAfter) | ||
{ | ||
InitializeComponent(); | ||
LoadEngineContext(context); | ||
} | ||
|
||
private void FrmEngineContextViewer_Load(object sender, EventArgs e) | ||
{ | ||
|
||
} | ||
|
||
private void LoadEngineContext(string context) | ||
{ | ||
|
||
var root = Newtonsoft.Json.JsonConvert.DeserializeObject<JToken>(context); | ||
DisplayTreeView(root, "Engine Context"); | ||
|
||
} | ||
private void DisplayTreeView(JToken root, string rootName) | ||
{ | ||
tvContext.BeginUpdate(); | ||
try | ||
{ | ||
tvContext.Nodes.Clear(); | ||
var tNode = tvContext.Nodes[tvContext.Nodes.Add(new TreeNode(rootName))]; | ||
tNode.Tag = root; | ||
|
||
AddNode(root, tNode); | ||
} | ||
finally | ||
{ | ||
tvContext.EndUpdate(); | ||
} | ||
} | ||
private void AddNode(JToken token, TreeNode inTreeNode) | ||
{ | ||
if (token == null) | ||
return; | ||
if (token is JValue) | ||
{ | ||
var childNode = inTreeNode.Nodes[inTreeNode.Nodes.Add(new TreeNode(token.ToString()))]; | ||
childNode.Tag = token; | ||
} | ||
else if (token is JObject) | ||
{ | ||
var obj = (JObject)token; | ||
foreach (var property in obj.Properties()) | ||
{ | ||
var childNode = inTreeNode.Nodes[inTreeNode.Nodes.Add(new TreeNode(property.Name))]; | ||
childNode.Tag = property; | ||
AddNode(property.Value, childNode); | ||
} | ||
} | ||
else if (token is JArray) | ||
{ | ||
var array = (JArray)token; | ||
for (int i = 0; i < array.Count; i++) | ||
{ | ||
var childNode = inTreeNode.Nodes[inTreeNode.Nodes.Add(new TreeNode(i.ToString()))]; | ||
childNode.Tag = array[i]; | ||
AddNode(array[i], childNode); | ||
} | ||
} | ||
else | ||
{ | ||
Console.WriteLine(string.Format("{0} not implemented", token.Type)); // JConstructor, JRaw | ||
} | ||
} | ||
|
||
private void UiBtnOk_Click(object sender, EventArgs e) | ||
{ | ||
this.DialogResult = DialogResult.OK; | ||
} | ||
} | ||
} |
Oops, something went wrong.