public void addToLoadedO2ModulesMenu(string menuItemName, O2Thread.FuncVoid onMenuItemClick)
        {
            DI.o2GuiWithDockPanel.invokeOnThread(
                () =>
                    {
                        var toolStripItem = new ToolStripMenuItem(
                            menuItemName, null,new EventHandler((_object, _EventArgs) =>O2Thread.mtaThread(onMenuItemClick)));

                        ;
                        loadedO2ModuleToolStripMenuItem.DropDownItems.Add(toolStripItem);
                    });
        }
 public static void backupGac(string zipFileToSaveGacContents)
 {
     O2Thread.mtaThread(
         () =>
     {
         PublicDI.log.info("Started unzip process of Gac Folder");
         var timer = new O2Timer("Gac Backup").start();
         new zipUtils().zipFolder(DI.PathToGac, zipFileToSaveGacContents);
         var logMessage = String.Format("Contents of \n\n\t{0}\n\n saved to \n\n\t{1}\n\n ", DI.PathToGac, zipFileToSaveGacContents);
         timer.stop();
         PublicDI.log.info(logMessage);
         PublicDI.log.showMessageBox(logMessage);
     });
 }
Ejemplo n.º 3
0
 public static void nTimesWithDelay(int count, int delay, bool runInMtaThread, MethodInvoker methodInvoker)
 {
     if (runInMtaThread)
     {
         O2Thread.mtaThread(() => nTimesWithDelay(count, delay, false, methodInvoker));
     }
     else
     {
         for (int i = 0; i < count; i++)
         {
             methodInvoker();
             Processes.Sleep(delay);
         }
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// ASync execution of code on the the Control thread unless we are on the correct thread
        /// and the execution will be sync
        /// </summary>
        public static void invokeOnThread(this Control control, O2Thread.FuncVoid codeToInvoke)
        {
            try
            {
                if (control.InvokeRequired)
                    control.Invoke(new EventHandler((sender, e) => codeToInvoke()));     
                else                                   
                    codeToInvoke();
            }

            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);                
            }
        }
Ejemplo n.º 5
0
        public void loadFiles(List<String> lFilesToLoad, O2Thread.FuncVoidT1<int> onPartialLoad)
        {
            int iFilesProcessed = 0;
            foreach (String sFileToLoad in lFilesToLoad)
            {
                loadFile(sFileToLoad);
                if (iFilesProcessed++ % 100 == 0)
                {
                    DI.log.info("Processed files: {0} /{1}", iFilesProcessed, lFilesToLoad.Count);
                    if (onPartialLoad != null)
                        onPartialLoad(iFilesProcessed);
                }
            }

            // some file stats

            DI.log.debug("Number of Files Currently Loaded: {0}", dLoadedFilesCache.Keys.Count);
            int iLinesOfCode = 0;
            //int iChars = 0;
            foreach (var lsLines in dLoadedFilesCache.Values)
                iLinesOfCode += lsLines.Count;
            DI.log.debug("Number of Lines of Code Currently Loaded: {0}", iLinesOfCode);
        }
Ejemplo n.º 6
0
 public static void addMenuItemWithOnClickEvent(string menuItemName, O2Thread.FuncVoid onMenuItemClick)
 {
 }
Ejemplo n.º 7
0
 public static List<String> getListOfAllFilesFromDirectory(String sStartDirectory, bool bSearchRecursively, O2Thread.FuncVoidT1<List<String>> onComplete)
 {
     var lsFiles = new List<string>();
     O2Thread.mtaThread(
         () =>
             {
                 getListOfAllFilesFromDirectory(lsFiles, sStartDirectory, bSearchRecursively, "*.*", false);
                 onComplete(lsFiles);
             });
     return lsFiles;
 }
Ejemplo n.º 8
0
        public Thread loadAssesmblyDataIntoTreeView(Assembly aAssemblyToLoad, TreeView tvTargetTreeView,
                                                    Label lbLastMethodExecuted, bool bOnlyShowStaticMethods)
        {
            tvTargetTreeView.Visible = false;
            tvTargetTreeView.Nodes.Clear();
            tvTargetTreeView.Sorted = true;
            int iTypesAdded = 0;

            return(O2Thread.mtaThread(() =>
            {
                try
                {
                    var treeNodesToAdd = new List <TreeNode>();
                    foreach (Type tType in aAssemblyToLoad.GetTypes())
                    {
                        if ((iTypesAdded++) % 500 == 0)
                        {
                            PublicDI.log.info("{0} types processed", iTypesAdded);
                        }
                        //vars.set_(tType.Name, tType); // set global variable of compiled code
                        //Callbacks.raiseEvent_ScriptCompiledSuccessfully(tType.Name);
                        TreeNode tnType = O2Forms.newTreeNode(tType.Name, tType.Name, 1, tType);
                        foreach (
                            MethodInfo mMethod in
                            tType.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.DeclaredOnly |
                                             ((bOnlyShowStaticMethods) ? BindingFlags.Static : BindingFlags.Static | BindingFlags.Instance)))
                        {
                            if (mMethod.Name == lbLastMethodExecuted.Text)
                            {
                                lbLastMethodExecuted.Tag = mMethod;
                            }
                            //TreeNode tnMethod = O2Forms.newTreeNode(mMethod.Name, mMethod.Name, 2, mMethod);
                            TreeNode tnMethod =
                                O2Forms.newTreeNode(
                                    new FilteredSignature(mMethod).getReflectorView(),
                                    mMethod.Name, 2, mMethod);
                            tnType.Nodes.Add(tnMethod);
                        }
                        if (tnType.Nodes.Count > 0)
                        {
                            treeNodesToAdd.Add(tnType);
                        }
                        //O2Forms.addNodeToTreeNodeCollection(tvTargetTreeView, tvTargetTreeView.Nodes, tnType);      // thread safe way to add nodes
                    }
                    PublicDI.log.info("{0} types processed , now loading them into treeView", iTypesAdded);
                    tvTargetTreeView.invokeOnThread(() =>
                    {
                        foreach (var treeNode in treeNodesToAdd)
                        {
                            tvTargetTreeView.Nodes.Add(treeNode);
                        }
                        PublicDI.log.info("All nodes loaded");
                        if (tvTargetTreeView.Nodes.Count > 0)
                        {
                            tvTargetTreeView.Nodes[0].Expand();
                        }
                        tvTargetTreeView.Visible = true;
                    });
                }
                catch (Exception ex)
                {
                    PublicDI.log.ex(ex, "in loadAssesmblyDataIntoTreeView");
                }
            }));


            //if (tvTargetTreeView.GetNodeCount(true) < 20)
            //    tvTargetTreeView.ExpandAll();
            //tvTargetTreeView.Visible = true;
        }
Ejemplo n.º 9
0
 public static void addControlToMenu(string menuItemName, O2Thread.FuncVoid onMenuItemClick)
 {
     DI.o2GuiWithDockPanel.addToLoadedO2ModulesMenu(menuItemName, onMenuItemClick);
 }