public GpusPanel() { InitializeComponent(); BackColor = ThemeColors.WindowContentBackgroundDarkTheme; ForeColor = ThemeColors.WindowContentForegroundDarkTheme; //Jus Some Color Games ObjectListGpus.BackColor = BackColor; ObjectListGpus.ForeColor = ForeColor; ObjectListGpus.SelectedBackColor = ThemeColors.UnfocusedSelectedBackgroundColor; ObjectListGpus.UnfocusedSelectedBackColor = ThemeColors.UnfocusedSelectedBackgroundColor; ObjectListGpus.UnfocusedSelectedForeColor = ObjectListGpus.ForeColor; //Setting ObjectListView Aspect Handlers ColumnColor.AspectToStringConverter = (obj) => { return(" "); }; ColumnColor.RendererDelegate = ColorRender; ColumnName.AspectGetter = GpuNameGetter; ColumnName.AspectPutter = delegate(object gpu, object newValue) { GpuData gData = gpu as GpuData; gData.NickName = newValue.ToString(); GpuRenamed?.Invoke(this, new EventArgs <int>(gData.Index)); }; //Wiring Events ObjectListGpus.ItemDrag += ObjectListGpus_ItemDrag; ObjectListGpus.GiveFeedback += ObjectListGpus_GiveFeedback; ObjectListGpus.SelectionChanged += ObjectListGpus_SelectionChanged; ObjectListGpus.MouseClick += ObjectListGpus_MouseClick; }
public GpuDetailPanel() { InitializeComponent(); BackColor = ThemeColors.WindowContentBackgroundDarkTheme; ForeColor = ThemeColors.WindowContentForegroundDarkTheme; //Jus Some Color Games ObjectListGpus.BackColor = BackColor; ObjectListGpus.ForeColor = ForeColor; ObjectListGpus.SelectedBackColor = ThemeColors.UnfocusedSelectedBackgroundColor; ObjectListGpus.UnfocusedSelectedBackColor = ThemeColors.UnfocusedSelectedBackgroundColor; ObjectListGpus.UnfocusedSelectedForeColor = ObjectListGpus.ForeColor; //Setting ObjectListView Aspect Handlers ColumnColor.AspectToStringConverter = (obj) => { return(" "); }; ColumnColor.RendererDelegate = ColorRender; ColumnBrand.ImageGetter = (obj) => { return((obj as GpuData).Manufacturer.ToString().ToLower() + "_full.png"); }; ColumnName.AspectPutter = delegate(object gpu, object newValue) { GpuData gData = gpu as GpuData; gData.NickName = newValue.ToString(); GpuRenamed?.Invoke(this, new EventArgs <int>(gData.Index)); }; //AspectGetter for Nullable Fields. It shows "N/A" instead of just being empty ColumnCClock.AspectToStringConverter = NullFieldAspectGetter; ColumnMClock.AspectToStringConverter = NullFieldAspectGetter; ColumnMvddc.AspectToStringConverter = NullFieldAspectGetter; ColumnCvddc.AspectToStringConverter = NullFieldAspectGetter; ColumnPowLim.AspectToStringConverter = NullFieldAspectGetter; ColumnTT.AspectToStringConverter = NullFieldAspectGetter; //AspectGetter for fields which are calculated from the data ColumnAvgTemp.AspectGetter = (obj) => { return(string.Format("{0:0.00}", (obj as GpuData).AvergaeTemperature)); }; ColumnAvgHash.AspectGetter = (obj) => { return(string.Format("{0:0.00}", (obj as GpuData).AvergaeHashRate)); }; ColumnSdHash.AspectGetter = (obj) => { return(string.Format("{0:0.00}", (obj as GpuData).StdDevHashRate)); }; ColumnAvgFan.AspectGetter = (obj) => { return(string.Format("{0:0.00}", (obj as GpuData).AvergaeFanSpeed)); }; SetColumnHeaderStyles(); }
private void LoadGpuNames(string gpusFileName) { /*string saveDirectory = Path.GetDirectoryName(currentFile); * string gpusFileName = Path.Combine(saveDirectory, Globals.GpuNamesFileName);*/ using (StreamReader sr = new StreamReader(gpusFileName)) { int numGpus = 0; if (!int.TryParse(sr.ReadLine(), out numGpus)) { return; } if (numGpus != Globals.GPUs.Count) { MessageBox.Show("Number of GPUs in the log file do not match the number of GPUs in the GPU Names file. GPU names are ignored.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } int gpuId; string pciPort; string orgName; string nickname; string[] dataParts; for (int i = 0; i < Globals.GPUs.Count; i++) { dataParts = sr.ReadLine().Split('\t'); if (dataParts.Length != 4 || !int.TryParse(dataParts[0], out gpuId)) { MessageBox.Show("GPU Names file seems to be corrupt. GPU names are ignored.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } pciPort = dataParts[1]; orgName = dataParts[2]; nickname = dataParts[3]; if (gpuId == Globals.GPUs[i].Index && pciPort == Globals.GPUs[i].PciePort && orgName == Globals.GPUs[i].Name) { Globals.GPUs[i].NickName = nickname; } else { MessageBox.Show("GPU{0] does not match the information dtored in GPU Names file. GPU Names are ignored.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); foreach (GpuData gpu in Globals.GPUs) { gpu.NickName = string.Empty; } return; } } sr.Close(); } foreach (GpuData gpu in Globals.GPUs) { GpuRenamed?.Invoke(this, new EventArgs <int>(gpu.Index)); } }