Ejemplo n.º 1
0
        private void frmProcessingStatus_Load(object sender, EventArgs e)
        {
            //get engine settings
            EngineContext.EngineSettings = new ApplicationSettings().GetOrCreateApplicationSettings().EngineSettings;

            //add hooks for hot key cancellation
            GlobalHook.HookStopped += new EventHandler(OnHookStopped);
            GlobalHook.StartEngineCancellationHook(EngineContext.EngineSettings.CancellationKey);
            GlobalHook.KeyDownEvent += GlobalHook_KeyDownEvent;

            if (_isParentScheduledTask)
            {
                List <string> assemblyList = NugetPackageManager.LoadPackageAssemblies(_configPath, true);
                Dictionary <string, List <Type> > groupedTypes = new Dictionary <string, List <Type> >();
                Dictionary <string, List <AssemblyReference> > allNamespaces = new Dictionary <string, List <AssemblyReference> >();
                var builder = AppDomainSetupManager.LoadBuilder(assemblyList, groupedTypes, allNamespaces, ScriptDefaultNamespaces.DefaultNamespaces);// EngineContext.ImportedNamespaces);
                EngineContext.Container = builder.Build();
            }

            //move engine form to bottom right and bring to front
            if (EngineContext.EngineSettings.ShowDebugWindow || EngineContext.IsDebugMode)
            {
                BringToFront();
                MoveFormToBottomRight(this);
            }
            else
            {
                MoveFormToBottomRight(this);
            }

            if (!EngineContext.IsDebugMode && !EngineContext.EngineSettings.ShowDebugWindow)
            {
                FormsHelper.HideForm(this);
            }

            //if listbox should be shown
            if (EngineContext.EngineSettings.ShowAdvancedDebugOutput || EngineContext.IsDebugMode)
            {
                lstSteppingCommands.Show();
                lblMainLogo.Show();
                pbBotIcon.Hide();
                lblAction.Hide();
            }
            else
            {
                lstSteppingCommands.Hide();
                lblMainLogo.Hide();
                pbBotIcon.Show();
                lblAction.Show();
            }

            //start running
            EngineInstance = new AutomationEngineInstance(EngineContext);

            if (IsNewTaskSteppedInto)
            {
                EngineInstance.PauseScript();
                uiBtnPause.Image       = Resources.engine_resume;
                uiBtnPause.DisplayText = "Resume";
                uiBtnStepOver.Visible  = true;
                uiBtnStepInto.Visible  = true;

                EngineContext.ScriptBuilder.CurrentEngine = this;

                //toggle running flag to allow for tab selection
                EngineContext.ScriptBuilder.IsScriptRunning = false;
                ((frmScriptBuilder)EngineContext.ScriptBuilder).OpenOpenBotsFile(EngineContext.FilePath, true);
                EngineContext.ScriptBuilder.IsScriptRunning = true;
            }

            EngineInstance.ReportProgressEvent       += Engine_ReportProgress;
            EngineInstance.ScriptFinishedEvent       += Engine_ScriptFinishedEvent;
            EngineInstance.LineNumberChangedEvent    += EngineInstance_LineNumberChangedEvent;
            EngineInstance.EngineContext.ScriptEngine = this;

            EngineInstance.ExecuteScriptAsync();
        }