示例#1
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);
        }
示例#2
0
        public override void GetSingleImage(CameraSummary summary)
        {
            if (snapshotting.IndexOf(summary.Identifier) >= 0)
            {
                return;
            }

            // Spawn a thread to get a snapshot.
            SnapshotRetriever retriever = new SnapshotRetriever(summary);

            retriever.CameraThumbnailProduced += SnapshotRetriever_CameraThumbnailProduced;
            snapshotting.Add(summary.Identifier);
            ThreadPool.QueueUserWorkItem(retriever.Run);
        }
        public override void StartThumbnail(CameraSummary summary)
        {
            SnapshotRetriever snapper = snapshotting.FirstOrDefault(s => s.Identifier == summary.Identifier);

            if (snapper != null)
            {
                return;
            }

            snapper = new SnapshotRetriever(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(testSummary);

            retriever.CameraThumbnailProduced += SnapshotRetriever_CameraThumbnailProduced;
            ThreadPool.QueueUserWorkItem(retriever.Run);
        }
        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);
            }
        }
示例#6
0
        private void SnapshotRetriever_CameraThumbnailProduced(object sender, CameraThumbnailProducedEventArgs e)
        {
            SnapshotRetriever retriever = sender as SnapshotRetriever;

            if (retriever == null)
            {
                return;
            }

            FormHandshakeResult result = new FormHandshakeResult(e.Thumbnail);

            result.ShowDialog();
            result.Dispose();

            e.Thumbnail.Dispose();
            AfterCameraTest(retriever);
        }
        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;
 }