Exemple #1
0
        private void aggiungi_button_Click(object sender, RoutedEventArgs e)
        {
            int flag = 0;

            string myIpString = this.ip_text_box.Text;
            bool   isValidIp  = true;

            string pattern = @"^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$";
            Regex  check   = new Regex(pattern);

            if (myIpString == null)
            {
                isValidIp = false;
            }
            else
            {
                isValidIp = check.IsMatch(myIpString, 0);
            }

            //isValidIp = IPAddress.TryParse(myIpString, out ipAddress);

            Int16 num;

            if (isValidIp == false)
            {
                MessageBox.Show("IP non valido o mancante");
            }
            else if (this.porta_text_box.Text.Trim().Length == 0 || !Int16.TryParse(this.porta_text_box.Text.Trim(), out num))
            {
                MessageBox.Show("Porta non valida o mancante");
            }
            else if (this.password_text_box.Password.Trim().Length == 0)
            {
                MessageBox.Show("Password mancante");
            }
            else
            {
                ServerWindow server = new ServerWindow(this.ip_text_box.Text, Convert.ToInt16(this.porta_text_box.Text), this.password_text_box.Password);

                foreach (ServerWindow se in rif.serverList)
                {
                    if (se.ip == this.ip_text_box.Text && se.porta == Convert.ToInt16(this.porta_text_box.Text))
                    {
                        flag = 1;
                    }
                }

                if (flag == 0)
                {
                    rif.serverList.Add(server);
                    //MessageBox.Show("Server aggiunto alla lista");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Server già presente in lista");
                }
            }
        }
Exemple #2
0
        public void Change_Focus(ServerWindow window)
        {
            Action action = () =>
            {
                controlla_button.IsEnabled  = true;
                DisconnettiButton.IsEnabled = true;
                CancellaButton.IsEnabled    = true;
                loading_label.Content       = "";

                if (window.Connesso == true)
                {
                    this.DisconnettiButton.Visibility = Visibility.Visible;
                }

                int n = serverList.IndexOf(window);
                window.boss = true;
                Console.WriteLine(n);
                Button b = new Button();
                b.Background        = Brushes.Yellow;
                b.Width             = 20;
                b.Height            = 20;
                b.BorderBrush       = Brushes.White;
                b.VerticalAlignment = VerticalAlignment.Top;
                b.Content           = "M";
                b.BorderBrush       = Brushes.Black;


                double x = 0;
                double y = 0;

                //for (int i =0; i < serverList.Count() && i!=n; i++)
                //{
                //    Button b1 = new Button();
                //    b1.Background = Brushes.White;
                //    b1.Width = 20;
                //    b1.Height = 20;
                //    b1.BorderBrush = Brushes.White;
                //    b1.VerticalAlignment = VerticalAlignment.Top;
                //    b1.Margin = new Thickness(x, y +(20*i), 0, 0);

                //    master.Children.Add(b1);
                //}


                master.Children.Clear();
                master.Children.Add(b);
                b.Margin          = new Thickness(x, y + (20 * n), 0, 0);
                window.l1.Content = "CTRL + " + cambiaFocus;
                window.l2.Content = "CTRL + " + ritornaClient;
                window.l3.Content = "CTRL + " + copiaClipboard;
                window.l4.Content = "CTRL + " + copiaClipboardServer;
                byte[] string_send = Encoding.UTF8.GetBytes("_XA_");
                window.socket.BeginSend(string_send, 0, string_send.Length, SocketFlags.None, ServerWindow.BeginSendCallback, window.socket);
                window.Show();
            };

            dispatcher.BeginInvoke(action);
        }
Exemple #3
0
        public void Inizio(ServerWindow s, bool set)
        {
            Action action = () =>
            {
                if (set == true)
                {
                    s.label_receiving.Content = "Sending ...";
                }
                else
                {
                    s.label_receiving.Content = "Receiving ...";
                }
                s.e1.Fill    = Brushes.Orange;
                s.e1.Opacity = 1.0;

                s.e2.Fill    = Brushes.Black;
                s.e2.Opacity = 0.9;

                s.e3.Fill    = Brushes.Black;
                s.e3.Opacity = 0.8;

                s.e4.Fill    = Brushes.Black;
                s.e4.Opacity = 0.7;

                s.e5.Fill    = Brushes.Black;
                s.e5.Opacity = 0.6;

                s.e6.Fill    = Brushes.Black;
                s.e6.Opacity = 0.5;

                s.e7.Fill    = Brushes.Black;
                s.e7.Opacity = 0.4;

                s.e8.Fill    = Brushes.Black;
                s.e8.Opacity = 0.3;

                s.e9.Fill    = Brushes.Black;
                s.e9.Opacity = 0.2;

                s.e10.Fill    = Brushes.Black;
                s.e10.Opacity = 0.1;
            };


            dispatcher.Invoke(action);
        }
Exemple #4
0
        public void Fine(ServerWindow s)
        {
            Action action = () =>
            {
                s.e1.Fill  = Brushes.LightBlue;
                s.e2.Fill  = Brushes.LightBlue;
                s.e3.Fill  = Brushes.LightBlue;
                s.e4.Fill  = Brushes.LightBlue;
                s.e5.Fill  = Brushes.LightBlue;
                s.e6.Fill  = Brushes.LightBlue;
                s.e7.Fill  = Brushes.LightBlue;
                s.e8.Fill  = Brushes.LightBlue;
                s.e9.Fill  = Brushes.LightBlue;
                s.e10.Fill = Brushes.LightBlue;
                s.label_receiving.Content = "";
            };


            dispatcher.Invoke(action);
        }
Exemple #5
0
 public void setRif(MainWindow main, ServerWindow se)
 {
     rif     = main;
     rif_ser = se;
 }