Beispiel #1
0
 private void btnDialogOk_Click(object sender, RoutedEventArgs e)
 {
     if (commPort.Text != "")
     {
         _network = new Network(null);
         _network.Update(providers.Content.ToString(), commPort.Text);
         System.Windows.MessageBox.Show("Updated");
         this.DialogResult = true;
        
     }
     else
     {
         MessageBox.Show("please input the port !");
     }
 }
        private void save_Click(object sender, RoutedEventArgs e)
        {
            if (network.Text != "")
            {
                _network = App.am.Networks.Add();
                _network.Names = network.Text;
                _network.Comm = "COM" + comms.Text;
                _network.Status = "disconnected";
                _network.Save();

                System.Windows.MessageBox.Show("Network saved ");
                Refresh();
            }
            else
            {
                MessageBox.Show("please input the network name");
            }
        }
        public void ConnectDevice()
        {


            _networkList = new ObservableCollection<Network>(App.am.Networks);
            _network = new Network(null);
            foreach (Network n in _networkList)
            {

                if (Messenger.connected(n.Names, n.Comm))
                {
                    App.Current.Dispatcher.Invoke((Action)delegate()
                    {
                        _network.UpdateStatus(n.Names, "connected");
                        InputBlock.Text = InputBlock.Text + Environment.NewLine + "Connected:" + n.Names + "to:" + n.Comm;
                        Scroller.ScrollToBottom();
                        InputBlock.ScrollToEnd();
                    });
                    Console.WriteLine("modem  connected:" + n.Names + "to:" + n.Comm);

                    port2.Content = port2.Content + Environment.NewLine + "Connected:" + n.Names + "";

                }

                else
                {

                    _network.UpdateStatus(n.Names, "disconnected");
                    App.Current.Dispatcher.Invoke((Action)delegate()
                   {
                       InputBlock.Text = InputBlock.Text + Environment.NewLine + "Not connected:" + n.Names + "to:" + n.Comm;
                       Scroller.ScrollToBottom();
                       InputBlock.ScrollToEnd();
                   });
                    Console.WriteLine("not connected:" + n.Names + "to:" + n.Comm);
                    port2.Content = port2.Content + Environment.NewLine + " " + n.Names + " " + n.Status;
                }

            }


        }