private void CommandSelection_Click(object sender, EventArgs e) { while (flwCommandSelections.Controls.Count > 0) { flwCommandSelections.Controls.RemoveAt(0); } sharpRPA.UI.CustomControls.CommandGroupControl selectedControl = (sharpRPA.UI.CustomControls.CommandGroupControl)sender; var availableCommands = groupedCommands.Where(cmd => FindAssignedGroup(cmd) == selectedControl.GroupName).FirstOrDefault(); foreach (var cmd in availableCommands) { //Instantiate Class Core.AutomationCommands.ScriptCommand newCommand = (Core.AutomationCommands.ScriptCommand)Activator.CreateInstance(cmd); sharpRPA.UI.CustomControls.CommandItemControl newitm = new sharpRPA.UI.CustomControls.CommandItemControl(); if (uiImages.ContainsKey(newCommand.CommandName)) { newitm.CommandImage = uiImages[newCommand.CommandName]; } newitm.CommandDisplay = newCommand.SelectionName; newitm.FunctionalDescription = FindFunctionalDescription(cmd); newitm.ImplementationDescription = FindImplementationDescription(cmd); newitm.ForeColor = Color.White; newitm.Click += CommandItem_Click; flwCommandSelections.Controls.Add(newitm); } }
private void frmCommandSelector_Load(object sender, EventArgs e) { uiImages = UI.Images.UIImageDictionary(); groupedCommands = Assembly.GetExecutingAssembly().GetTypes() .Where(t => t.Namespace == "sharpRPA.Core.AutomationCommands") .Where(t => t.Name != "ScriptCommand") .Where(t => t.IsAbstract == false) .Where(t => t.BaseType.Name == "ScriptCommand") .Where(t => CommandEnabled(t)) .GroupBy(t => t.GetCustomAttribute(typeof(Core.AutomationCommands.Attributes.ClassAttributes.Group))) .ToList(); foreach (var cmds in groupedCommands) { string assignedGroup = FindAssignedGroup(cmds); sharpRPA.UI.CustomControls.CommandGroupControl newFolderGroupControl = new sharpRPA.UI.CustomControls.CommandGroupControl(); newFolderGroupControl.Click += CommandSelection_Click; newFolderGroupControl.GroupName = assignedGroup; flwCommandCategories.Controls.Add(newFolderGroupControl); } }