コード例 #1
0
        private void konekButton_Click(object sender, RoutedEventArgs e)
        {
            Komunikasi.Default.BaudRate  = Convert.ToInt32(baudCombo.SelectedItem);
            Komunikasi.Default.PortName  = Convert.ToString(portCombo.SelectedItem);
            Komunikasi.Default.DataBits  = Convert.ToUInt16(databitCombo.SelectedItem);
            Komunikasi.Default.StopBits  = (StopBits)Enum.Parse(typeof(StopBits), stopbitCombo.SelectedItem.ToString());
            Komunikasi.Default.Handshake = (Handshake)Enum.Parse(typeof(Handshake), handshakeCombo.SelectedItem.ToString());
            Komunikasi.Default.Parity    = (Parity)Enum.Parse(typeof(Parity), parityCombo.SelectedItem.ToString());
            Komunikasi.Default.Launcher  = Convert.ToString(portLauncher.SelectedItem);
            interval = Convert.ToInt32(Convert.ToString(delayCombo.SelectedItem).Remove(5));

            //if (!Komunikasi.Default.terkoneksi)
            //{
            try
            {
                konekin.NewSerialDataReceived += konekin_NewSerialDataReceived;
                konekin.buka();
                if (Komunikasi.Default.terkoneksi)
                {
                    //btnPutus.Content = "Terhubung ke " + Komunikasi.Default.PortName;


                    stopwatch.Reset();
                    ClearLog();
                }
                else
                {
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            //}

            //gridUtama.Visibility = Visibility.Visible;
            //gridKoneksi.Visibility = Visibility.Hidden;
        }