Skip to content

Commit

Permalink
RunTask: call to different script now correctly handled
Browse files Browse the repository at this point in the history
SeleniumBrowserElementActionCommand: Added "Switch to frame" verb to handle framesets
Theme: parametrized gradient
frmScriptEngine: threading handling and red color for scripts in error
ThemedForm: automatic resize if too big to fit
  • Loading branch information
VirtualFab committed Sep 11, 2019
1 parent 4084705 commit 3fbe7bb
Show file tree
Hide file tree
Showing 9 changed files with 100 additions and 23 deletions.
8 changes: 6 additions & 2 deletions taskt/Core/Automation/Commands/RunTaskCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ public override void RunCommand(object sender)
});
}

Application.Run(new UI.Forms.frmScriptEngine(startFile, null, variableList));

UI.Forms.frmScriptEngine newEngine = new UI.Forms.frmScriptEngine(startFile, null, variableList, true);
Core.Automation.Engine.AutomationEngineInstance currentScriptEngine = (Core.Automation.Engine.AutomationEngineInstance) sender;
currentScriptEngine.tasktEngineUI.Invoke((Action)delegate () { currentScriptEngine.tasktEngineUI.TopMost = false; });
Application.Run(newEngine);
//currentScriptEngine.tasktEngineUI.TopMost = false;
currentScriptEngine.tasktEngineUI.Invoke((Action)delegate () { currentScriptEngine.tasktEngineUI.TopMost = true; });
}

public override List<Control> Render(frmCommandEditor editor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class SeleniumBrowserCreateCommand : ScriptCommand
[XmlAttribute]
[Attributes.PropertyAttributes.PropertyDescription("Please specify Selenium command line options (optional)")]
[Attributes.PropertyAttributes.InputSpecification("Select optional options to be passed to the Selenium command.")]
[Attributes.PropertyAttributes.SampleUsage("user-data-dir=/user/public/SeleniumTasktProfile")]
[Attributes.PropertyAttributes.SampleUsage("user-data-dir=c:\\users\\public\\SeleniumTasktProfile")]
[Attributes.PropertyAttributes.Remarks("")]
public string v_SeleniumOptions { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public class SeleniumBrowserElementActionCommand : ScriptCommand
[Attributes.PropertyAttributes.PropertyUISelectionOption("Get Attribute")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Get Matching Elements")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Wait For Element To Exist")]
[Attributes.PropertyAttributes.PropertyUISelectionOption("Switch to frame")]
[Attributes.PropertyAttributes.InputSpecification("Select the appropriate corresponding action to take once the element has been located")]
[Attributes.PropertyAttributes.SampleUsage("Select from **Invoke Click**, **Left Click**, **Right Click**, **Middle Click**, **Double Left Click**, **Clear Element**, **Set Text**, **Get Text**, **Get Attribute**, **Wait For Element To Exist**")]
[Attributes.PropertyAttributes.Remarks("Selecting this field changes the parameters that will be required in the next step")]
Expand Down Expand Up @@ -171,9 +172,8 @@ where rw.Field<string>("Parameter Name") == "Timeout (Seconds)"

return;
}
else
else if (seleniumSearchParam != string.Empty)
{

element = FindElement(seleniumInstance, seleniumSearchParam);
}

Expand Down Expand Up @@ -319,7 +319,19 @@ where rw.Field<string>("Parameter Name") == "Variable Name"
break;
case "Clear Element":
element.Clear();
break;

case "Switch to frame":
if (seleniumSearchParam == "")
{
seleniumInstance.SwitchTo().DefaultContent();
}
else
{
seleniumInstance.SwitchTo().Frame(element);
}
break;

default:
throw new Exception("Element Action was not found");
}
Expand Down Expand Up @@ -546,7 +558,15 @@ public void seleniumAction_SelectionChangeCommitted(object sender, EventArgs e)
{
actionParameters.Rows.Add("Timeout (Seconds)");
}
break;

case "Switch to frame":
foreach (var ctrl in ElementParameterControls)
{
ctrl.Hide();
}
break;

default:
break;
}
Expand Down
30 changes: 19 additions & 11 deletions taskt/Core/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@
namespace taskt.Core
{
public class Theme
{
public LinearGradientBrush CreateGradient(Rectangle rect)
{
var tasktBlue = Color.FromArgb(20, 136, 204);
var tasktPurple = Color.FromArgb(43, 50, 178);
LinearGradientBrush linearGradientBrush =
new LinearGradientBrush(rect, tasktPurple, tasktBlue, 180);
return linearGradientBrush;

//e.Graphics.FillRectangle(linearGradientBrush, pnlMain.ClientRectangle);

{

Color _BgGradientStartColor = Color.FromArgb(20, 136, 204);
public Color BgGradientStartColor
{
get { return _BgGradientStartColor; }
set { _BgGradientStartColor = value; }
}

Color _BgGradientEndColor = Color.FromArgb(43, 50, 178);
public Color BgGradientEndColor
{
get { return _BgGradientEndColor; }
set { _BgGradientEndColor = value; }
}

public LinearGradientBrush CreateGradient(Rectangle rect)
{
return new LinearGradientBrush(rect, _BgGradientStartColor, _BgGradientEndColor, 180);
}

}
}
9 changes: 8 additions & 1 deletion taskt/UI/CustomControls/CustomControls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,18 @@ public class UITabControl : TabControl

public partial class UIPanel : Panel
{
private taskt.Core.Theme _Theme = new taskt.Core.Theme();
public taskt.Core.Theme Theme
{
get { return _Theme; }
set { _Theme = value; }
}

protected override void OnPaint(PaintEventArgs e)
{


var brush = new Core.Theme().CreateGradient(this.ClientRectangle);
var brush = this.Theme.CreateGradient(this.ClientRectangle);
e.Graphics.FillRectangle(brush, this.ClientRectangle);


Expand Down
20 changes: 19 additions & 1 deletion taskt/UI/Forms/ThemedForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
Expand All @@ -21,9 +22,26 @@ private void ThemedForm_Load(object sender, EventArgs e)
{

}

protected override void OnShown(EventArgs e)
{
base.OnShown(e);
if (this.ClientSize.Height > Screen.PrimaryScreen.WorkingArea.Height - this.CurrentAutoScaleDimensions.Height) // Resizes if too tall to fit
{
this.ClientSize = new Size(this.ClientSize.Width, Screen.PrimaryScreen.WorkingArea.Height - (int)this.CurrentAutoScaleDimensions.Height);
}
}

private taskt.Core.Theme _Theme = new taskt.Core.Theme();
public taskt.Core.Theme Theme
{
get { return _Theme; }
set { _Theme = value; }
}

protected override void OnPaint(PaintEventArgs e)
{
e.Graphics.FillRectangle(new Core.Theme().CreateGradient(this.ClientRectangle), this.ClientRectangle);
e.Graphics.FillRectangle(this.Theme.CreateGradient(this.ClientRectangle), this.ClientRectangle);
base.OnPaint(e);
}
public static void MoveFormToBottomRight(Form sender)
Expand Down
10 changes: 9 additions & 1 deletion taskt/UI/Forms/frmScriptBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,8 +1359,9 @@ private void BeginImportProcess()
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
//import
Cursor.Current = Cursors.WaitCursor;
Import(openFileDialog.FileName);

Cursor.Current = Cursors.Default;
}

}
Expand All @@ -1386,6 +1387,13 @@ private void Import(string filePath)

//import
PopulateExecutionCommands(deserializedScript.Commands);
foreach (Core.Script.ScriptVariable var in deserializedScript.Variables)
{
if (scriptVariables.Find(alreadyExists => alreadyExists.VariableName == var.VariableName) == null)
{
scriptVariables.Add(var);
}
}

//comment
lstScriptActions.Items.Add(CreateScriptCommandListViewItem(new Core.Automation.Commands.CommentCommand() { v_Comment = "End Import From " + fileName + " @ " + dateTimeNow }));
Expand Down
17 changes: 15 additions & 2 deletions taskt/UI/Forms/frmScriptEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ private void Engine_ScriptFinishedEvent(object sender, ScriptFinishedEventArgs e
AddStatus("Total Execution Time: " + e.ExecutionTime.ToString());

if(CloseWhenDone)
{
this.Close();
{
engineInstance.tasktEngineUI.Invoke((Action)delegate () { this.Close(); });
}

}
Expand Down Expand Up @@ -313,6 +313,19 @@ private void UpdateUI(string mainLogoText)
pbBotIcon.Image = Properties.Resources.error;
}

if (mainLogoText.Contains("(error)"))
{
this.Theme.BgGradientStartColor = Color.DarkRed;
this.Theme.BgGradientEndColor = Color.LightCoral;
this.Invalidate();
}
else if (mainLogoText.Contains("(success)"))
{
this.Theme.BgGradientStartColor = Color.DarkGreen;
this.Theme.BgGradientEndColor = Color.LightGreen;
this.Invalidate();
}

//reset debug line
if (callBackForm != null)
callBackForm.DebugLine = 0;
Expand Down
3 changes: 1 addition & 2 deletions taskt/UI/Forms/frmScriptVariables.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ private TreeNode GetSelectedTopNode()

private void panel2_Paint(object sender, PaintEventArgs e)
{
var brush = new Core.Theme().CreateGradient(panel2.ClientRectangle);
e.Graphics.FillRectangle(brush, panel2.ClientRectangle);
e.Graphics.FillRectangle(this.Theme.CreateGradient(panel2.ClientRectangle), panel2.ClientRectangle);
}
}
}

0 comments on commit 3fbe7bb

Please sign in to comment.