Пример #1
0
 private void pauseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (paused)
     {
         pauseToolStripMenuItem.Text = "Pause";
         CaptureTimer.Start();
     }
     else
     {
         pauseToolStripMenuItem.Text = "Start";
         CaptureTimer.Stop();
     }
     paused = !paused;
 }
Пример #2
0
        private void CaptureTimer_Tick(object sender, EventArgs e)
        {
            var d = colorDetector;

            d.detect();
            try
            {
                CaptureTimer.Stop();
                using (var wb = new WebClient())
                {
                    //string get = "http://<rasspberry-pi-IP>/color.php?r=" + (d.R > 50 ? d.R : 0) + "g=" + (d.G > 50 ? d.G : 0) + "b=" + (d.B > 50 ? d.B : 0) + "id=<your id>";
                    string get      = "http://localhost/color.php?r=" + (d.R > 50 ? d.R : 0) + "&g=" + (d.G > 50 ? d.G : 0) + "&b=" + (d.B > 50 ? d.B : 0) + "&id=124";
                    var    response = wb.DownloadString(get);
                }
            }
            catch (Exception E)
            {
                DialogResult choice = MessageBox.Show("Retry in 30 seconds or Abort ?\nerror text :" + E.Message, "Retry or Abort", MessageBoxButtons.AbortRetryIgnore);
                if (choice == DialogResult.Retry)
                {
                    CaptureTimer.Interval = 30000;
                }
                else if (choice == DialogResult.Abort)
                {
                    CaptureTimer.Stop();
                    paused = true;
                    pauseToolStripMenuItem.Text = "Start";
                    //make icon gray if needed
                }
            }
            finally
            {
                if (!paused)
                {
                    CaptureTimer.Start();
                }
            }
        }
Пример #3
0
 private int interval = 1000; //default 1000ms
 public HiddenForm()
 {
     InitializeComponent();
     CaptureTimer.Start();
     //initialzie interval using config file if needed
 }