/// <summary> /// Test decode program initialization /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> private void OnLoad(object sender, EventArgs e) { // program title Text = "QRCodeDecoderDemo - " + QRDecoder.VersionNumber + " \u00a9 2013-2018 Uzi Granot. All rights reserved."; #if DEBUG // current directory string CurDir = Environment.CurrentDirectory; string WorkDir = CurDir.Replace("bin\\Debug", "Work"); if (WorkDir != CurDir && Directory.Exists(WorkDir)) { Environment.CurrentDirectory = WorkDir; } // open trace file QRCodeTrace.Open("QRCodeDecoderTrace.txt"); QRCodeTrace.Write("QRCodeDecoderDemo"); #endif // create decoder QRCodeDecoder = new QRDecoder(); // resize window OnResize(sender, e); return; }
/// <summary> /// Program initialization /// </summary> /// <param name="sender">Sender</param> /// <param name="e">Event arguments</param> private void OnLoad(object sender, EventArgs e) { // program title Text = "QRCodeVideoDecoder - " + QRDecoder.VersionNumber + " \u00a9 2013-2018 Uzi Granot. All rights reserved."; #if DEBUG // current directory string CurDir = Environment.CurrentDirectory; string WorkDir = CurDir.Replace("bin\\Debug", "Work"); if (WorkDir != CurDir && Directory.Exists(WorkDir)) { Environment.CurrentDirectory = WorkDir; } // open trace file QRCodeTrace.Open("QRCodeVideoDecoderTrace.txt"); QRCodeTrace.Write(Text); #endif // disable reset button ResetButton.Enabled = false; GoToUriButton.Enabled = false; // get an array of web camera devices DsDevice[] CameraDevices = DsDevice.GetDevicesOfCat(FilterCategory.VideoInputDevice); // make sure at least one is available if (CameraDevices == null || CameraDevices.Length == 0) { MessageBox.Show("No video cameras in this computer"); Close(); return; } // select the first camera DsDevice CameraDevice = CameraDevices[0]; // Device moniker IMoniker CameraMoniker = CameraDevice.Moniker; // get a list of frame sizes available FrameSize[] FrameSizes = Camera.GetFrameSizeList(CameraMoniker); // make sure there is at least one frame size if (FrameSizes == null || FrameSizes.Length == 0) { MessageBox.Show("No video cameras in this computer"); Close(); return; } // test if our frame size is available int Index; for (Index = 0; Index < FrameSizes.Length && (FrameSizes[Index].Width != FrameSize.Width || FrameSizes[Index].Height != FrameSize.Height); Index++) { ; } // select first frame size if (Index == FrameSizes.Length) { FrameSize = FrameSizes[0]; } // Set selected camera to camera control with default frame size // Create camera object VideoCamera = new Camera(PreviewPanel, CameraMoniker, FrameSize); // create QR code decoder Decoder = new QRDecoder(); // resize window OnResize(sender, e); // create timer QRCodeTimer = new Timer(); QRCodeTimer.Interval = 200; QRCodeTimer.Tick += QRCodeTimer_Tick; QRCodeTimer.Enabled = true; return; }