Exemple #1
0
        void getStreamCamera(string cPort, string cValue, string cText)
        {
            lastPort = cPort;
            lastValue = cValue;
            lastText = cText;
            lblCamerasNr.Text = "Streamming . . .";
            lblCamerasNr.Refresh();
            try
            {
                string myRemoteIP = "http://" + newIP + ":" + cPort + "/RobotWebCamServer";
                client = new WebCamService.WebCamServiceClient("NetTcpBinding_IWebCamService", myRemoteIP);
                client.Record(cValue, cText);
            }
            catch (System.ServiceModel.CommunicationException ex)
            { MessageBox.Show(ex.Message); }

            System.Threading.Thread.Sleep(3000);

            timer1.Tick += new EventHandler(timer1_Tick);
            timer1.Start();
        }
Exemple #2
0
        private void getStreamMic()
        {
            if (micIndex != null)
            {
                var outDevices = WaveOut.Devices;
                if (outDevices.Length == 0)
                {
                    MessageBox.Show("There are no output sound devices installed.");
                    return;
                }
                /*string outDevicesRes = "";
                string resValue = "0";
                for (int i = 0; i < outDevices.Length; i++)
                {
                    outDevicesRes += "\r\n" + i + " : " + outDevices[i].Name;
                }
                if (outDevices.Length == 1)
                {
                    speakerID = 0;
                }
                else if (InputBox("Select your Speaker ID", outDevicesRes, ref resValue) == DialogResult.OK)
                {
                    speakerID = Convert.ToInt32(resValue);
                }*/
                speakerID = 0;
            }
            else
            {
                MessageBox.Show("Fatal Error!!! Please try again.");
                return;
            }
            try
            {
                string myRemoteIP = string.Format("http://{0}:{1}/RobotWebCamServer", newIP, micPort);
                clientMic = new WebCamService.WebCamServiceClient("NetTcpBinding_IWebCamService", myRemoteIP);
                clientMic.micStart(Convert.ToInt32(micIndex));
                waveBuffer = clientMic.waveMicBuffer();
            }
            catch (System.ServiceModel.CommunicationException ex)
            {
                MessageBox.Show(ex.Message); return;
            }

            Thread.Sleep(30);
            isCalculateImageDelay = true;
            timerMic.Tick += new EventHandler(timerMic_Tick);
            timerMic.Start();
        }
Exemple #3
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (!(client == null))
     {
         client.stop_record();
     }
     client = null;
     Application.Exit();
 }
Exemple #4
0
        private void startArduino()
        {
            string strPermission = checkForPermission(loginName);

            //RegistryKey registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);

            //Console.WriteLine("registryKey" + registryKey);
            //registryKey = registryKey.OpenSubKey(@"SYSTEM\CurrentControlSet\Services\USBSTOR");
            //Object val = registryKey.GetValue("Start");
            //Console.WriteLine("The val is:" + val);
            ////disable USB storage...
            //Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 4, Microsoft.Win32.RegistryValueKind.DWord);

            ////enable USB storage...
            //Microsoft.Win32.Registry.SetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR", "Start", 3, Microsoft.Win32.RegistryValueKind.DWord);

            try
            {
                ThreadPool.QueueUserWorkItem(delegate
                {
                    string myRemoteIP = string.Format("http://{0}:{1}/RobotWebCamServer", newIP, lastPort);
                    DateTime dt = DateTime.Now;
                    client = new WebCamService.WebCamServiceClient("NetTcpBinding_IWebCamService", myRemoteIP);
                    try
                    {
                        client.arduinoStart(loginName, "COM" + lastCOMport, lastLabID, lastDevID, strPermission, ref dt);
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    lastDateTime = dt;
                }, null);

            }
            catch (System.ServiceModel.CommunicationException ex)
            {
                //MessageBox.Show(ex.Message);
                return;
            }

            Thread.Sleep(100);
            GetArduinoUserList(loginName);
            stopProgressBar();
            setSyntaxHighlight(syntaxHighlightingTextBoxSourceCode, "Arduino");
            //string mysource = File.OpenText(@"test\test.ino").ReadToEnd(); ;
            //syntaxHighlightingTextBoxSourceCode.Text = mysource;
            toolStripButtonOpenSerial.Enabled = true;
            toolStripButtonCompile.Enabled = true;
            toolStripButtonUpload.Enabled = true;
            timerGetUserList.Tick += new EventHandler(timerGetUserList_Tick);
            timerGetUserList.Start();

            syntaxHighlightingTextBoxSourceCode.Enabled = true;
            toolStripButtonZoomIn.Enabled = true;
            toolStripButtonZoomOut.Enabled = true;

            startProgressBar();
            this.StartBackgroundWorkSqlQueryGetUser()
                    .ContinueWith((t) => this.setResultSqlGetUserQuery(t.Result), TaskScheduler.FromCurrentSynchronizationContext());
        }