コード例 #1
0
        public void ViewExpandedScriptFile()
        {
            ScriptFileTag selectedScriptFileTag = GetSelectedTreeNodeTag() as ScriptFileTag;

            if (selectedScriptFileTag != null)
            {
                if (selectedScriptFileTag._ScriptFileName.ToLower().EndsWith(".vbs"))
                {
                    // TODO!!!!!
                    // The following code should be removed when the business layer is completely implemented!
                    // For now, construct a business layer object that does the execution of the VBS.
                    // BEGIN

                    DvtkApplicationLayer.VisualBasicScript applicationLayerVisualBasicScript =
                        new DvtkApplicationLayer.VisualBasicScript(selectedScriptFileTag._Session as ScriptSession, selectedScriptFileTag._ScriptFileName);

                    applicationLayerVisualBasicScript.ViewExpanded();
                    // END
                }
            }
        }
コード例 #2
0
        private void ExecuteVisualBasicScript()
        {
            try
            {
                ScriptFileTag theScriptFileTag = _TagThatIsBeingExecuted as ScriptFileTag;

                if (theScriptFileTag == null)
                    // Sanity check.
                {
                    Debug.Assert(false);
                }
                else
                {
                    // TODO!!!!!
                    // The following code should be removed when the business layer is completely implemented!
                    // For now, construct a business layer object that does the execution of the VBS.
                    // BEGIN

                    DvtkApplicationLayer.VisualBasicScript applicationLayerVisualBasicScript =
                        new DvtkApplicationLayer.VisualBasicScript(theScriptFileTag._Session as ScriptSession, theScriptFileTag._ScriptFileName);
                    // END

                    String[] emptyArray = {};
                    ArrayList listContainingExmptyArray = new ArrayList();
                    listContainingExmptyArray.Add(emptyArray);

                    applicationLayerVisualBasicScript.Execute(listContainingExmptyArray.ToArray());
                }

                // Update the UI. Do this with an invoke, because the thread that is calling this
                // method is NOT the thread that created all controls used!
                _EndExecution = new EndExecution(_TagThatIsBeingExecuted);

                _TagThatIsBeingExecuted  = null;

                _NotifyDelegate = new NotifyDelegate(_ParentForm.Notify);
                _ParentForm.Invoke(_NotifyDelegate, new object[]{_EndExecution});
            }
            catch (Exception ex)
            {
                //
                // Problem:
                // Errors thrown from a workerthread are eaten by the .NET 1.x CLR.
                // Workaround:
                // Directly call the global (untrapped) exception handler callback.
                // Do NOT rely on
                // either
                // - System.AppDomain.CurrentDomain.UnhandledException
                // or
                // - System.Windows.Forms.Application.ThreadException
                // These events will only be triggered for the main thread not for worker threads.
                //
                CustomExceptionHandler eh = new CustomExceptionHandler();
                System.Threading.ThreadExceptionEventArgs args = new ThreadExceptionEventArgs(ex);
                eh.OnThreadException(this, args);
                //
                // Rethrow. This rethrow may work in the future .NET 2.x CLR.
                // Currently eaten.
                //
                throw ex;
            }
        }
コード例 #3
0
ファイル: ProjectForm2.cs プロジェクト: ewcasas/DVTK
        // May only be called from UpdateTabContents.
        private void TCM_UpdateTabScript()
        {
            _TCM_UpdateCount++;

            bool theHtmlDescriptionExists = false;
            ScriptFileTag theScriptFileTag = null;
            //MediaSessionTag theMediaSessionTag = null;
            string theHtmlDescriptionFileName = null;
            Dvtk.Sessions.ScriptSession theScriptSession = null;

            TreeNodeTag theSelectedTag = GetSelectedTreeNodeTag();
            TreeNode theSelectedNode = GetSelectedNode();

            if (theSelectedTag is ScriptFileTag)
            {
                theScriptFileTag = (ScriptFileTag)theSelectedTag;
            }
            else if (theSelectedTag is ResultsFileTag)
            {
                if (theSelectedNode.Parent.Tag is ScriptFileTag)
                {
                    theScriptFileTag = (ScriptFileTag)theSelectedNode.Parent.Tag;
                }
            }

            if (theScriptFileTag == null)
            {
                // Not supposed to get here.
                throw new System.ApplicationException("Error: not expected to get here.");
            }

            theScriptSession = (Dvtk.Sessions.ScriptSession)GetSelectedSession();

            // Is the description directory not empty?
            if (theScriptSession.DescriptionDirectory != "")
            {
                DirectoryInfo theDirectoryInfo = new DirectoryInfo(theScriptSession.DescriptionDirectory);

                // Does the description directory exist?
                if (theDirectoryInfo.Exists)
                {
                    theHtmlDescriptionFileName = System.IO.Path.Combine(theScriptSession.DescriptionDirectory, theScriptFileTag._ScriptFileName);
                    theHtmlDescriptionFileName = theHtmlDescriptionFileName.Replace ('.', '_') + ".html";

                    // Does the html description file exists?
                    if (File.Exists(theHtmlDescriptionFileName))
                    {
                        // Now we know the html description file exists.
                        theHtmlDescriptionExists = true;
                    }
                }
            }

            if (theHtmlDescriptionExists)
            {
                object Zero = 0;
                object EmptyString = "";

                RichTextBoxScript.Visible = false;
                axWebBrowserScript.Visible = true;

                axWebBrowserScript.Navigate (theHtmlDescriptionFileName, ref Zero, ref EmptyString, ref EmptyString, ref EmptyString);
            }
            else
            {

                axWebBrowserScript.Visible = false;
                RichTextBoxScript.Visible = true;

                RichTextBoxScript.Clear();

                // If this is a Visual Basic Script...
                if (theScriptFileTag._ScriptFileName.ToLower().EndsWith(".vbs"))
                {
                    // TODO!!!!!
                    // The following code should be removed when the business layer is completely implemented!
                    // For now, construct a business layer object.
                    // BEGIN

                    DvtkApplicationLayer.VisualBasicScript applicationLayerVisualBasicScript =
                        new DvtkApplicationLayer.VisualBasicScript(theScriptSession, theScriptFileTag._ScriptFileName);
                    // END

                    if (_MainForm._UserSettings.ExpandVisualBasicScript)
                    {
                        String includeErrors;
                        String expandedContent = applicationLayerVisualBasicScript.GetExpandedContent(out includeErrors);

                        // If include errors exist...
                        if (includeErrors.Length > 0)
                        {
                            RichTextBoxScript.Text = includeErrors;
                            RichTextBoxScript.SelectAll();
                            RichTextBoxScript.SelectionColor = Color.Red;
                            RichTextBoxScript.Select(0, 0);
                            RichTextBoxScript.SelectionColor = Color.Black;
                            RichTextBoxScript.AppendText(expandedContent);
                        }
                            // If no include errors exist...
                        else
                        {
                            RichTextBoxScript.Text = expandedContent;
                        }
                    }
                    else
                    {
                        RichTextBoxScript.Text = applicationLayerVisualBasicScript.GetContent();
                    }

                }
                    // If this is not a visual basic script...
                else
                {
                    string theFullScriptFileName;

                    theFullScriptFileName = System.IO.Path.Combine(theScriptSession.DicomScriptRootDirectory, theScriptFileTag._ScriptFileName);

                    RichTextBoxScript.LoadFile(theFullScriptFileName, RichTextBoxStreamType.PlainText);
                }
            }

            _TCM_UpdateCount--;
        }