Esempio n. 1
0
        private void Btn_ip_Click(object sender, EventArgs e)
        {
            port = 8081;
            if (!Regex.IsMatch(Txt_ip.Text, @"\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"))
            {
                Label_ip.Text = "indirizzo non valido";
                Txt_ip.Clear();
                return;
            }

            if (Label_ip.Text != "")
            {
                Label_ip.Text = "";
            }

            streamingip = Txt_ip.Text.ToString();
            ip          = Txt_ip.Text.ToString();;
            Stream      = new MJPEGStream($"http://{streamingip}:8080/?action=stream");

            try
            {
                sendmessage("C");
                sendmessage("Q");


                Stream.NewFrame += Stream_NewFrame;
                streamexist      = 1;
                Txt_ip.Clear();
                if (Rb_normal.Checked == true)
                {
                    Pb_up.Visible = true; Pb_left.Visible = true; Pb_right.Visible = true; Pb_down.Visible = true; Pb_center.Visible = true;
                }
                else
                {
                    pb_updivieto.Visible     = true;
                    pb_downdivieto.Visible   = true;
                    pb_leftdivieto.Visible   = true;
                    pb_rightdivieto.Visible  = true;
                    pb_centerdivieto.Visible = true;
                    label_divieto.Visible    = true;
                }
                Btn_stream.Visible            = true; Btn_go.Visible = true; Rb_normal.Visible = true;
                Rb_tracking.Visible           = true;
                Rb_detection.Visible          = true;
                Btn_screenshot.Visible        = true;
                Btn_ip.Visible                = false;
                Txt_ip.Visible                = false;
                label3.Visible                = false;
                Btn_go.Visible                = false;
                Txt_search.Visible            = false;
                Label_search.Visible          = false;
                btn_visible.Visible           = true;
                pictureBox1.Visible           = true;
                listBoxHostnames.Visible      = false;
                Btn_eliminacronologia.Visible = false;
                btVideo.Visible               = true;
                btZoom.Visible                = true;
                trackBar1.Visible             = true;
                pictureBox2.Visible           = true;
                Txt_ip.Clear();
                label4.Visible = false;
                Txt_search.Clear();
                label5.Visible    = false;
                btngrok.Visible   = false;
                TxtHex.Visible    = false;
                TxtPort.Visible   = false;
                label2.Visible    = false;
                label6.Visible    = false;
                label7.Visible    = false;
                Labelzoom.Visible = true;
            }
            catch
            {
                Txt_ip.Clear();
                MessageBox.Show("L'IP inserito non è corretto o il raspberry pi non risponde, riprova");
                return;
            }
        }
Esempio n. 2
0
        private void bunifuThinButton21_Click(object sender, EventArgs e)
        {
            streamingip = TxtHex.Text + ".ngrok.io";
            port        = int.Parse(TxtPort.Text);
            ip          = "0.tcp.ngrok.io";
            Stream      = new MJPEGStream($"http://{streamingip}/?action=stream");

            try
            {
                sendmessage("C");
                sendmessage("Q");

                Stream.NewFrame += Stream_NewFrame;
                streamexist      = 1;
                Txt_ip.Clear();
                if (Rb_normal.Checked == true)
                {
                    Pb_up.Visible = true; Pb_left.Visible = true; Pb_right.Visible = true; Pb_down.Visible = true; Pb_center.Visible = true;
                }
                else
                {
                    pb_updivieto.Visible     = true;
                    pb_downdivieto.Visible   = true;
                    pb_leftdivieto.Visible   = true;
                    pb_rightdivieto.Visible  = true;
                    pb_centerdivieto.Visible = true;
                    label_divieto.Visible    = true;
                }
                Btn_stream.Visible            = true; Btn_go.Visible = true; Rb_normal.Visible = true;
                Rb_tracking.Visible           = true;
                Rb_detection.Visible          = true;
                Btn_screenshot.Visible        = true;
                Btn_ip.Visible                = false;
                Txt_ip.Visible                = false;
                label3.Visible                = false;
                Btn_go.Visible                = false;
                Txt_search.Visible            = false;
                Label_search.Visible          = false;
                btn_visible.Visible           = true;
                pictureBox1.Visible           = true;
                listBoxHostnames.Visible      = false;
                Btn_eliminacronologia.Visible = false;
                btVideo.Visible               = true;
                btZoom.Visible                = true;
                trackBar1.Visible             = true;
                pictureBox2.Visible           = true;
                Txt_ip.Clear();
                label4.Visible = false;
                Txt_search.Clear();
                label5.Visible    = false;
                btngrok.Visible   = false;
                TxtHex.Visible    = false;
                TxtPort.Visible   = false;
                label2.Visible    = false;
                label6.Visible    = false;
                Labelzoom.Visible = true;
                label7.Visible    = false;
            }
            catch
            {
                Txt_ip.Clear();
                MessageBox.Show("L'IP inserito non è corretto o il raspberry pi non risponde, riprova");
                return;
            }
        }
Esempio n. 3
0
        private void Btn_go_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Txt_search.Text) == true)
            {
                MessageBox.Show("inserire un valore come hostname");
                return;
            }
            string HostName = Txt_search.Text;

            IPAddress[] ipaddress = new IPAddress[100];
            try
            {
                ipaddress = Dns.GetHostAddresses(HostName);
            }
            catch
            {
                Label_search.Visible = true;
            }

            try
            {
                foreach (IPAddress ip4 in ipaddress.Where(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork))
                {
                    Txt_ip.Text          = ip4.ToString();;
                    Label_search.Visible = false;
                }
            }
            catch (NullReferenceException)
            {
                Label_search.Visible = true;
                Txt_search.Clear();
                return;
            }

            if (File.ReadAllText("hostnameListbox.txt").Contains(Txt_search.Text))
            {
            }
            else
            {
                StreamWriter scrivere = new StreamWriter("hostnameListbox.txt", true);
                scrivere.WriteLine($"{Txt_search.Text}");
                scrivere.Close();
            }

            StreamReader leggere;

            leggere = new StreamReader("hostnameListbox.txt");

            if (new FileInfo("hostnameListbox.txt").Length == 0)
            {
                leggere.Close();
                return;
            }
            listBoxHostnames.Items.Clear();
            while (leggere.EndOfStream == false)
            {
                listBoxHostnames.Items.Add(leggere.ReadLine());
            }

            leggere.Close();
            Txt_search.Clear();
        }