public static void downloadFileUsingAscxDownload(string sFileToDownload, String sTargetFileOrFolder,
                                                         Callbacks.dMethod_String dCallbackWhenCompleted)
        {
            O2Thread.mtaThread(
                () =>
            {
                var windowTitle = string.Format("{0} : {1}", "Download File", sFileToDownload);
                O2Messages.openControlInGUISync(typeof(ascx_DownloadFile), O2DockState.Float, windowTitle);

                O2Messages.getAscx(windowTitle,
                                   guiControl =>
                {
                    if (guiControl != null && guiControl is ascx_DownloadFile)
                    {
                        //var downloadFile = (IControl_DownloadFile)guiControl;
                        //O2Messages.openAscxGui(typeof (ascx_DownloadFile), O2DockState.Float, "Download File");
                        var adfDownloadFile = (ascx_DownloadFile)guiControl;
                        // Exec.openNewWindowWithControl("DownloadFile");
                        adfDownloadFile.invokeOnThread(
                            delegate
                        {
                            adfDownloadFile.setDownloadDetails(sFileToDownload, sTargetFileOrFolder);
                            adfDownloadFile.setAutoCloseOnDownload(true);
                            adfDownloadFile.setCallBackWhenCompleted(dCallbackWhenCompleted);
                            adfDownloadFile.downloadFile();
                            return(null);
                        });
                    }
                });
            });
        }
Beispiel #2
0
        public void Test_LoadFindingsInGui()
        {
            DI.log.info("Opening GUI");
            if (O2AscxGUI.launch())
            {
                O2Messages.openControlInGUI(typeof(ascx_CirViewer_CirData), O2DockState.Document, "Cir Viewer");
                var cirAnalysisControlName = "Cir Analysis";
                O2Messages.openControlInGUI(typeof(ascx_CirAnalysis), O2DockState.DockTop, cirAnalysisControlName);
                O2Messages.getAscx(cirAnalysisControlName, actionsToExecuteOnCirAnalysisControl);

                //O2Messages.setCirData(cirData);
            }
        }
 public static void viewCirFunctionSignatureOnNewForm(ICirFunction cirFunction)
 {
     O2Thread.mtaThread(
         () =>
     {
         var windowName = string.Format("Function Viewer: {0}", cirFunction.FunctionSignature);
         O2Messages.openControlInGUISync(typeof(ascx_FunctionCalls), O2DockState.Float, windowName);
         O2Messages.getAscx(windowName,
                            ascxControl =>
                            ((ascx_FunctionCalls)ascxControl).viewCirFunction(cirFunction));
     }
         );
 }
Beispiel #4
0
 public static Thread openInFloatWindow(List <IO2Finding> o2Findings, string windowTitle)
 {
     return(O2Thread.mtaThread(() =>
     {
         O2Messages.openControlInGUISync(typeof(ascx_FindingsViewer), O2DockState.Float, windowTitle);
         O2Messages.getAscx(windowTitle, guiControl =>
         {
             if (guiControl != null && guiControl is ascx_FindingsViewer)
             {
                 var findingsViewer = (ascx_FindingsViewer)guiControl;
                 findingsViewer.loadO2Findings(o2Findings);
             }
         });
     }));
 }
Beispiel #5
0
 public static void openInFloatWindow(IO2Finding o2Finding)
 {
     O2Thread.mtaThread(
         () =>
     {
         var windowName = "Finding Editor for: " + o2Finding;
         O2Messages.openControlInGUISync(typeof(ascx_FindingEditor), O2DockState.Float,
                                         windowName);
         O2Messages.getAscx(windowName, guiControl =>
         {
             if (guiControl != null &&
                 guiControl is ascx_FindingEditor)
             {
                 var findingEditor =
                     (ascx_FindingEditor)guiControl;
                 findingEditor.loadO2Finding(
                     o2Finding, false);
             }
         });
     });
 }
Beispiel #6
0
        public static void o2MessageHelper_Handle_IM_FileOrFolderSelected(IO2Message o2Message, string parentControl)
        {
            // open file in ascx_SourceCodeEditor
            if (o2Message is IM_FileOrFolderSelected)
            {
                var fileOrFolderSelectedMessage = ((IM_FileOrFolderSelected)o2Message);
                //var fileSelected = .pathToFileOrFolder;
                fileOrFolderSelectedMessage.pathToFileOrFolder = tryToResolveFileLocation(fileOrFolderSelectedMessage.pathToFileOrFolder, O2AscxGUI.getGuiWithDockPanelAsControl());
                if (File.Exists(fileOrFolderSelectedMessage.pathToFileOrFolder))
                {
                    // var filename = Path.GetFileName(fileOrFolderSelectedMessage.pathToFileOrFolder);

                    var ascx_ScriptControl = getScriptEditor(fileOrFolderSelectedMessage.pathToFileOrFolder);
                    O2Messages.getAscx(ascx_ScriptControl,
                                       guiControl =>
                    {
                        if (guiControl != null && guiControl is ascx_SourceCodeEditor)
                        {
                            var sourceCodeEditor = (ascx_SourceCodeEditor)guiControl;
                            switch (fileOrFolderSelectedMessage.messageText)
                            {
                            case "KM_Show_Selected_Text":
                                loadFileAndSelectText(sourceCodeEditor, fileOrFolderSelectedMessage);
                                break;

                            default:
                                loadFileAndSelectLine(sourceCodeEditor, fileOrFolderSelectedMessage);
                                break;
                            }

                            if (parentControl != null)
                            {
                                O2DockUtils.setDockContentState(parentControl,
                                                                O2DockState.DockLeft);
                            }
                        }
                    });
                }
            }
        }
Beispiel #7
0
        private static void openO2FindingOnNewGuiWindow(IO2Finding o2FindingToOpen)
        {
            O2Thread.mtaThread(() =>
            {
                var findingEditorControlName = string.Format("Findings Editor for: {0}               ({1})", o2FindingToOpen, Guid.NewGuid());
                O2Messages.openControlInGUISync(typeof(ascx_FindingEditor), O2DockState.Float,
                                                findingEditorControlName);
                O2Messages.getAscx(findingEditorControlName, controlObject =>
                {
                    if (controlObject != null && controlObject is ascx_FindingEditor)
                    {
                        var findingEditor = (ascx_FindingEditor)controlObject;
                        findingEditor.loadO2Finding(o2FindingToOpen);
                    }
                });
                // can't use this because we can't  serialized O2Finding (since it has interfaces on it)

                /*
                 * var serializedO2Finding = OzasmtUtils.createSerializedXmlStringFromO2Finding(o2FindingToOpen);
                 * O2Messages.executeOnAscx(findingEditorControlName, "loadSerializedO2Finding",
                 *                       new[] {serializedO2Finding});
                 * */
            });
        }
Beispiel #8
0
        public void test_CirCreatorWorkflow()
        {
            var             guiControlReady = new AutoResetEvent(false);
            ascx_CirCreator cirCreator      = null;

            O2Messages.getAscx(cirAnalysisControlName, ascxControl =>
            {
                if (ascxControl is ascx_CirCreator)
                {
                    cirCreator = (ascx_CirCreator)ascxControl;
                    guiControlReady.Set();
                }
                else
                {
                    DI.log.error("Could not get cirCreator control, aborting!");
                    return;
                }
            });
            guiControlReady.WaitOne(); //give it 2 seconds to setup
            Assert.That(cirCreator != null, "CirCreator control was null");

            // now that we have the control run the Automation tests
            O2AscxGUI.logInfo("Hello from UnitTests : " + cirCreator.GetType().FullName);
            // get directories controls
            var directory_CirCreationQueue = cirCreator.getDirectoryControlFor_CirCreationQueue();
            var directory_CreatedCirFiles  = cirCreator.getDirectoryControlFor_CreatedCirFiles();

            // make sure there are no files in the queue
            Assert.That(directory_CirCreationQueue.getFiles().Count == 0,
                        "There should be no files in the directory Queue");

            var convertTarget      = DI.config.ExecutingAssembly;
            var createdCirDataFile = Path.Combine(directory_CreatedCirFiles.getCurrentDirectory(),
                                                  Path.GetFileName(convertTarget) + ".CirData");

            if (File.Exists(createdCirDataFile))
            {
                DI.log.info("target createdCirDataFile already exists, so deleting it : " + createdCirDataFile);
                Files.deleteFile(createdCirDataFile);
            }
            Assert.That(false == File.Exists(createdCirDataFile), "createdCirDataFile should not exist: " + createdCirDataFile);
            // get the number of files in CreatedCirFiles
            var filesInCreatedCirFilesDir = directory_CreatedCirFiles.getFiles().Count;


            // this will copy the file and trigger the CirCreationQueue
            Files.Copy(convertTarget, directory_CirCreationQueue.getCurrentDirectory());

            Assert.That(directory_CirCreationQueue.getFiles().Count == 1,
                        "Now there should be one file in the directory Queue");


            // wait some time to allow conversion to take place  (ideally we should be hooking into the directory_CreatedCirFiles._onFileWatchEvent
            Thread.Sleep(2000);



            Assert.That(File.Exists(createdCirDataFile), "createdCirDataFile shouold be ther now: " + createdCirDataFile);
            Assert.That(filesInCreatedCirFilesDir + 1 == directory_CreatedCirFiles.getFiles().Count,
                        "There should only had been one extra file in the CreatedCirFiles dir");
        }