Esempio n. 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());
            }
        }