//private void toolStripMenuItemEnable_Click(object sender, EventArgs e) { // ComputeDeviceEnabledOption G = listViewDevices.FocusedItem.Tag as ComputeDeviceEnabledOption; // var isEnabled = !G.IsEnabled; // G.IsEnabled = isEnabled; // if (AutoSaveChange) { // G.SaveOption(); // } // if (SaveToGeneralConfig) { // ConfigManager.Instance.GeneralConfig.Commit(); // } // var lvi = listViewDevices.FocusedItem as ListViewItem; // if (lvi != null) _listItemCheckColorSetter.LviSetColor(lvi); // if (_algorithmsListView != null) _algorithmsListView.RepaintStatus(G.IsEnabled, G.CDevice.UUID); // if (BenchmarkCalculation != null) _benchmarkCalculation.CalcBenchmarkDevicesAlgorithmQueue(); //} private void toolStripMenuItemCopySettings_Click(object sender, EventArgs e) { ComputeDeviceEnabledOption G = listViewDevices.FocusedItem.Tag as ComputeDeviceEnabledOption; ToolStripMenuItem item = sender as ToolStripMenuItem; if (item != null) { var uuid = item.Tag as string; if (uuid != null) { var copyBenchCDev = ComputeDevice.GetDeviceWithUUID(uuid); G.CDevice.BenchmarkCopyUUID = uuid; var result = MessageBox.Show( String.Format( International.GetText("DeviceListView_ContextMenu_CopySettings_Confirm_Dialog_Msg"), copyBenchCDev.GetFullName(), G.CDevice.GetFullName()), International.GetText("DeviceListView_ContextMenu_CopySettings_Confirm_Dialog_Title"), MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { // just copy G.CDevice.CopyBenchmarkSettingsFrom(copyBenchCDev); if (_algorithmsListView != null) { _algorithmsListView.RepaintStatus(G.IsEnabled, G.CDevice.UUID); } } } } }
private void listViewDevicesItemChecked(object sender, ItemCheckedEventArgs e) { ComputeDeviceEnabledOption G = e.Item.Tag as ComputeDeviceEnabledOption; G.IsEnabled = e.Item.Checked; if (AutoSaveChange) { G.SaveOption(); } if (SaveToGeneralConfig) { ConfigManager.Instance.GeneralConfig.Commit(); } var lvi = e.Item as ListViewItem; if (lvi != null) { _listItemCheckColorSetter.LviSetColor(lvi); } if (_algorithmsListView != null) { _algorithmsListView.RepaintStatus(G.IsEnabled, G.CDevice.UUID); } if (BenchmarkCalculation != null) { BenchmarkCalculation.CalcBenchmarkDevicesAlgorithmQueue(); } }
public void SetComputeDevices(List <ComputeDevice> computeDevices) { // to not run callbacks when setting new bool tmp_AutoSaveChange = AutoSaveChange; bool tmp_SaveToGeneralConfig = SaveToGeneralConfig; AutoSaveChange = false; SaveToGeneralConfig = false; listViewDevices.BeginUpdate(); listViewDevices.Items.Clear(); // set devices foreach (var computeDevice in computeDevices) { ListViewItem lvi = new ListViewItem(); //lvi.SubItems.Add(computeDevice.Name); lvi.Checked = computeDevice.Enabled || SetAllEnabled; lvi.Text = computeDevice.GetFullName(); ComputeDeviceEnabledOption newTag = new ComputeDeviceEnabledOption() { IsEnabled = computeDevice.Enabled || SetAllEnabled, CDevice = computeDevice }; computeDevice.ComputeDeviceEnabledOption = newTag; Options.Add(newTag); lvi.Tag = newTag; listViewDevices.Items.Add(lvi); _listItemCheckColorSetter.LviSetColor(lvi); } listViewDevices.EndUpdate(); listViewDevices.Invalidate(true); // reset properties AutoSaveChange = tmp_AutoSaveChange; SaveToGeneralConfig = tmp_SaveToGeneralConfig; }
private void listViewDevices_MouseClick(object sender, MouseEventArgs e) { if (IsInBenchmark) { return; } if (IsMining) { return; } if (e.Button == MouseButtons.Right) { if (listViewDevices.FocusedItem.Bounds.Contains(e.Location) == true) { contextMenuStrip1.Items.Clear(); ComputeDeviceEnabledOption G = listViewDevices.FocusedItem.Tag as ComputeDeviceEnabledOption; //if (G.IsEnabled) { // var disableItem = new ToolStripMenuItem(); // disableItem.Text = International.GetText("DeviceListView_ContextMenu_DisableDevice"); // //disableItem.Checked = true; // disableItem.Click += toolStripMenuItemEnable_Click; // contextMenuStrip1.Items.Add(disableItem); //} else { // var disableItem = new ToolStripMenuItem(); // disableItem.Text = International.GetText("DeviceListView_ContextMenu_EnableDevice"); // //disableItem.Checked = false; // disableItem.Click += toolStripMenuItemEnable_Click; // contextMenuStrip1.Items.Add(disableItem); //} if (IsSettingsCopyEnabled) { var sameDevTypes = ComputeDevice.GetSameDevicesTypeAsDeviceWithUUID(G.CDevice.UUID); if (sameDevTypes.Count > 0) { var copyBenchItem = new ToolStripMenuItem(); //copyBenchItem.DropDownItems foreach (var cDev in sameDevTypes) { if (cDev.ComputeDeviceEnabledOption.IsEnabled) { var copyBenchDropDownItem = new ToolStripMenuItem(); copyBenchDropDownItem.Text = cDev.Name; copyBenchDropDownItem.Checked = cDev.UUID == G.CDevice.BenchmarkCopyUUID; copyBenchDropDownItem.Click += toolStripMenuItemCopySettings_Click; copyBenchDropDownItem.Tag = cDev.UUID; copyBenchItem.DropDownItems.Add(copyBenchDropDownItem); } } copyBenchItem.Text = International.GetText("DeviceListView_ContextMenu_CopySettings"); contextMenuStrip1.Items.Add(copyBenchItem); } } contextMenuStrip1.Show(Cursor.Position); } } }
public void LviSetColor(ListViewItem lvi) { ComputeDeviceEnabledOption cdvo = lvi.Tag as ComputeDeviceEnabledOption; if (cdvo != null) { if (cdvo.IsEnabled) { lvi.BackColor = ENABLED_COLOR; } else { lvi.BackColor = DISABLED_COLOR; } } }