public void OnChangeFocusModeClicked (NSObject sender)
{
var control = (UISegmentedControl)sender;
AVCaptureFocusMode mode = focusModes [control.SelectedSegment];
NSError error = null;
bool success = VideoDevice.LockForConfiguration (out error);
if (!success) {
Console.WriteLine ($"Could not lock device for configuration: {error}");
return;
}
if (VideoDevice.IsFocusModeSupported (mode)) {
VideoDevice.FocusMode = mode;
} else {
Console.WriteLine ($"Focus mode {StringFromFocusMode (mode)} is not supported. Focus mode is {StringFromFocusMode (VideoDevice.FocusMode)}.");
FocusModeControl.SelectedSegment = Array.IndexOf (focusModes, VideoDevice.FocusMode);
}
VideoDevice.UnlockForConfiguration ();
}