Ejemplo n.º 1
0
        private void updateSBWMenu()
        {
            if (!MainForm.IsSBWAvailable)
            {
                return;
            }
            try
            {
                bool bWasConnected = LowLevel.SBWGetConnectionStatus();
                if (!bWasConnected)
                {
                    LowLevel.SBWConnect();
                }

                oSBWMenu.DropDownItems.Clear();
                oAnalyzers = new Hashtable();
                var         oBroker  = new Module("BROKER");
                Service     oService = oBroker.getService("BROKER");
                Method      oMethod  = oService.getMethod("{}[] findServices(string,boolean)");
                ArrayList[] oList    = oMethod.Call("/Analysis", true).get1DListArray();

                var oModules = new SortedList(CaseInsensitiveComparer.Default);

                foreach (ArrayList list in oList)
                {
                    try
                    {
                        var uniqueName = (string)list[2];
                        if (oModules.Contains(uniqueName))
                        {
                            uniqueName += String.Format(" ({0})", list[0]);
                        }
                        oModules.Add(uniqueName, list);
                    }
                    catch (Exception)
                    {
                    }
                }

                foreach (DictionaryEntry entry in oModules)
                {
                    var sKey = (string)entry.Key;
                    var list = (ArrayList)entry.Value;
                    if ("AutoCSharp" != (string)list[0])
                    {
                        var uniqueName = (string)list[2];
                        if (oAnalyzers.Contains(uniqueName))
                        {
                            uniqueName += String.Format(" ({0})", list[0]);
                        }
                        var oItem = new ToolStripMenuItem(uniqueName);

                        oAnalyzers.Add(uniqueName, new SBWAnalyzer((string)list[0], (string)list[1]));

                        oItem.Click += oItem_Click;
                        oSBWMenu.DropDownItems.Add(oItem);
                    }
                }


                if (!bWasConnected)
                {
                    LowLevel.SBWDisconnect();
                }
            }
            catch (Exception)
            {
            }
        }