Пример #1
0
        private void ExternPropertyUpdate(object sender, EventArgs e)
        {
            Debug.WriteLine("PropertyUpdate");
            PropertyControl pc = (PropertyControl)sender;

            foreach (Control item in main.Controls)
            {
                if (item is PropertyControlSave)
                {
                    if (pc.ToString().Equals(((PropertyControlSave)item).ToString()))
                    {
                        ((PropertyControlSave)item).SyncValue(pc);
                    }
                }
            }
        }
Пример #2
0
        private void InitProperties()
        {
            mainLayout.Controls.Clear();

            foreach (var prop in Enum.GetValues(typeof(CameraControlProperty)))
            {
                if (INI.KeyExists(prop.ToString(), webcam.DevicePath) && "True".Equals(INI.ReadINI(webcam.DevicePath, prop.ToString())))
                {
                    mainLayout.Controls.Add(CreatePropertyControl(prop));
                }
            }
            foreach (var prop in Enum.GetValues(typeof(VideoProcAmpProperty)))
            {
                if (INI.KeyExists(prop.ToString(), webcam.DevicePath) && "True".Equals(INI.ReadINI(webcam.DevicePath, prop.ToString())))
                {
                    mainLayout.Controls.Add(CreatePropertyControl(prop));
                }
            }

            string PropertyHIDButton1Selected = INI.ReadINI(webcam.DevicePath, "PropertyHIDButton1");
            string PropertyHIDButton2Selected = INI.ReadINI(webcam.DevicePath, "PropertyHIDButton2");

            for (int i = 0; i < mainLayout.Controls.Count; i++)
            {
                PropertyControl item = (PropertyControl)mainLayout.Controls[i];
                item.Dock         = DockStyle.Top;
                item.ValueUpdate += new EventHandler(PropertyValueUpdate);
                if (PropertyHIDButton1Selected.Equals(item.ToString()))
                {
                    PropertyHIDButton1Index = i;
                }
                if (PropertyHIDButton2Selected.Equals(item.ToString()))
                {
                    PropertyHIDButton2Index = i;
                }
            }
            if (hid != null)
            {
                SelectNextProperty();
            }
        }
Пример #3
0
 public void SyncValue(PropertyControl pc)
 {
     trackBar.Value = pc.GetPropertyValue();
     cbAuto.Checked = pc.GetAutoMode();
     ValueUpdate?.Invoke(this, new EventArgs());
 }
Пример #4
0
        private void OnReport(HidReport report)
        {
            if (report.ReportId != 4)
            {
                return;
            }
            switch (report.Data[0])
            {
            case 1:
                currentProperty.AutoMode(false);
                bool dir = report.Data[1] != 0;
                Debug.WriteLine(dir);
                if (oldDir != dir)
                {
                    oldDir = dir;
                    mul    = 1;
                }
                else
                {
                    mul++;
                }
                currentProperty.UpdateValue(mul, dir ? 1 : -1);
                break;

            case 2:
                currentProperty.AutoMode(true);
                Debug.WriteLine("Button auto");
                break;

            case 3:
                Debug.WriteLine("Button 1");
                if (PropertyHIDButton1Index < 0)
                {
                    break;
                }
                currentProperty.SelectItem(false);
                currentIndex    = PropertyHIDButton1Index;
                currentProperty = (PropertyControl)mainLayout.Controls[currentIndex];
                currentProperty.SelectItem(true);
                break;

            case 4:
                Debug.WriteLine("Button 2");
                if (PropertyHIDButton2Index < 0)
                {
                    break;
                }
                currentProperty.SelectItem(false);
                currentIndex    = PropertyHIDButton2Index;
                currentProperty = (PropertyControl)mainLayout.Controls[currentIndex];
                currentProperty.SelectItem(true);
                break;

            case 5:
                Debug.WriteLine("Button next");
                if (report.Data[1] == 0)
                {
                    break;
                }
                SelectNextProperty();
                break;
            }
            // we need to start listening again for more data
            hid.ReadReport(OnReport);
        }