Exemple #1
0
        /// <summary>
        /// This will update selectClassDlg.selectedClasses with
        ///  classes currently selected. This is necessary to make sure
        /// nodes deleted in SE do not appear as selected in the dialog.
        /// </summary>
        private void UpdateSelectClassDialog()
        {
            try
            {
                if (selectClassDlg == null)
                {
                    return;
                }

                Node[] children = GetNodeSite().GetChildNodes();

                ArrayList stChildren = new ArrayList(50);

                for (int i = 0; i < children.Length; i++)
                {
                    if (children[i] is WMIClassNode)
                    {
                        WMIClassNode wmiClass = (WMIClassNode)children[i];
                        stChildren.Add(wmiClass.pathNoServer);
                    }
                }
                ((SelectWMIClassTreeDialog)selectClassDlg).SelectedClasses = stChildren;
            }

            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
        private void OnSelectClass(Object source, EventArgs args)
        {
            try
            {
                StringTable strs = new StringTable(50);

                SelectWMIClassTreeDialog selectClassDlg = new SelectWMIClassTreeDialog(
                    serverName,
                    ClassFilters.ConcreteData,
                    //SchemaFilters.NoEvent|SchemaFilters.NoAbstract|	SchemaFilters.NoSystem |SchemaFilters.NoAssoc,
                    strs);


                DialogResult ret = ((SelectWMIClassTreeDialog)selectClassDlg).ShowDialog();

                if (ret != DialogResult.OK)
                {
                    return;
                }

                String selClass = ((SelectWMIClassTreeDialog)selectClassDlg).SelectedClasses.ToArray()[0];
                targetClassBox.Text = selClass;


                QueryText.Text = "SELECT * FROM " + EventName + " WITHIN " + pollingIntervalBox.Text +
                                 " WHERE TargetInstance ISA \"" + ClassName + "\"";
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
        private void AddWholeNS(TreeNode selNode)
        {
            try
            {
                if (selNode.Parent != null)
                {
                    //this is not a namespace
                    return;
                }
                if (selNode.Nodes.Count == 1 && selNode.Nodes[0].Text == "")
                // the namespace hasn't been expanded before
                {
                    bool bRes = ShowClasses(selNode);
                }

                for (int j = 0; j < selNode.Nodes.Count; j++)
                {
                    DoAddNode(selNode.Nodes.All[j]);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
        //
        // CONSTRUCTORS
        //

        // <doc>
        // <desc>
        //     Main constructor.
        // </desc>
        // </doc>
        public WMIInstanceNode(ManagementObject mgmtObjIn,
                               ManagementClass mgmtClassObjIn,
                               string user,
                               string pw)
        {
            try
            {
                mgmtObj      = mgmtObjIn;
                mgmtClassObj = mgmtClassObjIn;

                ManagementPath mgmtPath = mgmtObj.Path;

                path       = mgmtPath.Path;
                serverName = mgmtPath.Server;
                nsName     = mgmtPath.NamespacePath;
                if (nsName.IndexOf(serverName) == 2 && nsName.Substring(0, 2) == "\\\\")
                {
                    nsName = nsName.Substring(2);
                    nsName = nsName.Substring(nsName.IndexOf("\\") + 1);
                }
                className = mgmtPath.ClassName;
                connectAs = user;
                password  = pw;

                IsNewInstance = (path == string.Empty);
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
                throw (exc);
            }
        }
Exemple #5
0
        private void OnPollingChanged(Object source, EventArgs args)
        {
            try
            {
                Convert.ToDouble(pollingIntervalBox.Text);
            }
            catch (Exception)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Polling_Interval_Validation_Failed",
                                                 pollingIntervalBox.Text));

                pollingIntervalBox.Text = DefaultPollingInterval;
                return;
            }

            if (InstanceEvents.Checked)
            {
                queryString = "SELECT * FROM " + EventName + " WITHIN " + pollingIntervalBox.Text +
                              " WHERE TargetInstance ISA \"" + classTree.SelectedNode.Text + "\"";
            }
            else
            {
                //should never get here
                return;
            }
        }
        public WMIObjectPropertyTable(ISWbemObject wmiObjIn,
                                      PropertyFilters propFiltersIn,
                                      GridMode gridModeIn,
                                      bool showOperatorsIn,
                                      bool showOriginIn,
                                      bool showKeysIn)
        {
            try
            {
                if (wmiObjIn == null)
                {
                    throw (new ArgumentNullException("wmiObj"));
                }

                wmiObj      = wmiObjIn;
                propFilters = propFiltersIn;
                gridMode    = gridModeIn;

                showOperators = showOperatorsIn;
                showOrigin    = showOriginIn;
                showKeys      = showKeysIn;

                Initialize();
            }

            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
        /// <summary>
        ///     This saves new instance to WMI
        /// </summary>
        private void CommitNewInstance(object sender, EventArgs e)
        {
            try
            {
                //call Commit on browse object
                if (browseComponent is  WMIObjectComponent)
                {
                    bool res = ((WMIObjectComponent)browseComponent).Commit();
                    if (res)
                    {
                        //disable commit menu  (remove? leave?)
                        ((ContextMenuItem)sender).Enabled = false;
                        IsNewInstance = false;

                        //update label
                        SetLabel();
                        this.GetNodeSite().UpdateLabel();
                    }
                    else
                    {
                        //Commit failed, remove this node
                        this.GetNodeSite().Remove();
                    }
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
Exemple #8
0
        /// <summary>
        /// IsEvent
        /// </summary>
        /// <param name="obj"> </param>
        static public bool IsEvent(ISWbemObject obj)
        {
            try
            {
                //handle __ExtrinsicEvent class separately, since it is not its own parent
                if (obj.Path_.RelPath.ToString() == "__ExtrinsicEvent")
                {
                    return(true);
                }

                Object[] arParents = (Object[])obj.Derivation_;
                for (int i = 0; i < arParents.Length; i++)
                {
                    if (arParents[i].ToString() == "__ExtrinsicEvent")
                    {
                        return(true);
                    }
                }


                return(false);
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
                return(false);
            }
        }
Exemple #9
0
        /// <summary>
        /// Given an instance of an association object and a path to one of its
        /// endpoints (the "source"), this method returns the role of the other endpoint
        /// (the "target") in this association.
        /// </summary>
        /// <param name="assocInstance"> </param>
        /// <param name="sourcePath"> </param>
        static public String GetAssocTargetRole(ISWbemObject assocInstance,
                                                ISWbemObjectPath sourcePath)
        {
            try
            {
                IEnumerator enumAssocProps = ((IEnumerable)(assocInstance.Properties_)).GetEnumerator();
                while (enumAssocProps.MoveNext())
                {
                    ISWbemProperty curProp = (ISWbemProperty)enumAssocProps.Current;
                    if (curProp.CIMType != WbemCimtypeEnum.wbemCimtypeReference)
                    {
                        continue;
                    }
                    else
                    {
                        //confirm that this is not the source
                        if ((String.Compare(curProp.get_Value().ToString(),
                                            sourcePath.Path, true)) != 0)
                        {
                            return(curProp.Name);
                        }
                    }
                }

                return(String.Empty);
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
                return(String.Empty);
            }
        }
Exemple #10
0
        public static ISWbemObject GetClassObject(String server,
                                                  String ns,
                                                  String className)
        {
            if (ns == string.Empty || className == string.Empty)
            {
                throw new ArgumentException();
            }

            try
            {
                ISWbemLocator wbemLocator = WmiHelper.wbemLocator;                //(ISWbemLocator)(new SWbemLocator());

                ISWbemServices wbemServices = wbemLocator.ConnectServer(server,
                                                                        ns,
                                                                        "",                                                     //user: blank defaults to current logged-on user
                                                                        "",                                                     //password: blank defaults to current logged-on user
                                                                        "",                                                     //locale: blank for current locale
                                                                        "",                                                     //authority: NTLM or Kerberos. Blank lets DCOM negotiate.
                                                                        0,                                                      //flags: reserved
                                                                        null);                                                  //context info: not needed here

                ISWbemObject classObj = wbemServices.Get(className,
                                                         (int)WbemFlagEnum.wbemFlagUseAmendedQualifiers,
                                                         null);
                return(classObj);
            }

            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
                return(null);
            }
        }
Exemple #11
0
        /// <summary>
        /// Given an instance of an association object and a path to one of its
        /// endpoints (the "source"), this method returns the role of the other endpoint
        /// (the "target") in this association.
        /// </summary>
        /// <param name="assocInstance"> </param>
        /// <param name="sourcePath"> </param>
        static public String GetAssocTargetRole(ManagementObject assocInstance,
                                                ManagementPath sourcePath)
        {
            try
            {
                PropertyCollection.PropertyEnumerator enumAssocProps = assocInstance.Properties.GetEnumerator();
                while (enumAssocProps.MoveNext())
                {
                    Property curProp = enumAssocProps.Current;
                    if (curProp.Type != CimType.Reference)
                    {
                        continue;
                    }
                    else
                    {
                        //confirm that this is not the source
                        if ((String.Compare(curProp.Value.ToString(),
                                            sourcePath.Path, true)) != 0)
                        {
                            return(curProp.Name);
                        }
                    }
                }

                return(String.Empty);
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
                return(String.Empty);
            }
        }
Exemple #12
0
        /// <summary>
        /// IsEvent
        /// </summary>
        /// <param name="obj"> </param>
        static public bool IsEvent(ManagementObject obj)
        {
            try
            {
                //handle __ExtrinsicEvent class separately, since it is not its own parent
                if (obj.Path.RelativePath.ToString() == "__ExtrinsicEvent")
                {
                    return(true);
                }

                Object[] arParents = (Object[])obj.SystemProperties["__DERIVATION"].Value;
                for (int i = 0; i < arParents.Length; i++)
                {
                    if (arParents[i].ToString() == "__ExtrinsicEvent")
                    {
                        return(true);
                    }
                }


                return(false);
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
                return(false);
            }
        }
        /// <summary>
        /// This updates the "where" clause of the query text
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        protected void GridRowChanging(object sender,
                                       DataRowChangeEventArgs e)
        {
            try
            {
                if (grid == null || grid.DataSource == null)
                {
                    return;
                }

                //get rid of current "where" clause, if any
                string phrase = QueryString;
                phrase.ToUpper();
                int nWhere = phrase.IndexOf("WHERE");
                if (nWhere >= 0)
                {
                    phrase = QueryString.Substring(0, nWhere);
                }

                QueryText.Text = phrase +
                                 ((WMIObjectPropertyTable)grid.DataSource).WhereClause;
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
Exemple #14
0
        //
        // CONSTRUCTORS
        //

        // <doc>
        // <desc>
        //     Main constructor.
        // </desc>
        // </doc>
        public WMIClassesNode()
        {
            try
            {
                try
                {
                    rm = new ResourceManager("Microsoft.VSDesigner.WMI.Res", // Name of the resource.
                                             ".",                            // Use current directory.
                                             null);
                }
                catch (Exception)
                {
                    //do nothing, will use static RM
                }

                //TextWriterTraceListener lstnr = new TextWriterTraceListener(File.OpenWrite("d:\\temp\\WMI-se.log"));
                Trace.AutoFlush = true;
                //Trace.Listeners.Add(lstnr);

                IEnumerator enumListeners = ((IEnumerable)Trace.Listeners).GetEnumerator();

                /*
                 * while (enumListeners.MoveNext())
                 * {
                 *      MessageBox.Show ("Listener " + enumListeners.Current.GetType().FullName + ", " +
                 *              ((TraceListener)enumListeners.Current).Name);
                 * }
                 */
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
                throw (exc);
            }
        }
Exemple #15
0
        //
        // CONSTRUCTORS
        //

        // <doc>
        // <desc>
        //     Main constructor.
        // </desc>
        // </doc>
        public WMIInstanceNode(ISWbemObject instObj,
                               ISWbemObject classObj)
        {
            try
            {
                try
                {
                    rm = new ResourceManager("Microsoft.VSDesigner.WMI.Res", // Name of the resource.
                                             ".",                            // Use current directory.
                                             null);
                }
                catch (Exception)
                {
                    //do nothing, will use static RM
                }

                wmiObj      = instObj;
                wmiClassObj = classObj;

                ISWbemObjectPath wbemPath = wmiObj.Path_;

                path       = wbemPath.Path;
                serverName = wbemPath.Server;
                nsName     = wbemPath.Namespace;
                className  = wbemPath.Class;

                IsNewInstance = (path == string.Empty);
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
                throw (exc);
            }
        }
        private void Add_click(Object source, EventArgs args)
        {
            try
            {
                if (classList.SelectedNode.Parent == null)
                {
                    //this is a namespace
                    DialogResult res =
                        MessageBox.Show(WMISys.GetString("WMISE_ClassSelectorAskViewAll"),
                                        "",
                                        MessageBox.YesNo);
                    if (res == DialogResult.No)
                    {
                        return;
                    }
                    else
                    {
                        AddWholeNS(classList.SelectedNode);
                    }
                }
                else
                {
                    DoAddNode(classList.SelectedNode);
                }

                classList.SelectedNode = null;
                btnAdd.Enabled         = false;
            }

            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
        private void Search_click(Object source, EventArgs args)
        {
            try
            {
                TreeNode find = DoSearch();
                if (find != null)
                {
                    classList.SelectedNode = find;

                    //classList.SelectedImageIndex = find.Index;

                    nodeLastFindNS   = find.Parent;
                    strLastFindClass = find.Text;

                    find.BackColor = Color.DarkGray;
                    find.ForeColor = Color.White;


                    //add found node to a list, so that the color-coding is removed before
                    //the next search

                    //MessageBox.Show("Length of found nodes list is " + listSearchHits.Count);
                    //MessageBox.Show("Found node is " + find.Text);

                    listSearchHits.Add(find.Handle);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
        private void SearchPattern_changed(Object source, EventArgs args)
        {
            try
            {
                nodeLastFindNS   = null;
                strLastFindClass = "";


                //this is a temp workaround for URT bug 48695: uncomment this later

                /*
                 * if (editSearch.Text != "")
                 * {
                 *      this.AcceptButton = btnGo;
                 *      this.UpdateDefaultButton();
                 * }
                 * else
                 * {
                 *      this.AcceptButton = okBtn;
                 *      this.UpdateDefaultButton();
                 * }
                 */
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
        public void CleanUpPreviousSelections()
        {
            try
            {
                IEnumerator enumHits = listSearchHits.GetEnumerator();
                while (enumHits.MoveNext())
                {
                    Int32 curHandle = (Int32)enumHits.Current;

                    TreeNode oldHit = TreeNode.FromHandle(classList, curHandle);

                    oldHit.BackColor = defaultBackColor;
                    oldHit.ForeColor = defaultForeColor;
                }

                //clean up the highlighted indices list
                listSearchHits.Clear();

                //classList.SelectedNode = null;

                selectedClassList.SelectedIndices.Clear();

                descr.Text = string.Empty;
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
        protected virtual void AfterNodeSelect(Object sender, TreeViewEventArgs args)
        {
            try
            {
                if (classList.SelectedNode != null)
                {
                    btnAdd.Enabled = true;
                }

                TreeNode curNode = args.node;

                //check if this is a namespace
                if (curNode.Parent == null)
                {
                    descr.Text = GetNSDescription(curNode.Text);
                }
                else
                {
                    //Update description field

                    UpdateClassDescription(ClassListControls.ClassTreeView);
                }
            }

            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
        private void DoAddNode(TreeNode node)
        {
            try
            {
                String path =
                    node.Parent.Text + ":" + node.Text;

                //see if the item is already there
                for (int i = 0; i < selectedClassList.Items.All.Length; i++)
                {
                    if (selectedClassList.Items.All[i].ToString().ToUpper() == path.ToUpper())
                    {
                        MessageBox.Show(WMISys.GetString("WMISE_ClassSelectorClassAlreadySelected", path));
                        //selectedClassList.SelectedItem = selectedClassList.Items.All[i];
                        return;
                    }
                }

                //if not, add it:
                selectedClassList.Items.Add(path);
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
Exemple #22
0
        /// <summary>
        /// Subscribes for event notifications
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        private void OnStartReceiving(object sender, EventArgs e)
        {
            try
            {
                //spawn a thread that would receive wmi events
                System.Threading.Thread eventThread = new System.Threading.Thread(new ThreadStart(GetEvents));
                eventThread.Start();

                while (!eventThread.IsAlive)
                {
                    ;
                }

                state = SubscriptionState.Started;
                icon  = new Icon(GetType(), "Start.ico").ToBitmap();

                if (this.GetNodeSite() != null)
                {
                    GetNodeSite().UpdateIcon();
                }
            }
            catch (Exception exc)
            {
                state = SubscriptionState.Error;
                icon  = new Icon(GetType(), "ErrorNode.ico").ToBitmap();
                this.GetNodeSite().UpdateIcon();
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
Exemple #23
0
        private void CancelDlgThread()
        {
            try
            {
                if (cancelDlg != null)
                {
                    cancelDlg.Hide();
                    cancelDlg.Dispose();
                    cancelDlg = null;
                }

                cancelDlg = new TreeCancelDialog(WMISys.GetString("WMISE_PleaseWait", curNSExpanded.Text),
                                                 this.Location.X + 40,
                                                 this.Location.Y + 40);

                DialogResult res = cancelDlg.ShowDialog();
                if (res == DialogResult.Cancel)
                {
                    bCancelled = true;
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", e.Message, e.StackTrace));
            }
        }
        private void Initialize(ISWbemObject wbemObj)
        {
            try
            {
                ISWbemObjectPath path = (ISWbemObjectPath)wbemObj.Path_;

                //get the property
                ISWbemPropertySet props = (ISWbemPropertySet)wbemObj.Properties_;
                prop = props.Item(propName, 0);

                if (path.IsClass)
                {
                    genus     = 1;
                    classProp = prop;
                }
                else                    //instance
                {
                    genus     = 2;
                    classProp = ((ISWbemPropertySet)wmiClassObj.Properties_).Item(propName, 0);
                }


                mgmtProp      = mgmtObj.Properties[propName];
                mgmtClassProp = mgmtClassObj.Properties[propName];
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
Exemple #25
0
        /// <summary>
        /// Create new instance of the class
        /// </summary>
        /// <param name="sender"> </param>
        /// <param name="e"> </param>
        private void OnCreateNewInstance(object sender, EventArgs e)
        {
            try
            {
                if (this.GetNodeSite().GetChildCount() == 0)
                {
                    Node[] children = this.CreateChildren();
                    for (int i = 0; i < children.Length; i++)
                    {
                        GetNodeSite().AddChild(children[i]);
                    }
                }

                //spawn new object and add it as a child node
                ManagementObject newInst   = ((ManagementClass)mgmtObj).CreateInstance();
                WMIInstanceNode  childNode = new WMIInstanceNode(newInst, mgmtObj, this.connectAs, this.password);
                childNode.Label = WMISys.GetString("WMISE_ClassNode_NewInstanceLbl", this.label);
                GetNodeSite().AddChild(childNode);
                childNode.GetNodeSite().Select();
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
Exemple #26
0
        public override bool ConfirmDeletingNode()
        {
            DialogResult res = MessageBox.Show(WMISys.GetString("WMISE_ClassNode_RemovePrompt", className),
                                               /*SR.GetString("SE_MessageBoxTitle_ServerExplorer"), */ string.Empty,
                                               MessageBoxButtons.YesNo);

            return(res == DialogResult.Yes);
        }
Exemple #27
0
 public override ContextMenuItem[] GetContextMenuItems()
 {
     return(new ContextMenuItem[] {
         new ContextMenuItem(WMISys.GetString("WMISE_AddEventFilterCM"), new EventHandler(OnAddEventFilter)),
         new ContextMenuItem(WMISys.GetString("WMISE_EventQueryPurge"),
                             new EventHandler(OnPurgeEvents)),
     });
 }
Exemple #28
0
        private void OnSelectWMIClass(object sender, EventArgs e)
        {
            try
            {
                ArrayList strs = new ArrayList(50);

                //First, enumerate existing classes to initialize dialog
                Node[] children = GetNodeSite().GetChildNodes();

                for (int i = 0; i < children.Length; i++)
                {
                    if (children[i] is WMIClassNode)
                    {
                        strs.Add(((WMIClassNode)children[i]).pathNoServer);
                    }
                }

                //get current server name
                ServerNode server     = (ServerNode)GetNodeSite().GetParentNode();
                String     serverName = server.GetUNCName();

                if (selectClassDlg == null)
                {
                    selectClassDlg = new SelectWMIClassTreeDialog(
                        serverName,
                        this.ConnectAs,
                        this.Password,
                        ClassFilters.ConcreteData,
                        //SchemaFilters.NoEvent|SchemaFilters.NoAbstract|	SchemaFilters.NoSystem |SchemaFilters.NoAssoc,
                        strs);
                }

                else
                {
                    //updated selected classes list in the dialog:
                    //to account for the case wheen some class node
                    //was deleted
                    UpdateSelectClassDialog();

                    ((SelectWMIClassTreeDialog)selectClassDlg).CleanUpPreviousSelections();
                }


                DialogResult ret = ((SelectWMIClassTreeDialog)selectClassDlg).ShowDialog();

                if (ret != DialogResult.OK)
                {
                    return;
                }

                //inspect strs and add or delete child nodes as necessary
                UpdateChildren(((SelectWMIClassTreeDialog)selectClassDlg).SelectedClasses);
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
        private bool UpdateClassDescription(ClassListControls curControl)
        {
            string ns        = string.Empty;
            string className = string.Empty;

            if (curControl == ClassListControls.ClassTreeView)
            {
                if (classList.SelectedNode != null)
                {
                    ns        = classList.SelectedNode.Parent.Text;
                    className = classList.SelectedNode.Text;
                }
            }
            else                        //this is a selected class list
            {
                //see if this is a multiple selection (or nothing is selected) and clear description in this case
                if (selectedClassList.SelectedIndices.Count != 1)
                {
                    descr.Text = string.Empty;
                    return(true);
                }

                string relPath = selectedClassList.SelectedItem.ToString();
                ns        = relPath.Substring(0, relPath.IndexOf(":"));
                className = relPath.Substring(relPath.IndexOf(":") + 1);

                // MessageBox.Show(path);
            }

            ISWbemObject obj = WmiHelper.GetClassObject(machineName,
                                                        ns,
                                                        className);

            string theDescr = WmiHelper.GetClassDescription(obj);

            if (theDescr != string.Empty)
            {
                //Add special handling for newlines: change all "\n" to System.Environment.NewLine:
                int    i        = -1;
                string theRest  = theDescr;
                string theStart = string.Empty;
                while ((i = theRest.IndexOf("\n")) >= 0)
                {
                    theStart = theStart + theRest.Substring(0, i) + System.Environment.NewLine;
                    theRest  = theRest.Substring(i + 1);
                }
                theDescr = theStart + theRest;

                descr.Text = theDescr;
                return(true);
            }
            else
            {
                descr.Text = WMISys.GetString("WMISE_NoDescr");
                return(false);
            }
        }
 /// <summary>
 ///     Retrieves the description text.
 /// </summary>
 /// <returns>
 ///     description
 /// </returns>
 public override string GetDescription()
 {
     if (!replaced)
     {
         replaced    = true;
         description = WMISys.GetString(base.GetDescription());
     }
     return(base.GetDescription());
 }