Ejemplo n.º 1
0
        public QueryConditionDialog(ManagementObject mgmtObj, string queryIn)
        {
            serverName = mgmtObj.Path.Server;
            className  = mgmtObj.Path.ClassName;
            nsName     = mgmtObj.Path.NamespacePath;

            queryString = queryIn;

            InitializeComponent();

            gridLabel.Location = new Point(16, 16);
            gridLabel.Text     = "Set query conditions:";
            gridLabel.Size     = new Size(250, 20);

            grid = new WMIObjectGrid(mgmtObj,
                                     new PropertyFilters(true, true),
                                     GridMode.LocalEditMode,
                                     true, false, false, true, false, true, true);

            grid.Location             = new Point(16, 40);
            grid.Size                 = (Size) new Point(468, 160);
            grid.Anchor               = AnchorStyles.Top; //.All;
            grid.PreferredColumnWidth = 90;
            grid.PreferredRowHeight   = 19;
            grid.TabIndex             = 3;
            ((DataTable)grid.DataSource).RowChanging += new DataRowChangeEventHandler(this.GridRowChanging);

            Controls.Add(grid);
        }
        private void OnSelectClass(Object source, EventArgs args)
        {
            try
            {
                StringTable strs = new StringTable(50);

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


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

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

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

                if (grid != null)
                {
                    this.Controls.Remove(grid);
                    grid = null;
                }

                grid = new WMIObjectGrid(WmiHelper.GetClassObject(serverName, NS, ClassName),
                                         PropertyFilters.NoSystem,
                                         GridMode.EditMode,
                                         true, false, false);

                grid.Location             = new Point(16, 70);
                grid.Size                 = (Size) new Point(368, 180);
                grid.Anchor               = AnchorStyles.All;
                grid.PreferredColumnWidth = 90;
                grid.PreferredRowHeight   = 19;
                grid.TabIndex             = 3;
                ((DataTable)grid.DataSource).RowChanging += new DataRowChangeEventHandler(this.GridRowChanging);

                this.Controls.Add(grid);

                QueryText.Text = "SELECT * FROM " + ClassName;
            }
            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
            }
        }
Ejemplo n.º 3
0
        public QueryConditionDialog(string serverIn,
                                    string user,
                                    string pw,
                                    string NS,
                                    string clsName,
                                    string queryIn)
        {
            try
            {
                if (serverIn == string.Empty ||
                    NS == string.Empty ||
                    clsName == string.Empty)
                {
                    throw new ArgumentException();
                }

                serverName  = serverIn;
                connectAs   = user;
                password    = pw;
                className   = clsName;
                nsName      = NS;
                queryString = queryIn;

                InitializeComponent();

                gridLabel.Location = new Point(16, 16);
                gridLabel.Text     = "Set query conditions:";
                gridLabel.Size     = new Size(250, 20);

                grid = new WMIObjectGrid(WmiHelper.GetClassObject(serverName, nsName, className, connectAs, password),
                                         new PropertyFilters(true, true),
                                         GridMode.LocalEditMode,
                                         true, false, false, true, false, true, true);

                grid.Location             = new Point(16, 40);
                grid.Size                 = (Size) new Point(468, 160);
                grid.Anchor               = AnchorStyles.Top; //.All;
                grid.PreferredColumnWidth = 90;
                grid.PreferredRowHeight   = 19;
                grid.TabIndex             = 3;
                ((DataTable)grid.DataSource).RowChanging += new DataRowChangeEventHandler(this.GridRowChanging);

                Controls.Add(grid);
            }

            catch (Exception exc)
            {
                throw (exc);
            }
        }
Ejemplo n.º 4
0
        public ExecuteMethodDialog(ManagementObject mgmtObjIn,
                                   Method methIn,
                                   ManagementObject mgmtClassObjIn)
        {
            try
            {
                if (mgmtObjIn == null || methIn == null)
                {
                    throw (new NullReferenceException());
                }

                mgmtObj      = mgmtObjIn;
                mgmtClassObj = mgmtClassObjIn;
                meth         = methIn;

                this.Text = WMISys.GetString("WMISE_ExecMethodDlg_Title", mgmtObj.Path.ClassName, meth.Name);

                //this is a temp workaround for URT bug 48695: uncomment this later
                //this.AcceptButton = executeBtn;

                this.AutoScaleBaseSize = (Size) new Point(5, 13);
                this.BorderStyle       = FormBorderStyle.FixedDialog;
                int dlgWidth  = 400;
                int dlgHeight = 500;
                this.ClientSize    = (Size) new Point(dlgWidth, dlgHeight);
                this.ShowInTaskbar = false;
                this.MinimizeBox   = false;
                this.MaximizeBox   = false;

                ServerName.Location = new Point(16, 16);
                ServerName.Text     = WMISys.GetString("WMISE_ExecMethodDlg_ServerName", mgmtObj.Path.Server);

                //NamespaceName.Location = new Point();
                //ClassName.Location = new Point();

                if (meth.InParameters == null)
                {
                    NoInParams.Text     = WMISys.GetString("WMISE_ExecMethodDlg_NoInputParams");
                    NoInParams.Location = new Point(16, 40);
                }
                else
                {
                    inParms = meth.InParameters;

                    gridIn = new WMIObjectGrid(inParms,
                                               new PropertyFilters(true, false),
                                               GridMode.EditMode,
                                               false, false, false, false, true, true, true);

                    labelInParms.Location = new Point(16, 40);
                    labelInParms.Text     = WMISys.GetString("WMISE_ExecMethodDlg_InputParameters");

                    gridIn.Location             = new Point(16, 65);
                    gridIn.Size                 = (Size) new Point(367, 140);
                    gridIn.Anchor               = AnchorStyles.Top; //.All;
                    gridIn.PreferredColumnWidth = 109;
                    gridIn.PreferredRowHeight   = 19;
                    gridIn.TabIndex             = 1;
                }

                labelOutParms.Location = new Point(16, 215);
                labelOutParms.Text     = WMISys.GetString("WMISE_ExecMethodDlg_OutputParameters");

                gridOut = new WMIObjectGrid(meth.OutParameters,
                                            new PropertyFilters(true, false),
                                            GridMode.ViewMode,
                                            false, false, false, false, true, true, true);

                gridOut.Location             = new Point(16, 240);
                gridOut.Size                 = (Size) new Point(367, 100);
                gridOut.Anchor               = AnchorStyles.Top; //.All;
                gridOut.PreferredColumnWidth = 109;
                gridOut.PreferredRowHeight   = 19;
                gridOut.TabIndex             = 2;

                descr.Text       = WmiHelper.GetMethodDescription(meth.Name, mgmtClassObj, "", "");
                descr.Location   = new Point(16, 355);
                descr.Size       = (Size) new Point(368, 70);
                descr.Multiline  = true;
                descr.ReadOnly   = true;
                descr.ScrollBars = ScrollBars.Vertical;

                executeBtn.Text     = WMISys.GetString("WMISE_ExecMethodDlg_Execute");
                executeBtn.Location = new Point(225, 440);
                executeBtn.Click   += new EventHandler(this.OnExecute);
                executeBtn.TabIndex = 3;

                cancelBtn.Text         = WMISys.GetString("WMISE_Cancel");
                cancelBtn.Location     = new Point(310, 440);
                cancelBtn.DialogResult = System.Windows.Forms.DialogResult.Cancel;
                cancelBtn.TabIndex     = 4;

                if (meth.InParameters == null)
                {
                    this.Controls.Add(cancelBtn);
                    this.Controls.Add(executeBtn);
                    this.Controls.Add(ServerName);
                    this.Controls.Add(NoInParams);
                    this.Controls.Add(labelOutParms);
                    this.Controls.Add(gridOut);
                    this.Controls.Add(descr);
                }
                else
                {
                    this.Controls.Add(cancelBtn);
                    this.Controls.Add(executeBtn);
                    this.Controls.Add(ServerName);
                    this.Controls.Add(labelInParms);
                    this.Controls.Add(gridIn);
                    this.Controls.Add(labelOutParms);
                    this.Controls.Add(gridOut);
                    this.Controls.Add(descr);
                }
            }

            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
                throw (exc);
            }
        }
Ejemplo n.º 5
0
        public ExecuteMethodDialog(ISWbemObject wbemObjIn,
                                   ISWbemMethod methIn,
                                   ISWbemObject wbemClassObjIn)
        {
            try
            {
                if (wbemObjIn == null || methIn == null)
                {
                    throw (new NullReferenceException());
                }

                wmiObj      = wbemObjIn;
                wmiClassObj = wbemClassObjIn;
                meth        = methIn;

                this.Text = WMISys.GetString("WMISE_ExecMethodDlg_Title", wmiObj.Path_.Class, meth.Name);

                //this is a temp workaround for URT bug 48695: uncomment this later
                //this.AcceptButton = executeBtn;

                this.AutoScaleBaseSize = (Size) new Point(5, 13);
                this.BorderStyle       = FormBorderStyle.FixedSingle;
                int dlgWidth  = 400;
                int dlgHeight = 500;
                this.ClientSize    = (Size) new Point(dlgWidth, dlgHeight);
                this.ShowInTaskbar = false;

                ServerName.Location = new Point(16, 16);
                ServerName.Text     = WMISys.GetString("WMISE_ExecMethodDlg_ServerName", wmiObj.Path_.Server);

                //NamespaceName.Location = new Point();
                //ClassName.Location = new Point();

                if (meth.InParameters == null)
                {
                    NoInParams.Text     = WMISys.GetString("WMISE_ExecMethodDlg_NoInputParams");
                    NoInParams.Location = new Point(16, 40);
                }
                else
                {
                    inParms = meth.InParameters.SpawnInstance_(0);
                    gridIn  = new WMIObjectGrid(inParms,
                                                PropertyFilters.NoSystem,
                                                GridMode.EditMode,
                                                false, false, false);

                    labelInParms.Location = new Point(16, 40);
                    labelInParms.Text     = WMISys.GetString("WMISE_ExecMethodDlg_InputParameters");

                    gridIn.Location             = new Point(16, 65);
                    gridIn.Size                 = (Size) new Point(367, 140);
                    gridIn.Anchor               = AnchorStyles.All;
                    gridIn.PreferredColumnWidth = 109;
                    gridIn.PreferredRowHeight   = 19;
                    gridIn.TabIndex             = 1;
                }

                labelOutParms.Location = new Point(16, 215);
                labelOutParms.Text     = WMISys.GetString("WMISE_ExecMethodDlg_OutputParameters");

                gridOut = new WMIObjectGrid(meth.OutParameters,
                                            PropertyFilters.NoSystem,
                                            GridMode.ViewMode,
                                            false, false, false);

                gridOut.Location             = new Point(16, 240);
                gridOut.Size                 = (Size) new Point(367, 100);
                gridOut.Anchor               = AnchorStyles.All;
                gridOut.PreferredColumnWidth = 109;
                gridOut.PreferredRowHeight   = 19;
                gridOut.TabIndex             = 2;

                descr.Text       = WmiHelper.GetMethodDescription(meth.Name, wmiClassObj);
                descr.Location   = new Point(16, 355);
                descr.Size       = (Size) new Point(368, 70);
                descr.Multiline  = true;
                descr.ReadOnly   = true;
                descr.ScrollBars = ScrollBars.Vertical;

                executeBtn.Text     = WMISys.GetString("WMISE_ExecMethodDlg_Execute");
                executeBtn.Location = new Point(225, 440);
                executeBtn.Click   += new EventHandler(this.OnExecute);
                executeBtn.TabIndex = 3;

                cancelBtn.Text         = WMISys.GetString("WMISE_Cancel");
                cancelBtn.Location     = new Point(310, 440);
                cancelBtn.DialogResult = DialogResult.Cancel;
                cancelBtn.TabIndex     = 4;

                if (meth.InParameters == null)
                {
                    this.Controls.All = new Control[] { cancelBtn,
                                                        executeBtn,
                                                        ServerName,
                                                        NoInParams,
                                                        labelOutParms,
                                                        gridOut,
                                                        descr };
                }
                else
                {
                    this.Controls.All = new Control[] { cancelBtn,
                                                        executeBtn,
                                                        ServerName,
                                                        labelInParms,
                                                        gridIn,
                                                        labelOutParms,
                                                        gridOut,
                                                        descr };
                }
            }

            catch (Exception exc)
            {
                MessageBox.Show(WMISys.GetString("WMISE_Exception", exc.Message, exc.StackTrace));
                throw (exc);
            }
        }