/// <summary> /// /// </summary> /// <returns></returns> private IDevice GetSelectedDevice(bool showNotSelectedMsg) { IDevice r = null; TreeNode node = this._hardwareTreeView.SelectedNode; if (node is DeviceTreeNode) { DeviceTreeNode deviceNode = (DeviceTreeNode)node; r = deviceNode.Device; } if (r == null && showNotSelectedMsg) { NUnit.UiKit.UserMessage.DisplayFailure(Strings.SelectDeviceFirst); } return(r); }
private void mnuDeviceEdit_Click(object sender, EventArgs e) { IDevice device = GetSelectedDevice(true); if (device != null) { IDeviceUI ui = device.Dpu.DeviceUI; DialogResult dr = ui.Edit(device); if (dr == DialogResult.OK) { device.Dpu.DevicePersister.Update(device); DeviceTreeNode deviceNode = (DeviceTreeNode)this.HardwareTreeView.SelectedNode; deviceNode.RefreshDeviceTreeNode(); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuDeviceAdd_Click(object sender, EventArgs e) { IStation selectedStation = null; selectedStation = this.GetSelectedStation(true); if (selectedStation != null) { frmDeviceType f = new frmDeviceType(); if (f.ShowDialog() == DialogResult.OK) { DeviceType deviceType = f.SelectedDeviceType; IDPU dpu = Soft.DPUs[deviceType]; IDeviceUI deviceUI = GetDeviceUI(deviceType); IDevice newDevice; DialogResult dr = deviceUI.Add(deviceType, selectedStation, out newDevice); if (dr == DialogResult.OK) { selectedStation.Devices.Add(newDevice); newDevice.Station = selectedStation; // // newDevice.Dpu = Soft.DPUs[deviceType]; // persister device // dpu.DevicePersister.Add(newDevice); // task device // dpu.TaskFactory.Create(newDevice); // add device tree node // DeviceTreeNode deviceTreeNode = new DeviceTreeNode(newDevice); this.GetSelectedStationTreeNode().Nodes.Add(deviceTreeNode); } } } }
/// <summary> /// /// </summary> /// <param name="station"></param> public StationTreeNode(IStation station) { this.Station = station; RefreshStationTreeNode(station); // // station.CommuniPortChanged += new EventHandler(station_CommuniPortChanged); // // //this.ImageKey = IconNames.Disconnect; //this.SelectedImageKey = IconNames.Disconnect; SetImageKey(IconNames.Disconnect); station.Tag = this; foreach (IDevice device in station.Devices) { DeviceTreeNode deviceNode = new DeviceTreeNode(device); this.Nodes.Add(deviceNode); } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void t_AfterSelect(object sender, TreeViewEventArgs e) { TreeNode node = e.Node; Model model = null; if (node is DeviceTreeNode) { DeviceTreeNode deviceNode = node as DeviceTreeNode; IDevice device = deviceNode.Device; //this.UCTaskViewer.Device = deviceNode.Device; //this.ViewerWrapper.View(device); model = new DeviceMode(device); } else if (node is StationTreeNode) { StationTreeNode stationNode = node as StationTreeNode; IStation station = stationNode.Station; //this.ViewerWrapper.View(station); model = new StationModel(station); } this.ControllerManager.Act(model); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mnuDeviceDelete_Click(object sender, EventArgs e) { IDevice selected = GetSelectedDevice(true); if (selected != null) { DialogResult dr = NUnit.UiKit.UserMessage.Ask(Strings.SureToDelete); if (dr == DialogResult.Yes) { IStation station = selected.Station; station.Devices.Remove(selected); selected.Dpu.DevicePersister.Delete(selected); DeviceTreeNode deviceNode = (DeviceTreeNode)selected.Tag; deviceNode.Remove(); // // this.HardwareTreeView.SelectedNode = (StationTreeNode)station.Tag; } } }