Exemplo n.º 1
0
        private void LoadProperties()
        {
            try
            {
                IsoNumber = new PropertyValue <int> {
                    Available = false
                };
                FNumber = new PropertyValue <int> {
                    Available = false
                };
                ExposureCompensation = new PropertyValue <int> {
                    Available = false
                };
                FocusMode = new PropertyValue <long> {
                    Available = false
                };
                ShutterSpeed = new PropertyValue <long> {
                    Available = false
                };
                WhiteBalance = new PropertyValue <long> {
                    Available = false
                };

                Properties.Add(AddNames("photo_size", "Photo size"));
                Properties.Add(AddNames("precise_selftime", "Capture delay"));
                Properties.Add(AddNames("burst_capture_number", "Burst capture number"));
                Properties.Add(AddNames("auto_low_light", "Auto low light"));

                AdvancedProperties.Add(AddNames("video_resolution", "Video resolution"));
                AdvancedProperties.Add(AddNames("led_mode", "Led mode"));
                AdvancedProperties.Add(AddNames("auto_power_off", "Auto power off"));
                AdvancedProperties.Add(AddNames("loop_record", "Loop record"));
                AdvancedProperties.Add(AddNames("warp_enable", "Lens correction"));
                AdvancedProperties.Add(AddNames("buzzer_ring", "Find device"));

                CompressionSetting.ValueChanged +=
                    (sender, key, val) => { Protocol.SendValue(CompressionSetting.Tag, key); };
                SendCommand(9, CompressionSetting.Tag);

                Mode.ValueChanged += Mode_ValueChanged;
                SendCommand(9, Mode.Tag);

                ExposureMeteringMode.ValueChanged +=
                    (sender, key, val) => { Protocol.SendValue(ExposureMeteringMode.Tag, key); };
                SendCommand(9, ExposureMeteringMode.Tag);

                foreach (var property in Properties)
                {
                    SendCommand(9, property.Tag);
                }
                foreach (var property in AdvancedProperties)
                {
                    SendCommand(9, property.Tag);
                }
            }
            catch (Exception ex)
            {
                Log.Error("Unable to load data", ex);
            }
        }
        public FakeCameraDevice()
        {
            HaveLiveView         = false;
            IsBusy               = false;
            DeviceName           = "Fake camera";
            SerialNumber         = "00000000";
            IsConnected          = true;
            HaveLiveView         = false;
            ExposureStatus       = 1;
            ExposureCompensation = new PropertyValue <int>()
            {
                IsEnabled = false
            };
            Mode = new PropertyValue <uint> {
                IsEnabled = false
            };
            FNumber = new PropertyValue <int> {
                IsEnabled = false
            };
            ShutterSpeed = new PropertyValue <long> {
                IsEnabled = false
            };
            WhiteBalance = new PropertyValue <long> {
                IsEnabled = false
            };
            FocusMode = new PropertyValue <long> {
                IsEnabled = false
            };
            CompressionSetting = new PropertyValue <int> {
                IsEnabled = false
            };
            IsoNumber = new PropertyValue <int> {
                IsEnabled = true
            };
            ExposureMeteringMode = new PropertyValue <int> {
                IsEnabled = false
            };
            Battery = 100;
            Capabilities.Add(CapabilityEnum.CaptureNoAf);
            Capabilities.Add(CapabilityEnum.LiveView);
            LiveViewImageZoomRatio = new PropertyValue <int>();
            LiveViewImageZoomRatio.AddValues("All", 0);
            LiveViewImageZoomRatio.Value = "All";

            IsoNumber.AddValues("100", 100);
            IsoNumber.AddValues("200", 200);
            IsoNumber.AddValues("300", 300);
            IsoNumber.Value = "100";

            var val = new PropertyValue <long>()
            {
                Name = "Test Test"
            };

            val.AddValues("Val 1", 1);
            val.AddValues("Val 2", 2);
            val.AddValues("Val 3", 3);
            val.Value = "Val 1";
            AdvancedProperties.Add(val);
        }
Exemplo n.º 3
0
        public bool Init(DeviceDescriptor deviceDescriptor, DeviceDescription description)
        {
            base.Init(deviceDescriptor);
            StillImageDevice imageDevice = StillImageDevice as StillImageDevice;

            if (imageDevice != null)
            {
                imageDevice.DeviceEvent += StillImageDevice_DeviceEvent;
            }
            foreach (var property in description.Properties)
            {
                if (!string.IsNullOrEmpty(property.Name))
                {
                    try
                    {
                        MTPDataResponse result = StillImageDevice.ExecuteReadData(CONST_CMD_GetDevicePropDesc, property.Code);

                        ErrorCodes.GetException(result.ErrorCode);
                        uint dataType   = BitConverter.ToUInt16(result.Data, 2);
                        int  dataLength = StaticHelper.GetDataLength(dataType);

                        var value = new PropertyValue <long> {
                            Code = property.Code, Name = property.Name
                        };
                        foreach (var propertyValue in property.Values)
                        {
                            value.AddValues(propertyValue.Name, propertyValue.Value);
                        }
                        value.ValueChanged += value_ValueChanged;

                        AdvancedProperties.Add(value);
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Error ger property ", ex);
                    }
                }
            }
            return(true);
        }