Пример #1
0
        private void SnapshotRetriever_CameraThumbnailProduced(object sender, CameraThumbnailProducedEventArgs e)
        {
            SnapshotRetriever retriever = sender as SnapshotRetriever;

            if (retriever == null)
            {
                return;
            }

            if (e.HadError || e.ImageDescriptor == ImageDescriptor.Invalid || e.Thumbnail == null)
            {
                string title   = CameraLang.FormHandshakeResult_Failure_Title;
                string message = CameraLang.FormHandshakeResult_Failure_Message;
                MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                FormHandshakeResult result = new FormHandshakeResult(e.Thumbnail);
                result.ShowDialog();
                result.Dispose();
                e.Thumbnail.Dispose();
            }

            AfterCameraTest(retriever);
        }
Пример #2
0
        private void SnapshotRetriever_CameraThumbnailProduced(object sender, CameraThumbnailProducedEventArgs e)
        {
            SnapshotRetriever retriever = sender as SnapshotRetriever;

            if (retriever != null)
            {
                retriever.CameraThumbnailProduced -= SnapshotRetriever_CameraThumbnailProduced;
                snapshotting.Remove(retriever.Identifier);
            }

            OnCameraThumbnailProduced(e);
        }
Пример #3
0
        public override void StartThumbnail(CameraSummary summary)
        {
            SnapshotRetriever snapper = snapshotting.FirstOrDefault(s => s.Identifier == summary.Identifier);

            if (snapper != null)
            {
                return;
            }

            snapper = new SnapshotRetriever(this, summary);
            snapper.CameraThumbnailProduced += SnapshotRetriever_CameraThumbnailProduced;
            snapshotting.Add(snapper);
            snapper.Start();
        }
Пример #4
0
        public void TestCamera()
        {
            if (testing)
            {
                return;
            }

            // Spawn a thread to get a snapshot.
            testing = true;
            CameraSummary     testSummary = GetResult();
            SnapshotRetriever retriever   = new SnapshotRetriever(manager, testSummary);

            retriever.CameraThumbnailProduced += SnapshotRetriever_CameraThumbnailProduced;
            ThreadPool.QueueUserWorkItem(retriever.Run);
        }
Пример #5
0
        public override void GetSingleImage(CameraSummary summary)
        {
            if (snapshotting.IndexOf(summary.Identifier) >= 0)
            {
                return;
            }

            log.DebugFormat("Retrieve single image.");

            SnapshotRetriever retriever = new SnapshotRetriever(this, summary);

            retriever.CameraThumbnailProduced += SnapshotRetriever_CameraThumbnailProduced;
            snapshotting.Add(summary.Identifier);
            ThreadPool.QueueUserWorkItem(retriever.Run);
        }
Пример #6
0
        public override void StopAllThumbnails()
        {
            for (int i = snapshotting.Count - 1; i >= 0; i--)
            {
                SnapshotRetriever snapper = snapshotting[i];
                snapper.Cancel();
                snapper.Thread.Join(500);
                if (snapper.Thread.IsAlive)
                {
                    snapper.Thread.Abort();
                }

                snapper.CameraThumbnailProduced -= SnapshotRetriever_CameraThumbnailProduced;
                snapshotting.RemoveAt(i);
            }
        }
Пример #7
0
        private void ProcessThumbnail(object sender, CameraThumbnailProducedEventArgs e)
        {
            SnapshotRetriever snapper = sender as SnapshotRetriever;

            if (snapper == null)
            {
                return;
            }

            log.DebugFormat("Received thumbnail event for {0}. Cancelled: {1}.", snapper.Alias, e.Cancelled);
            snapper.CameraThumbnailProduced -= SnapshotRetriever_CameraThumbnailProduced;
            if (snapshotting.Contains(snapper))
            {
                snapshotting.Remove(snapper);
            }

            OnCameraThumbnailProduced(e);
        }
Пример #8
0
 private void AfterCameraTest(SnapshotRetriever retriever)
 {
     retriever.CameraThumbnailProduced -= SnapshotRetriever_CameraThumbnailProduced;
     testing = false;
 }