Ejemplo n.º 1
0
        private void Connect_button_Click(object sender, RoutedEventArgs e)
        {
            Client = new TcpClient();
            IPAddress IP;
            int       port;

            if (!Client.Connected)
            {
                if (IPAddress.TryParse(IPBox.Text, out IP) && int.TryParse(PortBox.Text, out port))
                {
                    try
                    {
                        Client.Connect(IP, port);
                        Infolabel.Content = "Połączono";
                        LEDControl LED = new LEDControl(Client);
                        this.Close();
                    }
                    catch (SocketException)
                    {
                        Infolabel.Content = "Serwer niedostępny";
                    }
                }
                else
                {
                    Infolabel.Content = "Błędny format adresu IP lub portu";
                }
            }
            else
            {
                Infolabel.Content = "Połącznie wciąż aktywne";
            }
        }
Ejemplo n.º 2
0
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            var systemPath = System.Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);

            ListToXmlFile(systemPath + @"\Segments.xml");
            _timer.Enabled = false;
            ledControl     = new LEDControl(Client, list.Count);
            this.Close();
        }
Ejemplo n.º 3
0
 private void GroupButton_Click(object sender, RoutedEventArgs e)
 {
     if (Client.Connected)
     {
         ledControl = new LEDControl(Client);
         this.Close();
     }
     else
     {
         MessageBox.Show(@"Najpierw skonfiguruj połączenie.");
     }
 }
Ejemplo n.º 4
0
        private void ConnectListNetwork(int delay = 0)
        {
            infoLabel.Content = "Łączę ze sterownikiem...";

            var task = Task.Run(async delegate
            {
                await Task.Delay(delay);
            });

            task.Wait();

            lastNetwork.FontWeight = FontWeights.Regular;
            if (listBox.SelectedItem != null)
            {
                Client = new TcpClient();
                ListBoxItem network  = listBox.SelectedItem as ListBoxItem;
                string      password = "";
                if (wifi.GetAccessPoints().Find(item => item.Name == network.Content.ToString()).IsSecure)
                {
                    password = passwordBox.Password;
                }
                ConnectionControl.ConnectNetwork(wifi, network.Content.ToString(), password);
                if (wifi.ConnectionStatus == WifiStatus.Connected)
                {
                    if (wifi.GetAccessPoints().Find(item => item.IsConnected).Name == network.Content.ToString())
                    {
                        ConnectionControl.DeleteMemory();
                        if (ConnectionControl.ConnectBluegiga(Client))
                        {
                            MessageBoxResult result = MessageBox.Show("Połączono. Czy chcesz skonfigurować porty?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
                            if (result == MessageBoxResult.Yes)
                            {
                                LEDControl LED = new LEDControl(Client);
                                this.Close();
                            }
                            infoLabel.Content = "Połączono";
                        }
                        else
                        {
                            infoLabel.Content = "Brak połączenia";
                        }
                    }
                }
                WifiSearch(wifi);
            }
        }
Ejemplo n.º 5
0
        private void startButton_Click(object sender, RoutedEventArgs e)
        {
            // endLabel.Content = "koniec";
            Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
            dlg.FileName   = "Characters"; //Default file name
            dlg.DefaultExt = ".xml";
            dlg.Filter     = "XML documents (.xml)|*.xml";
            Nullable <bool> result = dlg.ShowDialog();

            if (result == true)
            {
                string filePath = dlg.FileName;
                ListToXmlFile(filePath);
            }
            _timer.Enabled = false;
            ledControl     = new LEDControl(Client, list.Count);
            this.Close();
        }
Ejemplo n.º 6
0
        private void nextButton_Click(object sender, RoutedEventArgs e)
        {
            LEDControl LED = new LEDControl(Client);

            this.Close();
        }
Ejemplo n.º 7
0
 private void LedButton_Click(object sender, RoutedEventArgs e)
 {
     Load();
     ledControl = new LEDControl(Client, list.Count);
     this.Close();
 }