/// <summary> /// Executes a model after verifying that it is ready /// </summary> /// <param name="error">A string parameter which will contains a error string if one is generated</param> /// <returns>Returns true if it executed succesfully</returns> public bool ExecuteModel(out string error) { //Make sure all the tools are ready for execution foreach (ToolElement te in _modelElements.FindAll(delegate(ModelElement o) { return (o as ToolElement != null); })) { if (te.ToolStatus == ToolStatus.Error || te.ToolStatus == ToolStatus.Empty) { error = te.Name + " is not ready for execution"; return false; } } //The number of tools to execute _toolToExeCount = _modelElements.FindAll(delegate(ModelElement o) { return (o as ToolElement != null); }).Count; //First we create the progress form ToolProgress progForm = new ToolProgress(_toolToExeCount); //We create a background worker thread to execute the tool BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += BWToolThreader; object[] threadParamerter = new object[1]; threadParamerter[0] = progForm; // Show the progress dialog and kick off the Async thread bw.RunWorkerAsync(threadParamerter); progForm.ShowDialog(this); error = ""; //Make sure all the tools are ready for execution foreach (ToolElement te in _modelElements.FindAll(delegate(ModelElement o) { return (o as ToolElement != null); })) te.ExecutionStatus = ToolExecuteStatus.NotRun; return true; }
/// <summary> /// When the user double clicks one of the tools this event fires /// </summary> /// <param name="e"></param> protected override void OnDoubleClick(EventArgs e) { base.OnDoubleClick(e); // Get the node at the current mouse pointer location. TreeNode theNode = GetNodeAt(PointToClient(Cursor.Position).X, PointToClient(Cursor.Position).Y); // Checks if the user double clicked a node and not a white spot if ((theNode != null)) { // checks if the user clicked a tool or a category if (_toolInfoList.ContainsKey(theNode.Name)) { //We Generate an instance of the tool and dialog box to go with it ITool toolToExecute = NewTool(theNode.Name); toolToExecute.WorkingPath = _tempPath; ToolDialog td = new ToolDialog(toolToExecute, DataSets); DialogResult tdResult = td.ShowDialog(this); while (tdResult == DialogResult.OK && td.ToolStatus != ToolStatus.Ok) { MessageBox.Show(MessageStrings.ToolSetupIncorectly); tdResult = td.ShowDialog(this); } if (tdResult == DialogResult.OK && td.ToolStatus == ToolStatus.Ok) { //This fires when the user clicks the "OK" button on a tool dialog //First we create the progress form ToolProgress progForm = new ToolProgress(1); //We create a background worker thread to execute the tool BackgroundWorker bw = new BackgroundWorker(); bw.DoWork += bw_DoWork; bw.RunWorkerCompleted += bw_RunWorkerCompleted; object[] threadParamerter = new object[2]; threadParamerter[0] = toolToExecute; threadParamerter[1] = progForm; // Show the progress dialog and kick off the Async thread progForm.Show(this); bw.RunWorkerAsync(threadParamerter); } } } }