/// <summary> /// Used by the automation engine to show a message to the user on-screen. If UI is not available, a standard messagebox will be invoked instead. /// </summary> public void ShowMessage(string message, string title, UI.Forms.Supplemental.frmDialog.DialogType dialogType, int closeAfter) { if (InvokeRequired) { var d = new ShowMessageDelegate(ShowMessage); Invoke(d, new object[] { message, title, dialogType, closeAfter }); } else { var confirmationForm = new UI.Forms.Supplemental.frmDialog(message, title, dialogType, closeAfter); confirmationForm.ShowDialog(); } }
private void uiBtnSave_Click(object sender, EventArgs e) { if (lstScriptActions.Items.Count == 0) { return; } int beginLoopValidationCount = 0; int beginIfValidationCount = 0; foreach (ListViewItem item in lstScriptActions.Items) { if (item.Tag is Core.AutomationCommands.BeginLoopCommand) { beginLoopValidationCount++; } else if (item.Tag is Core.AutomationCommands.EndLoopCommand) { beginLoopValidationCount--; } else if (item.Tag is Core.AutomationCommands.BeginIfCommand) { beginIfValidationCount++; } else if (item.Tag is Core.AutomationCommands.EndIfCommand) { beginIfValidationCount--; } //end loop was found first if (beginLoopValidationCount < 0) { Notify("Please verify the ordering of your loops."); return; } //end if was found first if (beginIfValidationCount < 0) { Notify("Please verify the ordering of your ifs."); return; } } //extras were found if (beginLoopValidationCount != 0) { Notify("Please verify the ordering of your loops."); return; } //extras were found if (beginIfValidationCount != 0) { Notify("Please verify the ordering of your ifs."); return; } //define default output path if (this.ScriptFilePath == null) { var fileName = Microsoft.VisualBasic.Interaction.InputBox("Please enter a file name (without extension)", "Enter File Name", "Default", -1, -1); if (fileName == string.Empty) { return; } var rpaScriptsFolder = Core.Common.GetScriptFolderPath(); if (!System.IO.Directory.Exists(rpaScriptsFolder)) { UI.Forms.Supplemental.frmDialog userDialog = new UI.Forms.Supplemental.frmDialog("Would you like to create a folder to save your scripts in now? A script folder is required to save scripts generated with this application. The new script folder path would be '" + rpaScriptsFolder + "'.", "Unable to locate Script Folder!", UI.Forms.Supplemental.frmDialog.DialogType.YesNo, 0); if (userDialog.ShowDialog() == DialogResult.OK) { System.IO.Directory.CreateDirectory(rpaScriptsFolder); } else { return; } } this.ScriptFilePath = rpaScriptsFolder + fileName + ".xml"; } //serialize script try { var exportedScript = Core.Script.Script.SerializeScript(this.ScriptFilePath, lstScriptActions.Items, scriptVariables); //show success dialog Notify("File has been saved successfully!"); } catch (Exception ex) { Notify("Error: " + ex.ToString()); } }
private void frmScriptBuilder_Load(object sender, EventArgs e) { //detect latest release //HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("https://api.github.com/repos/saucepleez/sharpRPA/releases"); //myHttpWebRequest.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2;)"; //HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse(); //StreamReader reader = new StreamReader(myHttpWebResponse.GetResponseStream(), Encoding.UTF8); //String responseString = reader.ReadToEnd(); //Newtonsoft.Json.Linq.JArray jsonArray = Newtonsoft.Json.Linq.JArray.Parse(responseString); //dynamic data = Newtonsoft.Json.Linq.JObject.Parse(jsonArray[0].ToString()); //create undo list undoList = new List <List <ListViewItem> >(); //get app settings var appSettingClass = new Core.ApplicationSettings(); appSettings = appSettingClass.GetOrCreateApplicationSettings(); //get server setting preferences var serverSettings = appSettings.ServerSettings; //try to connect to server if ((serverSettings.ServerConnectionEnabled) && (serverSettings.ConnectToServerOnStartup)) { CreateSocketConnection(serverSettings.ServerURL); } //create folder to store scripts var rpaScriptsFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\sharpRPA\\My Scripts\\"; if (!System.IO.Directory.Exists(rpaScriptsFolder)) { UI.Forms.Supplemental.frmDialog userDialog = new UI.Forms.Supplemental.frmDialog("Would you like to create a folder to save your scripts in now? A script folder is required to save scripts generated with this application. The new script folder path would be '" + rpaScriptsFolder + "'.", "Unable to locate Script Folder!", UI.Forms.Supplemental.frmDialog.DialogType.YesNo, 0); if (userDialog.ShowDialog() == DialogResult.OK) { System.IO.Directory.CreateDirectory(rpaScriptsFolder); } } //get latest files for recent files list on load GenerateRecentFiles(); //get current version lblCurrentVersion.Text = "v" + new Version(System.Windows.Forms.Application.ProductVersion); //no height for status bar tlpControls.RowStyles[3].Height = 0; //instantiate for script variables scriptVariables = new List <Core.Script.ScriptVariable>(); //pnlHeader.BackColor = Color.FromArgb(255, 214, 88); //instantiate and populate display icons for commands uiImages = UI.Images.UIImageList(); lstScriptActions.SmallImageList = uiImages; // tvCommands.ImageList = uiImages; // tvCommands.ImageList.Images.Add(new Bitmap(1,1)); //get commands var groupedCommands = Core.Common.GetGroupedCommands(); foreach (var cmd in groupedCommands) { var group = cmd.Key as Core.AutomationCommands.Attributes.ClassAttributes.Group; TreeNode newGroup = new TreeNode(group.groupName); // newGroup.ImageIndex = tvCommands.ImageList.Images.Count - 1; // newGroup.SelectedImageIndex = tvCommands.ImageList.Images.Count - 1; foreach (var subcmd in cmd) { Core.AutomationCommands.ScriptCommand newCommand = (Core.AutomationCommands.ScriptCommand)Activator.CreateInstance(subcmd); TreeNode subNode = new TreeNode(newCommand.SelectionName); //subNode.ImageIndex = uiImages.Images.IndexOfKey(newCommand.GetType().Name); // subNode.SelectedImageIndex = uiImages.Images.IndexOfKey(newCommand.GetType().Name); newGroup.Nodes.Add(subNode); } tvCommands.Nodes.Add(newGroup); } //tvCommands.ImageList = uiImages; }
public bool ShowMessage(string message, string title, UI.Forms.Supplemental.frmDialog.DialogType dialogType, int closeAfter) { var confirmationForm = new UI.Forms.Supplemental.frmDialog(message, title, dialogType, closeAfter); return(confirmationForm.ShowDialog() == DialogResult.OK); }