using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace ServerExplorerExamples
{
	/// <summary>
	/// Summary description for PerfCounterExample.
	/// </summary>
	public class PerfCounterExample : System.Windows.Forms.Form
	{
		private System.Diagnostics.PerformanceCounter performanceCounter1;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public PerfCounterExample()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.performanceCounter1 = new System.Diagnostics.PerformanceCounter();
			this.label1 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).BeginInit();
			this.SuspendLayout();
			// 
			// performanceCounter1
			// 
			this.performanceCounter1.CategoryName = "Memory";
			this.performanceCounter1.CounterName = "Available MBytes";
			this.performanceCounter1.MachineName = "TOSHIBA";
			// 
			// label1
			// 
			this.label1.Location = new System.Drawing.Point(8, 32);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(128, 16);
			this.label1.TabIndex = 0;
			this.label1.Text = "Dostępna pamięć w MB:";
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(136, 32);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(100, 16);
			this.label2.TabIndex = 1;
			// 
			// PerfCounterExample
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(312, 174);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.label1);
			this.Name = "PerfCounterExample";
			this.Text = "PerfCounterExample";
			this.Load += new System.EventHandler(this.PerfCounterExample_Load);
			((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void PerfCounterExample_Load(object sender, System.EventArgs e)
		{
			//Pobranie wartości licznika wydajności
			label2.Text = performanceCounter1.NextValue().ToString();
		
		}
	}
}
