예제 #1
0
        public CaptureStegoProcess(IMoniker moniker)
        {
            Guid   baseFilterGuid = typeof(IBaseFilter).GUID;
            object o;

            ///Get our device ready
            moniker.BindToObject(null, null, ref baseFilterGuid, out o);
            this._captureFilter = (IBaseFilter)o;

            this._graphBuilder = (IGraphBuilder) new FilterGraph();

            this._captureBuilder = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

            ///Tell capture graph about filter graph builder
            this._captureBuilder.SetFiltergraph(this._graphBuilder);

            this._mediaCtrl   = (IMediaControl)this._graphBuilder;
            this._mediaEvent  = (IMediaEvent)this._graphBuilder;
            this._videoWindow = (IVideoWindow)this._graphBuilder;

            ///Code for stoping capturing
            this.OnStopCapture = delegate()
            {
                if (this._mediaCtrl != null)
                {
                    int hr = this._mediaCtrl.StopWhenReady();
                }
                base._processing = ProcessingType.Done;
                this._videoWindow.put_Visible(OABool.False);
            };
        }
예제 #2
0
        private void MainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            try
            {
                if (m_SerialCommPort.IsOpen)
                {
                    m_SerialCommPort.DiscardOutBuffer();
                    m_SerialCommPort.DiscardInBuffer();
                    m_SerialCommPort.Close();
                }
                if (m_historyTableAdapter.Connection.State == ConnectionState.Open)
                {
                    m_historyTableAdapter.Connection.Close();
                }

                m_TrackingServer.Stop();
                m_HistoryServer.Stop();
                m_UVMetersTimer.Enabled = false;
                m_UVMetersTimer.Stop();

                StopCapture sc = new StopCapture(DoAsyncStopCapture);
                sc.EndInvoke(sc.BeginInvoke(null, null));

                Properties.Settings.Default.Save();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.InnerException + ex.ToString());
            }
        }
예제 #3
0
        internal static async Task StopCaptureAsync([NotNull] StopCapture srv)
        {
            if (Settings.ScreenCaptureManager == null)
            {
                srv.Response.Success = false;
                srv.Response.Message = "No screenshot manager has been set for this platform";
                return;
            }

            string errorMessage = null;

            using (SemaphoreSlim signal = new SemaphoreSlim(0))
            {
                GameThread.Post(async() =>
                {
                    try
                    {
                        await Settings.ScreenCaptureManager.StopAsync();
                    }
                    catch (Exception e)
                    {
                        errorMessage = e.Message;
                    }
                    finally
                    {
                        signal.Release();
                    }
                });

                if (!await signal.WaitAsync(DefaultTimeoutInMs))
                {
                    Logger.Error("ControllerService: Unexpected timeout in StopCaptureAsync");
                    srv.Response.Success = false;
                    srv.Response.Message = "Request timed out";
                    return;
                }
            }

            if (errorMessage != null)
            {
                srv.Response.Success = false;
                srv.Response.Message = errorMessage;
                return;
            }

            srv.Response.Success = true;
        }