public void DeconstructTest(IOControlCode CtrlCode, FileDevice DeviceType, uint Function, Method Method, FileAccess Access) { var(_DeviceType, _Function, _Method, _Access) = CtrlCode; Assert.AreEqual(DeviceType, _DeviceType); Assert.AreEqual(Function, _Function); Assert.AreEqual(Method, _Method); Assert.AreEqual(Access, _Access); }
private void createButton_Click(object sender, EventArgs e) { byte?id = GetID(); if (!id.HasValue) { MessageBox.Show("Enter an ID for the device to create.", "Create device", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); idTB.Focus(); return; } var devname = nameTB.Text.Trim(); string devtype = typeCB.Text.ToLower(); IODevice newDevice = null; switch (devtype) { case "file": // Need to get file path for this guy. Show special dialog for creating file device. // Let's just use a built-in file browser dialog for now. var fileBrowserDlg = new OpenFileDialog { Title = $"Choose path for file device 0x{id.Value:X} (\"{devname}\")", CheckFileExists = false }; if (fileBrowserDlg.ShowDialog() != DialogResult.OK) { return; } string path = fileBrowserDlg.FileName; try { newDevice = new FileDevice(id.Value, path); } catch (System.IO.IOException ex) { MessageBox.Show(ex.Message, "Error creating file device", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } break; case "console": // No special options needed for this type of device? simply create it newDevice = new ConsoleDevice(id.Value); break; case "graphics": // Not implemented yet. return; //break; default: MessageBox.Show($"\"{typeCB.Text}\" is not a valid device type.", "Create device", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); typeCB.Focus(); return; } if (devname.Length > 0) { newDevice.Name = nameTB.Text; } try { Machine.AddDevice(id.Value, newDevice); } catch (ArgumentException ex) { MessageBox.Show($"Could not add the device to the machine:\n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } AddDeviceToList(newDevice); ((MainForm)Owner).UpdateIODevices(this, null); }
public static IOControlCode CtrlCode(FileDevice DeviceType, uint Function = default, Method Method = default, FileAccess Access = default) => (IOControlCode)CtrlCode((uint)DeviceType, Function, (uint)Method, (uint)Access);
public GetMediaTypes(FileDevice DeviceType, DeviceMediaInfo[] MediaInfo) => (this.DeviceType, MediaInfoCount, this._MediaInfo) = (DeviceType, (uint)(MediaInfo?.Length ?? 0), (MediaInfo?.Length ?? 0) == 0 ? new DeviceMediaInfo[1] : MediaInfo);
public void GetDeviceTypeTest(IOControlCode CtrlCode, FileDevice DeviceType) => Assert.AreEqual(DeviceType, CtrlCode.GetDeviceType());
public void CtrlCodeTest(IOControlCode CtrlCode, FileDevice DeviceType, uint Function, Method Method, FileAccess Access) => Assert.AreEqual(CtrlCode, IOControlCodeExtensions.CtrlCode(DeviceType, Function, Method, Access));