/* * public ManageDevice() * { * //AllDevices = new List<Device>(); * * } */ public ManageDevice(Device aDevice) { AllDevices.Add(aDevice); Get1PnInterfaces(); GetAllPortsAndPartners(); Save(); }
void OnDxgkrnlDeviceStart(TraceEvent obj) { Debug.Assert(obj.EventName == "Device/DC_Start" && obj.PayloadNames.Length == 6); Debug.Assert(obj.PayloadNames[0] == "hProcessId"); int processId = (int)(UInt64)obj.PayloadValue(0); Debug.Assert(obj.PayloadNames[1] == "pDxgAdapter"); ulong pDxgAdapter = (ulong)obj.PayloadValue(1); Debug.Assert(obj.PayloadNames[3] == "hDevice"); ulong hDevice = (ulong)obj.PayloadValue(3); // Make sure the device doesn't already exist (error if it does) if (deviceLookup.ContainsKey(hDevice)) { Debug.Assert(false); return; } DeviceInfo device = new DeviceInfo(); AllDevices.Add(device); deviceLookup.Add(hDevice, device); device.hDevice = hDevice; device.Adapter = FindOrCreateAdapter(pDxgAdapter); device.Process = FindOrCreateProcess(processId); }
DeviceInfo FindOrCreateDevice(ulong hDevice) { // Already seen this device? if (deviceLookup.ContainsKey(hDevice)) { return(deviceLookup[hDevice]); } else { DeviceInfo device = new DeviceInfo(); device.hDevice = hDevice; AllDevices.Add(device); deviceLookup.Add(hDevice, device); return(device); } }
protected virtual void AddDevice(IAudioDevice device) { var newDevice = new DeviceViewModel(this, _deviceManager, device); AllDevices.Add(newDevice); }
private void AddDevice(IAudioDevice device) { var newDevice = new DeviceViewModel(_deviceManager, device); AllDevices.Add(newDevice); }
public DevicesListViewModel(IDeviceRelatedRepository repo, IUserSession userSession) { Repository = repo; UserSession = userSession; AllDevices = Repository.AllDevices.ToList(); InitDevicesLocationWithInstances(); FilterDevicesAccordingToCriteria(); ShowAddDeviceViewCommand = RegisterCommandAction( (obj) => { AddDeviceView = new AddDeviceView(); AddDeviceView.DataContext = ResolveDependency <IAddDeviceViewModel>(); AddDeviceView.ShowDialog(); }, (obj) => UserSession.IsAuthorizedUserAllowedTo(UserActions.AddDevice) ); RemoveDeviceCommand = RegisterCommandAction( (obj) => { Repository.RemoveDevice(SelectedDevice); Repository.DeleteAllDeviceMovementHistory(SelectedDevice); Repository.SaveChanges(); AllDevices.Remove(AllDevices.Find(d => d.ID == SelectedDevice.ID)); FilteredDevices.Remove(SelectedDevice); }, (obj) => { if (UserSession.IsAuthorizedUserAllowedTo(UserActions.RemoveDevice)) { return(SelectedDevice != null); } else { return(false); } } ); SubscribeActionOnDeviceAddition( (device) => { device.DeviceType = Repository.AllDeviceTypes.Single(dt => dt.ID == device.DeviceTypeID); device.Cabinet = Repository.FindCabinet(device.CabinetID); device.Cabinet.Housing = DeviceLocationViewModel. AllHousings. First(h => h.ID == device.Cabinet.HousingID); AllDevices.Add(device); if (DevicesFilter.DoesMeetSearchingAndFilteringCriteria(device)) { FilteredDevices.Add(device); } } ); SubscribeActionOnFilteringCriteraChanges( (filteredDevices) => FilteredDevices = filteredDevices.ToObservableCollection() ); }