private bool SelectSource()
{
bool success = false;
FindCameras.LastConfig.PromptSave = false;
var vs = new VideoSource { CameraControl = CameraControl, StartWizard = StartWizard };
vs.ShowDialog(this);
if (vs.DialogResult == DialogResult.OK)
{
CameraControl.Camobject.settings.videosourcestring = vs.VideoSourceString;
CameraControl.Camobject.settings.sourceindex = vs.SourceIndex;
CameraControl.Camobject.settings.login = vs.CameraLogin;
CameraControl.Camobject.settings.password = vs.CameraPassword;
CameraControl.Camobject.name = vs.FriendlyName;
bool su = CameraControl.Camobject.resolution != vs.CaptureSize.Width + "x" + vs.CaptureSize.Height;
if (vs.SourceIndex==3)
{
CameraControl.Camobject.resolution = vs.CaptureSize.Width + "x" + vs.CaptureSize.Height;
CameraControl.Camobject.settings.framerate = vs.FrameRate;
CameraControl.Camobject.settings.crossbarindex = vs.VideoInputIndex;
}
chkActive.Enabled = true;
chkActive.Checked = false;
Thread.Sleep(1000); //allows unmanaged code to complete shutdown
chkActive.Checked = true;
CameraControl.NeedSizeUpdate = su;
if (CameraControl.VolumeControl == null && CameraControl.Camera!=null)
{
//do we need to add a paired volume control?
var c = CameraControl.Camera.VideoSource as ISupportsAudio;
if (c!=null)
{
c.HasAudioStream += AddCameraHasAudioStream;
}
if (FindCameras.LastConfig.PromptSave)
{
CameraControl.NewFrame -= NewCameraNewFrame;
CameraControl.NewFrame += NewCameraNewFrame;
}
}
LoadAlertTypes();
success = true;
}
vs.Dispose();
return success;
}