示例#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));
            }
        }
示例#2
0
        private void UpdateChildren(ArrayList stDialog)
        {
            try
            {
                Node[]    children   = GetNodeSite().GetChildNodes();
                ArrayList stChildren = new ArrayList();

                //First pass: put existing children into string table: strChildren
                //also, remove children that have been deleted from the list in the dialog
                for (int i = 0; i < children.Length; i++)
                {
                    if (children[i] is WMIClassNode)
                    {
                        WMIClassNode wmiClass = (WMIClassNode)children[i];
                        if (!stDialog.Contains(wmiClass.pathNoServer))
                        {
                            //remove child
                            children[i].GetNodeSite().Remove();
                        }
                        else
                        {
                            stChildren.Add(wmiClass.pathNoServer);
                        }
                    }
                }
                String[] arDialog = new String[stDialog.Count];
                stDialog.CopyTo(arDialog, 0);

                //Second pass, see if we need to add any children
                for (int i = 0; i < arDialog.Length; i++)
                {
                    if (!stChildren.Contains(arDialog[i]))
                    {
                        //add the node
                        WMIClassNode newChild = new WMIClassNode("\\\\" + GetNodeSite().GetMachineName() + "\\" + arDialog[i],
                                                                 this.ConnectAs, this.Password);
                        GetNodeSite().AddChild(newChild);
                    }
                }
            }

            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
示例#3
0
        //
        // METHODS
        //

        // <doc>
        // <desc>
        //     Create <Add Classes> node under this node.
        // </desc>
        // </doc>
        public override Node[] CreateChildren()
        {
            //TODO: if connectAs and password are specified and this is a local server,
            //you cannot connect to WMI.  Offer an option to connect as a current user
            //instead. If rejected, make this node an error node.

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

            if (children == null || children.Length == 0)
            {
                children = new Node[DefaultClasses.Length + 1];

                int i, k;
                for (i = 0, k = 0; i < DefaultClasses.Length; i++)
                {
                    try
                    {
                        children[k] = new WMIClassNode(WmiHelper.MakeClassPath(GetNodeSite().GetMachineName(),
                                                                               DefaultNS, DefaultClasses[i]),
                                                       this.ConnectAs, this.Password);
                    }
                    catch (Exception)
                    {
                        //children[k] = new ErrorNode(new ErrorComponent(exc));
                        continue;                               //k wouldn't get increased
                    }

                    k++;
                }
                children[k] = GetNewChildNode();

                Node[] children2 = new Node[k + 1];
                Array.Copy(children, children2, k + 1);
                return(children2);
            }
            return(children);
        }