Ejemplo n.º 1
0
        private void btn_stream_Click(object sender, EventArgs e)
        {
            if (isStreaming)
            {
                btn_stream.Text = "Stream Desktop";

                if (screen_capture != null)
                {
                    screen_capture.Stop();
                    screen_capture = null;
                }
            }
            else
            {
                if (screen_capture != null)
                {
                    return;
                }

                btn_stream.Text = "Stop Stream";

                screen_capture = new Screen_capture(this);
                screen_capture.ScreenRefreshed += (_sender, data) =>
                {
                    UpdateFrame(data);
                };
                screen_capture.Start();

                Thread thread = new Thread(() => calculate_average());
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
            }
            isStreaming = !isStreaming;
        }
Ejemplo n.º 2
0
 private void Screen_Stream_FormClosing(object sender, FormClosingEventArgs e)
 {
     isStreaming = false;
     if (screen_capture != null)
     {
         screen_capture.Stop();
         screen_capture = null;
     }
 }