コード例 #1
0
        public async Task InitDevices(IEnumerable <DeviceItem> devices)
        {
            Devices = devices.Select(i => new SelectedItem {
                Value = i.DeviceId, Text = i.Label
            });
            Disabled = !Devices.Any();

            if (OnInit != null)
            {
                await OnInit(devices);
            }
            if (devices.Any())
            {
                for (var index = 0; index < devices.Count(); index++)
                {
                    var d = devices.ElementAt(index);
                    if (string.IsNullOrEmpty(d.Label))
                    {
                        d.Label = $"Video device {index + 1}";
                    }
                }
                Disabled     = false;
                ActiveCamera = Cameras.First();
            }
            StateHasChanged();
        }
コード例 #2
0
        public DeviceInformation GetCamera(string id)
        {
            if (!Cameras.Any())
            {
                return(null);
            }
            var camera = Cameras.FirstOrDefault(x => x.Id.ToLower() == id?.ToLower());

            if (camera == null)
            {
                camera = Cameras.FirstOrDefault(x => x.EnclosureLocation?.Panel == Panel.Front);
            }
            return(camera ?? Cameras.First());
        }
コード例 #3
0
        public async Task <DeviceInformation> GetCameraAsync(string id = null)
        {
            if (Cameras == null)
            {
                Cameras = await GetCamerasAsync(null);
            }
            if (!Cameras.Any())
            {
                return(null);
            }
            var camera = Cameras.FirstOrDefault(x => x.Id.ToLower() == id?.ToLower());

            if (camera == null)
            {
                camera = Cameras.FirstOrDefault(x => x.EnclosureLocation?.Panel == Panel.Front);
            }
            return(camera ?? Cameras.First());
        }