Esempio n. 1
0
        /// <summary>
        /// Creates CPU counter
        /// </summary>
        public static SimpleCounter CreateCPUCounter()
        {
            // Créer un compteur par CPU
            System.Diagnostics.PerformanceCounterCategory category = new System.Diagnostics.PerformanceCounterCategory("Processor");
            SimpleCounter        mainCounter = null;
            List <SimpleCounter> counters    = new List <SimpleCounter>();

            foreach (string instance in category.GetInstanceNames().OrderBy(s => s))
            {
                System.Diagnostics.PerformanceCounter pc = new System.Diagnostics.PerformanceCounter("Processor", "% Processor Time", instance, true);

                SimpleCounter counter = new KnownMaxPerformanceCounter(new PerformanceCounter(pc), new StaticPerformanceCounter(100));

                if (instance == "_Total")
                {
                    mainCounter = counter;
                }
                else
                {
                    counters.Add(counter);
                }
            }

            return(new SubPerformanceCounter(mainCounter, counters));
        }
Esempio n. 2
0
        /// <summary>
        /// Creates CPU percentage of max frequency counter
        /// </summary>
        public static SimpleCounter CreateCPUFrequencyCounter()
        {
            // Créer un compteur par CPU
            System.Diagnostics.PerformanceCounterCategory category = new System.Diagnostics.PerformanceCounterCategory("ProcessorPerformance");
            SimpleCounter        mainCounter = null;
            List <SimpleCounter> counters    = new List <SimpleCounter>();

            foreach (string instance in category.GetInstanceNames().OrderBy(s => s))
            {
                System.Diagnostics.PerformanceCounter pc = new System.Diagnostics.PerformanceCounter("ProcessorPerformance", "percentage", instance, true);

                SimpleCounter counter = new KnownMaxPerformanceCounter(new PerformanceCounter(pc), new StaticPerformanceCounter(100));

                counters.Add(counter);
            }

            mainCounter = new SumPerformanceCounter(counters);
            return(new SubPerformanceCounter(mainCounter, counters));
        }
Esempio n. 3
0
		private UserControlCounter AddCounterControl(SimpleCounter counter, Color color, string name, string internalName)
		{
			UserControlCounter userControlCounter = new UserControlCounter();
			userControlCounter.CounterHistory = new CounterHistory(counter);
			userControlCounter.CounterHistory.Counter.Name = internalName;
			userControlCounter.BackColor = System.Drawing.Color.Transparent;
			userControlCounter.BackgroundImageLayout = System.Windows.Forms.ImageLayout.None;
			userControlCounter.Color = System.Drawing.Color.FromArgb(0, color);
			userControlCounter.ImeMode = System.Windows.Forms.ImeMode.Disable;
			userControlCounter.Location = new System.Drawing.Point(0, 21);
			userControlCounter.Margin = new System.Windows.Forms.Padding(0, 0, 1, 1);
			userControlCounter.Name = name;
			userControlCounter.Size = new System.Drawing.Size(40, 20);
			flowLayoutPanel.Controls.Add(userControlCounter);

			// Remonter les actions souris des contrôles à nous-mêmes
			userControlCounter.MouseDown += new MouseEventHandler(Monitor_MouseDown);
			userControlCounter.MouseMove += new MouseEventHandler(Monitor_MouseMove);
			userControlCounter.MouseUp += new MouseEventHandler(Monitor_MouseUp);

			return userControlCounter;
		}
Esempio n. 4
0
 public SubPerformanceCounter(SimpleCounter counter, List<SimpleCounter> subCounters)
 {
     this.counter = counter;
     this.subCounters = subCounters;
 }
Esempio n. 5
0
 public SubPerformanceCounter(SimpleCounter counter, List <SimpleCounter> subCounters)
 {
     this.counter     = counter;
     this.subCounters = subCounters;
 }