/// <summary> Connects a device. </summary> /// <param name="serialNo"> The serial no. </param> private void ConnectDevice(string serialNo) { // unload device if not desired type if (_genericDevice != null) { if (_genericDevice.CoreDevice.DeviceID == serialNo) { return; } DisconnectDevice(); } // create new device IGenericCoreDeviceCLI device = DeviceFactory.CreateDevice(serialNo); GenericDeviceHolder devices = new GenericDeviceHolder(device); _genericDevice = devices[1]; if (_genericDevice == null) { MessageBox.Show("Unknown Device Type"); return; } // connect device try { _genericDevice.CoreDevice.Connect(serialNo); // wait for settings to be initialized _genericDevice.Device.WaitForSettingsInitialized(5000); } catch (DeviceException ex) { MessageBox.Show(ex.Message); return; } // create view via factory // get factory IUIFactory factory = DeviceManager.GetUIFactory(_genericDevice.CoreDevice.DeviceID); // create and initialize view model for device IDeviceViewModel viewModel = factory.CreateViewModel(DisplayTypeEnum.Full, _genericDevice); viewModel.Initialize(); // create view and attach to our display _contentControl.Content = factory.CreateLargeView(viewModel); }