private string GetCpuDataText(InfoTypeId id) { if (id == InfoTypeId.INFO_CPU_TOTAL || id == InfoTypeId.INFO_CPU_REMAIN || id >= InfoTypeId.INFO_CPUEACH_START) { switch (id) { case InfoTypeId.INFO_CPU_REMAIN: return("Available"); case InfoTypeId.INFO_CPU_TOTAL: return("Total"); default: if (id >= InfoTypeId.INFO_CPUEACH_START) { string[] instance_names = MeasureCpuEach.GetInstanceNames(); return(instance_names[(int)id - (int)InfoTypeId.INFO_CPUEACH_START]); } return(null); } } else { return(null); } }
private string GetMemDataText(InfoTypeId id) { if (id == InfoTypeId.INFO_MEM_TOTAL) { return("Total"); } else { return(null); } }
private void UpdateDisplayLayout() { MainPanel.Background = new SolidColorBrush(Setting.param.BackColor); timer_count_max = Setting.param.GetMeterUpdatePerInfo(); for (int i = 0; i < MAX_METER_NUM; i++) { MeasureObj obj; InfoTypeId id = Setting.param.GetInfoTypeAt(i); switch (id) { case InfoTypeId.INFO_CPU_TOTAL: obj = new MeasureCpuTotal(false); break; case InfoTypeId.INFO_CPU_REMAIN: obj = new MeasureCpuTotal(true); break; case InfoTypeId.INFO_MEM_TOTAL: obj = new MeasureMemory(); break; default: if (id >= InfoTypeId.INFO_CPUEACH_START) { obj = new MeasureCpuEach((int)id - (int)InfoTypeId.INFO_CPUEACH_START); break; } else { throw new NotImplementedException(); } } meter_controls[i] = new MeterControl() { Meter = meters[i], MeasureObj = obj, MaxTimeIndex = timer_count_max }; } if (timer != null) { timer.Interval = TimeSpan.FromMilliseconds(Setting.param.GetUpdateInterval()); } SetNumRows(Setting.param.NumberOfRows); for (int i = 0; i < Setting.param.NumberOfRows; i++) { labels[i].Content = GetTitleText(Setting.param.GetInfoTypeAt(2 * i), Setting.param.GetInfoTypeAt(2 * i + 1)); } }
private string GetTitleText(InfoTypeId id_left, InfoTypeId id_right) { string cpu_left = GetCpuDataText(id_left); string cpu_right = GetCpuDataText(id_right); if (cpu_left != null && cpu_right != null) { return("CPU " + cpu_left + " / " + cpu_right); } string mem_left = GetMemDataText(id_left); string mem_right = GetMemDataText(id_right); if (mem_left != null && mem_right != null) { return("MEM " + mem_left + " / " + mem_right); } if (cpu_left != null || cpu_right != null) { if (cpu_left != null) { cpu_left = "CPU " + cpu_left; } if (cpu_right != null) { cpu_right = "CPU " + cpu_right; } } if (mem_left != null || mem_right != null) { if (mem_left != null) { mem_left = "MEM " + mem_left; } if (mem_right != null) { mem_right = "MEM " + mem_right; } } if (cpu_left == null) { return(mem_left + " / " + cpu_right); } else { return(cpu_left + " / " + mem_right); } }