示例#1
0
 private void ComPortBox_Closed(object sender, EventArgs e)
 {
     if (ComPortBox.SelectedItem == null)
     {
         return;
     }
     Settings.Com = ComPortBox.SelectedItem.ToString();
     ComPort.InitComPort(Settings.Com, Settings.BaudRate);
 }
示例#2
0
 private void BaudrateComboBox_DropDownClosed(object sender, EventArgs e)
 {
     if (BaudrateComboBox.SelectedItem == null)
     {
         return;
     }
     Settings.BaudRate = Convert.ToInt32(BaudrateComboBox.SelectedItem);
     ComPort.InitComPort(Settings.Com, Settings.BaudRate);
 }
示例#3
0
        public MainWindow()
        {
            InitializeComponent();
            Closing += MainWindow_Closing;

            #region COM_INIT and COM_EVENTS
            ComPort.NewDataRecived    += rdata => WriteLog(rdata, true);
            ComPort.NewDataRecived    += rdata => Manager(rdata);
            ComPort.NewDataTransfered += tdata => WriteLog(tdata, false);
            ComPortBox.Items.Add(Settings.Com);
            ComPortBox.SelectedIndex = 0;
            ComPort.InitComPort(Settings.Com, Settings.BaudRate);
            #endregion

            #region SendTimerInit
            System.Windows.Threading.DispatcherTimer interrogatorTimer = new System.Windows.Threading.DispatcherTimer();
            interrogatorTimer.Tick    += new EventHandler(DataTransferTimer_Tick);
            interrogatorTimer.Interval = new TimeSpan(0, 0, 0, 0, 250); //инит таймера отправки: дни; часы; минуты; секунды; милсек.
            interrogatorTimer.Start();
            #endregion
        }