private void btnOptions_Click(object sender, RoutedEventArgs e)
{
//----------------<
btnOptions_Click() >----------------
if(combo_Controllers.Visibility==Visibility.Visible )
{
combo_Controllers.Visibility
= Visibility.Collapsed ;
cbxAuto.Visibility = Visibility.Collapsed;
slider_Modify.Visibility = Visibility.Collapsed;
}
else
{
combo_Controllers.Visibility
= Visibility.Visible;
cbxAuto.Visibility = Visibility.Visible;
slider_Modify.Visibility = Visibility.Visible;
init_Controllers();
}
//----------------</
btnOptions_Click() >----------------
}
private void init_Controllers()
{
//----------------<
init_Controllers() >----------------
combo_Controllers.Items.Clear();
combo_Controllers.Visibility = Visibility.Visible;
lblApp.Visibility = Visibility.Collapsed;
//--< check Controlles and add to
List >--
if
(_mediaCapture.VideoDeviceController.Brightness.Capabilities.Supported)
combo_Controllers.Items.Add("Brightness");
if
(_mediaCapture.VideoDeviceController.Contrast.Capabilities.Supported)
combo_Controllers.Items.Add("Contrast");
if
(_mediaCapture.VideoDeviceController.Exposure.Capabilities.Supported) combo_Controllers.Items.Add("Exposure");
if
(_mediaCapture.VideoDeviceController.Focus.Capabilities.Supported)
combo_Controllers.Items.Add("Focus");
if
(_mediaCapture.VideoDeviceController.Hue.Capabilities.Supported)
combo_Controllers.Items.Add("Hue");
if
(_mediaCapture.VideoDeviceController.Pan.Capabilities.Supported)
combo_Controllers.Items.Add("Pan");
if
(_mediaCapture.VideoDeviceController.WhiteBalance.Capabilities.Supported)
combo_Controllers.Items.Add("WhiteBalance");
if
(_mediaCapture.VideoDeviceController.Zoom.Capabilities.Supported)
combo_Controllers.Items.Add("Zoom");
//--</ check Controlles and add to
List >--
if (combo_Controllers.Items.Count > 0)
{
combo_Controllers.SelectedIndex = 0;
}
else
{
combo_Controllers.Visibility
= Visibility.Collapsed;
}
//----------------</
init_Controllers() >----------------
}
private void combo_Controllers_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
//----------------<
combo_Controllers_SelectionChanged() >----------------
ComboBox ctlComboBox = sender as ComboBox;
//< check >
if (ctlComboBox.SelectedValue==null)
{
return;
}
//</ check >
string sController =
ctlComboBox.SelectedValue.ToString();
//< check Selection >
//*and set _Controller
if(sController=="Brightness") _control =
_mediaCapture.VideoDeviceController.Brightness;
else if (sController == "Contrast") _control =
_mediaCapture.VideoDeviceController.Contrast ;
else if (sController == "Exposure") _control =
_mediaCapture.VideoDeviceController.Exposure;
else if (sController == "Focus") _control =
_mediaCapture.VideoDeviceController.Focus;
else if (sController == "Hue") _control =
_mediaCapture.VideoDeviceController.Hue;
else if (sController == "Pan") _control =
_mediaCapture.VideoDeviceController.Pan;
else if (sController == "WhiteBalance") _control =
_mediaCapture.VideoDeviceController.WhiteBalance;
else if (sController == "Zoom") _control =
_mediaCapture.VideoDeviceController.Zoom;
//</ check Selection >
//< set controls-Elemtens >
check_Controller(_control);
//</ set control-Elements >
//----------------</
combo_Controllers_SelectionChanged() >----------------
}
#region Camera_Device_Controller
MediaDeviceControl _control;
MediaDeviceControlCapabilities _caps;
private void check_Controller(MediaDeviceControl video_Device_Controller)
{
//----------------<
check_Controller() >----------------
//*get Brightness Controller of Webcam,
internal controller
//< get Control >
//_control =
_mediaCapture.VideoDeviceController.Brightness;
_caps = _control.Capabilities;
//</ get Control >
if (_caps.Supported == true)
{
//----< set Slider >----
slider_Modify.Visibility =
Visibility.Visible;
slider_Modify.Maximum =
_caps.Max;
slider_Modify.Minimum =
_caps.Min;
double val = 0;
_control.TryGetValue(out val);
slider_Modify.Value = val;
//----</ set Slider >----
//< set Auto-Control >
if (_caps.AutoModeSupported)
{
cbxAuto.Visibility = Visibility.Visible;
bool isAuto;
_control.TryGetAuto(out isAuto);
cbxAuto.IsChecked =
isAuto;
}
else
{
cbxAuto.Visibility = Visibility.Collapsed;
}
//</ set Auto-Control >
}
else
{
//< not supported >
slider_Modify.Visibility = Visibility.Collapsed;
cbxAuto.Visibility = Visibility.Collapsed;
//</ not supported >
}
//----------------</
check_Controller() >----------------
}
private void slider_Modify_ValueChanged(object sender,
Windows.UI.Xaml.Controls.Primitives.RangeBaseValueChangedEventArgs e)
{
//----------------<
slider_Modify_ValueChanged() >----------------
if (_caps.Supported == true)
{
double val = slider_Modify.Value;
_control.TrySetValue(val);
}
//----------------</
slider_Modify_ValueChanged() >----------------
}
private void cbxAuto_Click(object sender, RoutedEventArgs e)
{
//< set auto >
_control.TrySetAuto((bool)cbxAuto.IsChecked);
//</ set auto >
}
#endregion /Camera_Device_Controller
|