Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Threading;
- using System.Management;
- using System.Diagnostics;
- namespace Techne
- {
- public partial class Form1 : Form
- {
- public static bool techneHome;
- public static bool cpuMenu;
- public static bool gpuMenu;
- public static bool ramMenu;
- public static int cpuSpeedLoop;
- public static int cpuClockSpeed;
- public static decimal cpuClockSpeedNew;
- public static int lvl2CacheSize;
- public static int lvl2CacheSpeed;
- public static int lvl3CacheSize;
- public static int lvl3CacheSpeed;
- //Techne Website Homepage on startup
- public static string techneHomeWebsite = "http://brandonspendlove.wix.com/technecomputers";
- //CPU Information (Processor)
- ManagementObjectSearcher cpuInfo =
- new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
- public PerformanceCounter cpuCounter;
- public PerformanceCounter cpuPerf; // = new PerformanceCounter("Processor Information","% of Maximum Frequency","_Total");
- public PerformanceCounter cpuFreq;
- public PerformanceCounter cpuIdleTime;
- public Form1()
- {
- InitializeComponent();
- webBrowser1.Navigate(techneHomeWebsite);
- textBox15.Text = techneHomeWebsite;
- techneHome = true;
- //Hide Controls that aren't on the HOMEPAGE
- #region Hide Controls that don't appear on HOMEPAGE
- label1.Hide();
- textBox1.Hide();
- label2.Hide();
- textBox2.Hide();
- label3.Hide();
- textBox3.Hide();
- label4.Hide();
- textBox4.Hide();
- label5.Hide();
- textBox5.Hide();
- //L2 & 3 Cache ammount and speed
- label6.Hide();
- label7.Hide();
- label8.Hide();
- label9.Hide();
- textBox6.Hide();
- textBox7.Hide();
- textBox8.Hide();
- textBox9.Hide();
- //Help Button
- button5.Hide();
- // CPU Usage
- label10.Hide();
- textBox10.Hide();
- // Architecture
- label11.Hide();
- textBox11.Hide();
- // CPU Performance
- label12.Hide();
- textBox12.Hide();
- // CPU Current Speed
- label13.Hide();
- textBox13.Hide();
- // CPU Idle Time
- label14.Hide();
- textBox14.Hide();
- #endregion
- //****************************************//
- //Boolean Values for Application to know which page the user has selected....//
- if (techneHome == true)
- {
- cpuMenu = false;
- gpuMenu = false;
- ramMenu = false;
- }
- if (cpuMenu == true)
- {
- techneHome = false;
- gpuMenu = false;
- ramMenu = false;
- }
- if (gpuMenu == true)
- {
- techneHome = false;
- cpuMenu = false;
- ramMenu = false;
- }
- if (ramMenu == true)
- {
- techneHome = false;
- cpuMenu = false;
- gpuMenu = false;
- }
- //*************************************************************************//
- //CPU Loop information for usage
- TestSetup();
- InitialiseCPUCounter();
- InitCpuFreq();
- InitCpuIdle();
- //*****************************//
- //**********CPU Counters Custom********//
- //*************************************//
- //CPU Information attach to boxes.............//
- #region CPU Menu Page Information and Attaching
- foreach (ManagementObject mo in cpuInfo.Get())
- {
- // CPU Model Name
- textBox1.AppendText(string.Format("{0}", (string)(mo["Name"])));
- // CPU Clock Speed converting to Ghz
- cpuClockSpeed = Convert.ToInt32(mo["MaxClockSpeed"]);
- cpuClockSpeedNew = (decimal)cpuClockSpeed / 1000;
- textBox2.AppendText(cpuClockSpeedNew.ToString() + "Ghz");
- // Number of Cores on CPU
- textBox3.AppendText(string.Format("{0}", mo["NumberOfCores"]).ToString());
- // Architecture of CPU
- textBox4.AppendText(string.Format("{0}", (ushort)mo["Architecture"]));
- // Number of Threads on CPU
- textBox5.AppendText(string.Format("{0}", mo["NumberOfLogicalProcessors"]).ToString());
- //L2 Cache Size and Speed
- lvl2CacheSize = Convert.ToInt32(mo["L2CacheSize"]);
- lvl2CacheSize = (lvl2CacheSize / 1000);
- textBox6.AppendText(lvl2CacheSize.ToString() + " MB");
- lvl2CacheSpeed = Convert.ToInt32(mo["L2CacheSpeed"]);
- lvl2CacheSpeed = (lvl2CacheSpeed / 1000);
- textBox7.AppendText(lvl2CacheSpeed.ToString() + " MB");
- //********************************************************//
- //L3 Cache Size and Speed
- lvl3CacheSize = Convert.ToInt32(mo["L3CacheSize"]);
- lvl3CacheSize = (lvl3CacheSize / 1000);
- textBox8.AppendText(lvl3CacheSize.ToString() + " MB");
- lvl3CacheSpeed = Convert.ToInt32(mo["L3CacheSpeed"]);
- lvl3CacheSpeed = (lvl3CacheSpeed / 1000);
- textBox9.AppendText(lvl3CacheSpeed.ToString() + " MB");
- if (textBox6.Text == "0 MB")
- {
- textBox6.Clear();
- textBox6.AppendText("Error");
- }
- if (textBox7.Text == "0 MB" )
- {
- textBox7.Clear();
- textBox7.AppendText("Error");
- }
- if (textBox8.Text == "0 MB")
- {
- textBox8.Clear();
- textBox8.AppendText("Error");
- }
- if (textBox9.Text == "0 MB")
- {
- textBox9.Clear();
- textBox9.AppendText("Error");
- }
- //***************************************************//
- //Status
- textBox11.AppendText(string.Format("{0}", (ushort)mo["CpuStatus"]));
- }
- #endregion
- //*******************************************//
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- }
- //Web Browser on HOMEPAGE
- private void NavigateToPage()
- {
- toolStripStatusLabel1.Text = "Navigation Started";
- button6.Enabled = false;
- textBox15.Enabled = false;
- webBrowser1.Navigate(textBox15.Text);
- }
- //Load page buttons (Different pages, HOMEPAGE, CPU, GPU and RAM)**********************************//
- #region Menu Buttons
- //Techne Menu Page............................//
- #region Techne Homepage Button
- private void button1_Click(object sender, EventArgs e)
- {
- techneHome = true;
- //CPU
- label1.Hide();
- textBox1.Hide();
- label2.Hide();
- textBox2.Hide();
- label3.Hide();
- textBox3.Hide();
- label4.Hide();
- textBox4.Hide();
- label5.Hide();
- textBox5.Hide();
- //Help Button on CPU page
- button5.Hide();
- //L2 & 3 Cache ammount and speed
- label6.Hide();
- label7.Hide();
- label8.Hide();
- label9.Hide();
- textBox6.Hide();
- textBox7.Hide();
- textBox8.Hide();
- textBox9.Hide();
- //CPU Usage
- label10.Hide();
- textBox10.Hide();
- //Status
- label11.Hide();
- textBox11.Hide();
- // CPU Performance
- label12.Hide();
- textBox12.Hide();
- // CPU Current Speed
- label13.Hide();
- textBox13.Hide();
- // CPU Idle Time
- label14.Hide();
- textBox14.Hide();
- // Web Browser...
- webBrowser1.Show();
- textBox15.Show();
- button6.Show();
- statusStrip1.Show();
- }
- #endregion
- //*******************************************//
- //CPU Menu page.............................//
- #region CPU Menu Button
- //CPU page button
- private void button2_Click(object sender, EventArgs e)
- {
- cpuMenu = true;
- //CPU
- label1.Show();
- textBox1.Show();
- label2.Show();
- textBox2.Show();
- label3.Show();
- textBox3.Show();
- label4.Show();
- textBox4.Show();
- label5.Show();
- textBox5.Show();
- //Help Button
- button5.Show();
- //L2 & 3 Cache ammount and speed
- label6.Show();
- label7.Show();
- label8.Show();
- label9.Show();
- textBox6.Show();
- textBox7.Show();
- textBox8.Show();
- textBox9.Show();
- //CPU Usage
- label10.Show();
- textBox10.Show();
- //Status
- label11.Show();
- textBox11.Show();
- // CPU Performance
- label12.Show();
- textBox12.Show();
- // CPU Current Speed
- label13.Show();
- textBox13.Show();
- // CPU Idle Time
- label14.Show();
- textBox14.Show();
- // Web Browser...
- webBrowser1.Hide();
- textBox15.Hide();
- button6.Hide();
- statusStrip1.Hide();
- }
- #endregion
- //*****************************************//
- //GPU Menu Page.............................//
- #region GPU Menu Button
- //GPU Page Button*********************************************************************************//
- private void button3_Click(object sender, EventArgs e)
- {
- gpuMenu = true;
- //CPU
- label1.Hide();
- textBox1.Hide();
- label2.Hide();
- textBox2.Hide();
- label3.Hide();
- textBox3.Hide();
- label4.Hide();
- textBox4.Hide();
- label5.Hide();
- textBox5.Hide();
- //L2 & 3 Cache ammount and speed
- label6.Hide();
- label7.Hide();
- label8.Hide();
- label9.Hide();
- textBox6.Hide();
- textBox7.Hide();
- textBox8.Hide();
- textBox9.Hide();
- //Help Button
- button5.Hide();
- //CPU Usage
- label10.Hide();
- textBox10.Hide();
- //Status
- label11.Hide();
- textBox11.Hide();
- // CPU Performance
- label12.Hide();
- textBox12.Hide();
- // CPU Current Speed
- label13.Hide();
- textBox13.Hide();
- // CPU Idle Time
- label14.Hide();
- textBox14.Hide();
- // Web Browser...
- webBrowser1.Hide();
- textBox15.Hide();
- button6.Hide();
- statusStrip1.Hide();
- }
- #endregion
- //*******************************************//
- #endregion
- private void label1_Click(object sender, EventArgs e)
- {
- }
- private void textBox5_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox7_TextChanged(object sender, EventArgs e)
- {
- }
- private void button6_Click(object sender, EventArgs e)
- {
- }
- private void textBox10_TextChanged(object sender, EventArgs e)
- {
- }
- // CPU Timers for refreshing the usage etc... //
- //*******************************************//
- //CPU Usage
- private void InitialiseCPUCounter()
- {
- Thread.Sleep(100);
- cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- this.textBox10.Text = "" +Convert.ToInt32(cpuCounter.NextValue()).ToString() +"%";
- }
- //CPU Frequency (Current Speed)
- private void InitCpuFreq()
- {
- Thread.Sleep(100);
- cpuFreq = new PerformanceCounter("Processor Information", "Processor Frequency", "_Total");
- }
- private void timer2_Tick(object sender, EventArgs e)
- {
- this.textBox13.Text = "" + Convert.ToInt32(cpuFreq.NextValue()).ToString() + " - Mhz";
- }
- //CPU Performance
- private void TestSetup()
- {
- Thread.Sleep(100);
- cpuPerf = new PerformanceCounter("Processor Information", "% Processor Performance", "_Total");
- //cpuTest.CategoryName = "Processor Performance";
- //cpuTest.CounterName = "Processor Frequency";
- // cpuTest.InstanceName = "PPM_Processor_0";
- }
- private void timer3_Tick(object sender, EventArgs e)
- {
- this.textBox12.Text = "" + Convert.ToInt32(cpuPerf.NextValue()).ToString() +"%";
- }
- // Idle Time....
- private void InitCpuIdle()
- {
- Thread.Sleep(100);
- cpuIdleTime = new PerformanceCounter("Processor Information","% Idle Time","_Total");
- }
- private void timer4_Tick(object sender, EventArgs e)
- {
- this.textBox14.Text = "" + Convert.ToInt32(cpuIdleTime.NextValue()).ToString() + "%";
- }
- //*******************************************************//
- private void label10_Click(object sender, EventArgs e)
- {
- }
- private void textBox11_TextChanged(object sender, EventArgs e)
- {
- }
- private void label11_Click(object sender, EventArgs e)
- {
- }
- private void textBox11_TextChanged_1(object sender, EventArgs e)
- {
- }
- // Help form appear...
- private void button5_Click(object sender, EventArgs e)
- {
- Form2 form2 = new Form2();
- form2.Show();
- }
- private void textBox12_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox12_TextChanged_1(object sender, EventArgs e)
- {
- }
- private void textBox13_TextChanged(object sender, EventArgs e)
- {
- }
- private void textBox10_TextChanged_1(object sender, EventArgs e)
- {
- }
- private void label12_Click(object sender, EventArgs e)
- {
- }
- private void textBox13_TextChanged_1(object sender, EventArgs e)
- {
- }
- private void textBox14_TextChanged(object sender, EventArgs e)
- {
- }
- private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
- {
- button6.Enabled = true;
- textBox15.Enabled = true;
- toolStripStatusLabel1.Text = "Navigation Complete";
- }
- private void textBox15_TextChanged(object sender, EventArgs e)
- {
- }
- private void button6_Click_1(object sender, EventArgs e)
- {
- NavigateToPage();
- }
- private void statusStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
- {
- }
- // Webbrowser Keypress (HOMEPAGE)
- private void textBox15_KeyPress(object sender, KeyPressEventArgs e)
- {
- if (e.KeyChar == (char)ConsoleKey.Enter)
- {
- NavigateToPage();
- }
- }
- private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
- {
- if (e.CurrentProgress > 0 && e.MaximumProgress > 0)
- {
- toolStripProgressBar1.ProgressBar.Value = (int)(e.CurrentProgress * 100 / e.MaximumProgress);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment