コード例 #1
0
        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();

                    var tsi = new ToolStripMenuItem("Rename", null, (o, args) =>
                    {
                        var d = listViewDevices.FocusedItem;

                        var renameForm = new Form_DeviceRename();
                        renameForm.SetCurrentName(d.Text);

                        if (renameForm.ShowDialog() == DialogResult.OK)
                        {
                            d.Text = renameForm.NewName;
                            SettingsUtil.SetNameForDevice(d.Text, (d.Tag as ComputeDevice).UUID);
                            SettingsUtil.SaveSettings();
                        }
                    });

                    contextMenuStrip1.Items.Add(tsi);

                    if (IsSettingsCopyEnabled)
                    {
                        var CDevice = listViewDevices.FocusedItem.Tag as ComputeDevice;

                        var sameDevTypes = ComputeDeviceManager.Avaliable.GetSameDevicesTypeAsDeviceWithUUID(CDevice.UUID);
                        if (sameDevTypes.Count > 0)
                        {
                            var copyBenchItem = new ToolStripMenuItem();
                            //copyBenchItem.DropDownItems
                            foreach (var cDev in sameDevTypes)
                            {
                                if (cDev.Enabled)
                                {
                                    var copyBenchDropDownItem = new ToolStripMenuItem();
                                    copyBenchDropDownItem.Text    = cDev.Name;
                                    copyBenchDropDownItem.Checked = cDev.UUID == 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);
                }
            }
        }