Exemple #1
0
        private void tmrGetStatus_Tick(object sender, EventArgs e)
        {
            lvMain.BeginUpdate();

            try
            {
                foreach (ListViewItem item in lvMain.Items)
                {
                    if (item.Tag is EmulatorChannel)
                    {
                        EmulatorChannel channel = (EmulatorChannel)item.Tag;
                        if (channel.Engine != null && channel.Enabled)
                        {
                            channel.Status = channel.Engine.GetChannelStatus();
                            switch (channel.Status)
                            {
                            case ChannelStatus.Unknown:
                                item.SubItems[5].Text = string.Empty;
                                break;

                            case ChannelStatus.Normal:
                                item.SubItems[5].Text = "Streaming";
                                break;

                            default:
                                item.SubItems[5].Text = channel.Status.ToString();
                                break;
                            }
                            item.SubItems[5].ForeColor = (channel.Status == ChannelStatus.Normal) ? Color.Green : Color.Red;
                        }
                        else
                        {
                            item.SubItems[5].Text = string.Empty;
                        }
                    }
                }

                if (_AppSettings.ShowSystemResourceUsage)
                {
                    tsslCpuUsage.Text    = OsMetrics.GetCpuUsage().ToString() + " %";
                    tsslMemoryUsage.Text = OsMetrics.GetMemoryUsage().ToString() + " %";
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            finally
            {
                lvMain.EndUpdate();
            }
        }
        private void timer1_Tick(object sender, EventArgs e)
        {
            ListViewItem item;

            if (lvMain.Items.Count == 0)
            {
                item = lvMain.Items.Add(DateTime.Now.ToString());
                for (int i = 0; i < 8; i++)
                {
                    item.SubItems.Add(string.Empty);
                }
            }
            else
            {
                item = lvMain.Items[0];
                item.SubItems[0].Text = DateTime.Now.ToString();
            }

            try
            {
                string driveName = OsMetrics.GetSystemPartitionLabel();
                item.SubItems[1].Text = OsMetrics.GetCpuUsage().ToString() + " %";
                item.SubItems[2].Text = OsMetrics.GetMemoryUsage().ToString() + " %";

                double nwUtil = double.NaN;
                if (cmbNwInterfaces.SelectedIndex > 0)
                {
                    nwUtil = OsMetrics.GetNetworkUtilization(cmbNwInterfaces.Text);
                }
                item.SubItems[3].Text = double.IsNaN(nwUtil) ? string.Empty : nwUtil.ToString("0.0") + " %";

                double temperature = HardwareMetrics.GetCpuTemperature();
                item.SubItems[4].Text = (temperature == 0.0) ? string.Empty : temperature.ToString("0.0") + " °C";

                temperature           = HardwareMetrics.GetMainBoardTemperature();
                item.SubItems[5].Text = (temperature == 0.0) ? string.Empty : temperature.ToString("0.0") + " °C";

                temperature           = HardwareMetrics.GetHddTemperature();
                item.SubItems[6].Text = (temperature == 0.0) ? string.Empty : temperature.ToString("0.0") + " °C";

                item.SubItems[7].Text = HardwareMetrics.GetHddUsage().ToString("0.0") + " %";
                item.SubItems[8].Text = (100.0 - OsMetrics.GetDiskUtilization(driveName)).ToString("0.0") + " %";

                TimeSpan uptime = OsMetrics.GetUpTime();
                tsslUptime.Text = uptime.Days.ToString() + " days, " + uptime.Hours.ToString() + " hours, " +
                                  uptime.Minutes.ToString() + " mins, " + uptime.Seconds.ToString() + " secs";
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
        private void FormMain_Load(object sender, EventArgs e)
        {
            try
            {
                cmbNwInterfaces.Items.Clear();
                cmbNwInterfaces.Items.Add("< Disable Network Monitoring >");
                _NicInterfaces = OsMetrics.EnumerateNetworkInterfaces();
                foreach (string nicInterface in _NicInterfaces)
                {
                    cmbNwInterfaces.Items.Add(nicInterface);
                }
                cmbNwInterfaces.SelectedIndex = 0;

                tsslInstalledRam.Text = ((double)OsMetrics.GetInstalledPhysicalMemory() / 1024 / 1024).ToString("0.0") + " GB";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #4
0
 private void btnCopyToClipboard_Click(object sender, EventArgs e)
 {
     try
     {
         StringBuilder sb = new StringBuilder();
         sb.Append(this.labelProductName.Text + Environment.NewLine);
         sb.Append(this.labelVersion.Text + Environment.NewLine);
         sb.Append(this.labelCompanyName.Text + Environment.NewLine);
         sb.Append(this.labelLibVersion.Text + Environment.NewLine);
         sb.Append("Emulator library version: " + typeof(EmulatorChannel).Assembly.GetName().Version.ToString() + Environment.NewLine);
         sb.Append("SystemMetrics library version: " + typeof(OsMetrics).Assembly.GetName().Version.ToString() + Environment.NewLine);
         sb.Append("OS: " + OsMetrics.GetOSVersion() + " (" +
                   (Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit") + ")" + Environment.NewLine);
         sb.Append("DotNet Framework: " + Environment.Version + Environment.NewLine);
         sb.Append("System Resources: CPU - " + Environment.ProcessorCount.ToString() +
                   "-core, Memory: " + (OsMetrics.GetInstalledPhysicalMemory() / 1024).ToString("0") + " MB" + Environment.NewLine);
         Clipboard.Clear();
         Clipboard.SetText(sb.ToString());
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }