Ejemplo n.º 1
0
        private void OnEventReady(object sender,
                                  EventArrivedEventArgs args)
        {
            //output to OutputWindow

            _DTE dteObj = (_DTE)GetNodeSite().GetService(typeof(_DTE));

            if (outputPane == null)
            {
                OutputWindow ouputWindow = (OutputWindow)dteObj.Windows.Item(EnvDTE.Constants.vsWindowKindOutput).Object;
                outputPane = ouputWindow.OutputWindowPanes.Item("{1BD8A850-02D1-11d1-bee7-00a0c913d1f8}");
            }

            dteObj.ExecuteCommand("View.Output", "");

            outputPane.Activate();
            outputPane.OutputString(FormEventString(args.NewEvent) + "\n");

            //also, add a child node
            WMIInstanceNode eventNode = new WMIInstanceNode((ManagementObject)args.NewEvent,
                                                            new ManagementClass(args.NewEvent.ClassPath.Path, null),
                                                            this.connectAs,
                                                            this.password);

            eventNodes.Add(eventNode);

            GetNodeSite().AddChild(eventNode);
        }
Ejemplo n.º 2
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));
            }
        }