Ejemplo n.º 1
0
        private void RefreshPortPairs()
        {
            ObservableCollection <Com0comPortPair> newpairs = Com0comSetup.GetPortPairs();

            //first we need to delete any ports that don't appear in the new list
            foreach (var expair in PortPairs.ToList())
            {
                var newpair = (from p in newpairs where p.PairNumber == expair.PairNumber select p).FirstOrDefault();
                if (newpair == null)
                {
                    expair.StopComms();
                    PortPairs.Remove(expair);
                }
            }

            //next we need to add any new pairs
            foreach (var newpair in newpairs)
            {
                var expair = (from p in PortPairs where p.PairNumber == newpair.PairNumber select p).FirstOrDefault();
                if (expair == null)
                {
                    PortPairs.Add(newpair);
                }
            }
        }
 public MainWindow()
 {
     try
     {
         PortPairs = Com0comSetup.GetPortPairs();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     InitializeComponent();
     cboCommsMode.ItemsSource = Enum.GetValues(typeof(CommsMode));
 }
Ejemplo n.º 3
0
        private void mnuAddPair_Click(object sender, RoutedEventArgs e)
        {
            PortConfigWindow w = new PortConfigWindow();

            if (w.ShowDialog() ?? false)
            {
                if (Com0comSetup.CreatePortPair(w.Result.PortA))
                {
                    RefreshPortPairs();
                }
                else
                {
                    MessageBox.Show("Failed to create pair - do you have admin?");
                }
            }
        }
Ejemplo n.º 4
0
        private void mnuRemovePair_Click(object sender, RoutedEventArgs e)
        {
            Com0comPortPair p;

            if ((p = listPorts.SelectedValue as Com0comPortPair) != null)
            {
                if (p.CommsStatus != CommsStatus.Idle)
                {
                    MessageBox.Show("Please stop the comms on this port first");
                    return;
                }
                if (Com0comSetup.DeletePortPair(p.PairNumber))
                {
                    RefreshPortPairs();
                }
                else
                {
                    MessageBox.Show("Failed to remove pair - do you have admin?");
                }
            }
        }
Ejemplo n.º 5
0
 public MainWindow()
 {
     try
     {
         PortPairs = Com0comSetup.GetPortPairs();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     InitializeComponent();
     cboCommsMode.ItemsSource = Enum.GetValues(typeof(CommsMode));
     cb_BaudRate.Items.Add("110");
     cb_BaudRate.Items.Add("150");
     cb_BaudRate.Items.Add("300");
     cb_BaudRate.Items.Add("1200");
     cb_BaudRate.Items.Add("2400");
     cb_BaudRate.Items.Add("4800");
     cb_BaudRate.Items.Add("9600");
     cb_BaudRate.Items.Add("19200");
     cb_BaudRate.Items.Add("38400");
     cb_BaudRate.Items.Add("57600");
     cb_BaudRate.Items.Add("115200");
 }
Ejemplo n.º 6
0
 private void mnuLaunchSetupg_Click(object sender, RoutedEventArgs e)
 {
     Com0comSetup.LaunchSetupg();
 }