コード例 #1
0
		//-------------------------------------------------------------------------
		// Handles the event when the user selects an item in the targetClassList
		// list on the event tab.
		//-------------------------------------------------------------------------
        private void TargetClassList_event_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            this.PropertyList_event.Items.Clear();
            AddTargetClassProperties();

			if(this.PropertyList_event.Items.Count > 0) 
			{
				System.Array.Clear(this.EventConditionArray, 0, this.EventConditionArray.Length);
				this.EventConditionArray = new EventQueryCondition[PropertyList_event.Items.Count];

				for(int i = 0; i < PropertyList_event.Items.Count; i++)
				{
					EventConditionArray[i] = new EventQueryCondition(this);
					EventConditionArray[i].SetParameterName((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[0]);
				
					if(PropertyList_event.Items[i].ToString().StartsWith("TargetClass ISA") ||
						PropertyList_event.Items[i].ToString().StartsWith("PreviousClass ISA") ||
						PropertyList_event.Items[i].ToString().StartsWith("TargetInstance ISA") ||
						PropertyList_event.Items[i].ToString().StartsWith("PreviousInstance ISA") ||
						PropertyList_event.Items[i].ToString().StartsWith("TargetNamespace =") ||
						PropertyList_event.Items[i].ToString().StartsWith("PreviousNamespace ="))
					{
						EventConditionArray[i].ChangeOperator((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[1]);
						EventConditionArray[i].ChangeTextBoxValue((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[2]);
					}
				}	
			}
        }
コード例 #2
0
		//-------------------------------------------------------------------------
		// Handles the event when the user selects an event class property
		// (from the PropertyList_event list) to include in an event query.
		//-------------------------------------------------------------------------
		private void PropertyList_event_SelectedIndexChanged(object sender, System.EventArgs e)
		{	

			for(int i = 0; i < PropertyList_event.Items.Count; i++)
			{
				try
				{

					if(this.PropertyList_event.SelectedIndices.Contains(i) && !EventConditionArray[i].GetOkClicked())
					{
					
						EventConditionArray[i].Visible = true;
						EventConditionArray[i].ChangeText(
                            "Assign a value to the " + EventConditionArray[i].GetParameterName()
							+ " property. The property is of type: " +
							EventConditionArray[i].GetParameterType() + ".");
					}
				}
				catch (System.NullReferenceException nullError)
				{
					// Catches the case if the window was closed.
					EventConditionArray[i] = new EventQueryCondition(this);
					EventConditionArray[i].SetParameterName((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[0]);
					EventConditionArray[i].Visible = true;
					EventConditionArray[i].ChangeText(
						"Assign a value to the " + EventConditionArray[i].GetParameterName()
						+ " property. The property is of type: " +
						EventConditionArray[i].GetParameterType() + ".");
				
					if(PropertyList_event.Items[i].ToString().StartsWith("TargetClass ISA") ||
						PropertyList_event.Items[i].ToString().StartsWith("PreviousClass ISA") ||
						PropertyList_event.Items[i].ToString().StartsWith("TargetInstance ISA") ||
						PropertyList_event.Items[i].ToString().StartsWith("PreviousInstance ISA") ||
						PropertyList_event.Items[i].ToString().StartsWith("TargetNamespace =") ||
						PropertyList_event.Items[i].ToString().StartsWith("PreviousNamespace ="))
					{
						EventConditionArray[i].ChangeOperator((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[1]);
						EventConditionArray[i].ChangeTextBoxValue((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[2]);
					}
				}
			
				if(!this.PropertyList_event.SelectedIndices.Contains(i))
				{
					try
					{
						EventConditionArray[i].Visible = false;
						EventConditionArray[i].SetOkClicked(false);
					}
					catch (System.NullReferenceException nullError)
					{
						// Catches the case if the window was closed.
						EventConditionArray[i] = new EventQueryCondition(this);
						EventConditionArray[i].SetParameterName((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[0]);
						EventConditionArray[i].Visible = false;
						EventConditionArray[i].SetOkClicked(false);

						if(PropertyList_event.Items[i].ToString().StartsWith("TargetClass ISA") ||
							PropertyList_event.Items[i].ToString().StartsWith("PreviousClass ISA") ||
							PropertyList_event.Items[i].ToString().StartsWith("TargetInstance ISA") ||
							PropertyList_event.Items[i].ToString().StartsWith("PreviousInstance ISA") ||
							PropertyList_event.Items[i].ToString().StartsWith("TargetNamespace =") ||
							PropertyList_event.Items[i].ToString().StartsWith("PreviousNamespace ="))
						{
							EventConditionArray[i].ChangeOperator((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[1]);
							EventConditionArray[i].ChangeTextBoxValue((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[2]);
						}
					}
				}
			}

			this.GenerateEventCode();
		}
コード例 #3
0
        //-------------------------------------------------------------------------
        // Handles the event when the class is changed on the event tab.
        //
        //-------------------------------------------------------------------------
        private void ClassList_event_SelectedIndexChanged(object sender, System.EventArgs e)
        {
            this.PropertyList_event.Items.Clear();
            this.PropertyList_event.Text = "";
            this.CodeText_event.Text = "";
            this.PropertyValueLabel.Text = "";
            this.PropertyValueLabel.Visible = false;
            this.TargetClassList_event.Items.Clear();
            this.TargetClassList_event.Text = "";
            this.TargetClassList_event.Visible = false;
            this.PropertyList_event.Items.Clear();


            if(this.ClassList_event.Text.StartsWith("__Class"))
            {
                this.PropertyValueLabel.Text = "TargetClass:";
                this.PropertyValueLabel.Visible = true;
                this.TargetClassList_event.Visible = true;
                
                // Populates the class list on the event page.
                System.Threading.ThreadPool.
                    QueueUserWorkItem(
                    new System.Threading.WaitCallback(
                    this.AddClassesToTargetClassList));
            }
            if(this.ClassList_event.Text.StartsWith("__MethodInvocationEvent"))
            {
                this.PropertyValueLabel.Text = "TargetInstance:";
                this.PropertyValueLabel.Visible = true;
                this.TargetClassList_event.Visible = true;
                
                // Populates the class list on the event page.
                System.Threading.ThreadPool.
                    QueueUserWorkItem(
                    new System.Threading.WaitCallback(
                    this.AddMethodClassesToTargetClassList));
            }
            else if(this.ClassList_event.Text.StartsWith("__Namespace"))
            {
                this.PropertyValueLabel.Text = "TargetNamespace:";
                this.PropertyValueLabel.Visible = true;
                this.TargetClassList_event.Visible = true;				

                // Populates the class list on the event page.
                System.Threading.ThreadPool.
                    QueueUserWorkItem(
                    new System.Threading.WaitCallback(
                    this.AddNamespacesToTargetList));
            }
            else if(this.ClassList_event.Text.StartsWith("__Instance"))
            {
                this.PropertyValueLabel.Text = "TargetInstance:";
                this.PropertyValueLabel.Visible = true;
                this.TargetClassList_event.Visible = true;

                // Populates the class list on the event page.
                System.Threading.ThreadPool.
                    QueueUserWorkItem(
                    new System.Threading.WaitCallback(
                    this.AddClassesToTargetClassList));
            }
            else
            {
	
                AddEventClassProperties();


                if(this.PropertyList_event.Items.Count > 0) 
                {
                    System.Array.Clear(this.EventConditionArray, 0, this.EventConditionArray.Length);
                    this.EventConditionArray = new EventQueryCondition[PropertyList_event.Items.Count];

                    for(int i = 0; i < PropertyList_event.Items.Count; i++)
                    {
                        EventConditionArray[i] = new EventQueryCondition(this);
                        EventConditionArray[i].SetParameterName((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[0]);

                        if(PropertyList_event.Items[i].ToString().StartsWith("TargetClass ISA") ||
                            PropertyList_event.Items[i].ToString().StartsWith("PreviousClass ISA") ||
                            PropertyList_event.Items[i].ToString().StartsWith("TargetInstance ISA") ||
                            PropertyList_event.Items[i].ToString().StartsWith("PreviousInstance ISA") ||
                            PropertyList_event.Items[i].ToString().StartsWith("TargetNamespace =") ||
                            PropertyList_event.Items[i].ToString().StartsWith("PreviousNamespace ="))
                        {
                            EventConditionArray[i].ChangeOperator((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[1]);
                            EventConditionArray[i].ChangeTextBoxValue((PropertyList_event.Items[i].ToString().Split(" ".ToCharArray()))[2]);
                        }	
						
                    }
					
                }
            }

            // Display the link to the class documentation.
            // Note: This link changes if MSDN changes the URL for the WMI SDK documentation.
            if(this.EventLinkLabel.Links.Count > 0)
            {
                this.EventLinkLabel.Links[0].LinkData = "www.msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/" + this.ClassList_event.Text + ".asp";
            }
            else
            {
                this.EventLinkLabel.Links.Add(0, this.EventLinkLabel.Text.Length, "www.msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/" + this.ClassList_event.Text + ".asp");
            }

            // All the event classes in the root\cimv2 namespace are documented.
            if(this.NamespaceList_event.Text.Equals("root\\CIMV2"))
            {   
                this.EventLinkLabel.Visible = true;
            }
            else
            {
                this.EventLinkLabel.Visible = false;
            }

            GenerateEventCode();
        }