Exemplo n.º 1
0
        //-------------------------------------------------------------------------
        // Initializes the EventQueryCondition object, to create a pointer
        // back to the parent WMIScripter form.
        //-------------------------------------------------------------------------
        public QueryConditionForm(QueryControl2 parent)
        {
            InitializeComponent();
            this.StoredValue = "";

            this.OperatorBox.Items.Add("=");
            this.OperatorBox.Items.Add("<>");
            this.OperatorBox.Items.Add(">");
            this.OperatorBox.Items.Add("<");
            this.OperatorBox.Items.Add("ISA");

            this.Q_Info = parent;

            this.PropertyList.DrawMode = DrawMode.OwnerDrawFixed;
            this.PropertyList.DrawItem += new DrawItemEventHandler(this.PropertyList_DrawItem);

            this.ValueList.DrawMode = DrawMode.OwnerDrawFixed;
            this.ValueList.DrawItem += new DrawItemEventHandler(this.ValueList_DrawItem);

            try
            {
                ObjectGetOptions op = new ObjectGetOptions(null, System.TimeSpan.MaxValue, true);
                ManagementClass mc = new ManagementClass(this.Q_Info.GetNamespaceName(),
                    this.Q_Info.GetClassName(), op);
                mc.Options.UseAmendedQualifiers = true;

                foreach (PropertyData property in mc.Properties)
                {
                    if (property.IsArray)
                    {
                        // Don't add it to the list.
                    }
                    else
                    {
                        this.PropertyList.Items.Add(property.Name);
                    }
                }

                if (this.PropertyList.Items.Count > 0)
                {
                    this.PropertyList.Text = this.PropertyList.Items[0].ToString();
                }

            }
            catch (ManagementException)
            {
                // Invalid Query, the class or namespace might be blank.  Do nothing.
            }
        }
Exemplo n.º 2
0
        //-------------------------------------------------------------------------
        // Default constructor for the WMIScripter form.
        //
        //-------------------------------------------------------------------------
        public WMIScripter()
        {
            // Generates the start-up screen.
            StartupScreenForm.ShowStartupScreen();

            InitializeComponent();

            // Creates the window for the target computer information.
            this.TargetWindow = new TargetComputerWindow(this);
            this.TargetWindow.Visible = false;

            this.NamespaceList = new ArrayList();
            this.AddNamespacesToListRecursive("root");
            this.NamespaceList.Sort();

            this.QueryCtrl = new QueryControl2(this);
            this.QueryCtrl.AddNamespaces(this.NamespaceList);
            this.QueryCtrl.SetNamespace("root\\cimv2");

            this.EventCtrl = new EventControl2(this);
            this.EventCtrl.AddNamespaces(this.NamespaceList);

            this.MethodCtrl = new MethodControl2(this);
            this.MethodCtrl.AddNamespaces(this.NamespaceList);

            this.ExploreWmiCtrl = new ExploreWmiControl(this);
            this.ExploreWmiCtrl.AddNamespaces(this.NamespaceList);

            this.searchForm = new SearchForm2(this);
            this.searchForm.AddNamespaces(this.NamespaceList);
            this.searchForm.Visible = false;

            this.Controls.Add(this.QueryCtrl);
            this.Controls[0].Dock = DockStyle.Fill;
            this.Controls.Add(this.MethodCtrl);
            this.Controls[1].Dock = DockStyle.Fill;
            this.Controls.Add(this.EventCtrl);
            this.Controls[2].Dock = DockStyle.Fill;
            this.Controls.Add(this.ExploreWmiCtrl);
            this.Controls[3].Dock = DockStyle.Fill;

            this.Controls["QueryControl2"].Visible = true;
            this.Controls["MethodControl2"].Visible = false;
            this.Controls["EventControl2"].Visible = false;
            this.Controls["ExploreWmiControl"].Visible = false;
            this.QueryMenuItem.Checked = true;

            this.selectedLanguage = VBSCRIPT;

            StartupScreenForm.CloseForm();
        }