Пример #1
0
        // Creating the port button the screen, depending on the available port on the computer and the user chooses which port he's expecting
        // to read from. Device Manager/ Ports/ should tell you what you should pick
        private void CreateComPortsButtons()
        {
            // Get the ports from the Device Manager
            string[] ports = SerialProtocol.GetAvailablePorts();
            foreach (string port in ports)
            {
                // Create a button for each port
                var radioButton = new RadioButton();
                radioButton.Content = port;
                radioButton.Margin  = new Thickness(10, 0, 10, 0);

                radioButton.Checked  += RadioButtonOnChecked;
                radioButton.GroupName = "Ports";
                radioButton.IsChecked = false;

                // Add it to the UI
                mx_comPortsPanels.Children.Add(radioButton);
            }
        }
Пример #2
0
        // call back function when the port desired is selected
        private void RadioButtonOnChecked(object sender, RoutedEventArgs e)
        {
            RadioButton radioButton = sender as RadioButton;

            // remove the buttons from the screen
            // TODO: Delete those buttons from memory if not needed at all
            mx_comPortsPanels.Visibility = Visibility.Collapsed;

            if (radioButton != null)
            {
                // open the serial port with the COM selected
                m_serialProt = new SerialProtocol(radioButton.Content.ToString());

                // create the timer that updates the location of the marker
                m_uiTimer.Tick += (o, args) => UpdateMarkerOnTheMap();
                // Set the timer interval in MS
                m_uiTimer.Interval = new TimeSpan(0, 0, 0, 0, 900);
                m_uiTimer.Start();
            }
        }