Exemplo n.º 1
0
 private void UserControl_Loaded(object sender, RoutedEventArgs e)
 {
     if (_loaded)
     {
         return;
     }
     PortConfig();
     HexInput.CreateDefault();
     _loaded = true;
 }
Exemplo n.º 2
0
 private void NextButton_Click(object sender, EventArgs e)
 {
     BytesNum               = (byte)BytesNumericUD.Value;
     RemainingNum           = BytesNum;
     BytesNumericUD.Visible = false;
     buf = new byte[BytesNum];
     BytesNumLabel.Text        = BytesNum.ToString();
     BytesLeftLabel.Text       = BytesNum.ToString();;
     BytesNumLabel.Visible     = true;
     MsgPanel.Visible          = true;
     NextButton.Visible        = false;
     HexInput.Controls[1].Text = "";
     HexInput.Focus();
 }
Exemplo n.º 3
0
 private void ClearOneByteButton_Click(object sender, EventArgs e)
 {
     if ((RemainingNum > 0) && (RemainingNum != BytesNum))
     {
         Array.Copy(buf, 0, buf, 0, buf.Length - 1);
         MsgScintilla.ReadOnly = false;
         MsgScintilla.Undo();
         MsgScintilla.ReadOnly     = true;
         RemainingNum             += 1;
         BytesLeftLabel.Text       = RemainingNum.ToString();
         HexInput.Controls[1].Text = "";
         HexInput.Focus();
     }
 }
Exemplo n.º 4
0
        private void SendData()
        {
            if (!_portopen)
            {
                return;
            }

            if (InputMode.SelectedIndex == 0)
            {
                if (RbASCII.IsChecked == true)
                {
                    byte[] b = StringToBytes(TbInput.Text);
                    _port.Write(b, 0, b.Length);
                    LbSend.Items.Add("Send text: " + TbInput.Text + "\r\n");
                }
                else
                {
                    string[] values = TbInput.Text.Split(' ');
                    if (RbByte.IsChecked == true)
                    {
                        List <byte> bval = new List <byte>();
                        try { foreach (var v in values)
                              {
                                  bval.Add(Convert.ToByte(v));
                              }
                        }
                        catch (Exception) { MessageBox.Show("Error parsing input", "Error", MessageBoxButton.OK); }
                        _port.Write(bval.ToArray(), 0, bval.Count);
                        LbSend.Items.Add("Send bytes: " + TbInput.Text);
                    }
                }
                if (CbClear.IsChecked == true)
                {
                    TbInput.Clear();
                }
            }
            else
            {
                byte[] data = HexInput.GetBytes();
                _port.Write(data, 0, data.Length);
                LbSend.Items.Add("Send bytes: " + ByteArrayToString(data));
                HexInput.CreateDefault();
            }
        }
Exemplo n.º 5
0
        private void InputByteButton_Click_1(object sender, EventArgs e)
        {
            if (RemainingNum > 0)
            {
                buf[BytesNum - RemainingNum] = (byte)HexInput.Value;
                RemainingNum--;
                MsgScintilla.ReadOnly = false;
                MsgScintilla.BeginUndoAction();
                if (count % 8 == 0)
                {
                    MsgScintilla.AppendText(((int)HexInput.Value).ToString("X") + "\r\n");
                    count = 1;
                }
                else
                {
                    count++;
                    MsgScintilla.AppendText(((int)HexInput.Value).ToString("X") + " ");
                }
                MsgScintilla.EndUndoAction();

                MsgScintilla.ReadOnly = true;
                BytesLeftLabel.Text   = RemainingNum.ToString();
                HexInput.Value        = 0;
                if (RemainingNum == 0)
                {
                    InputPanel.Visible     = false;
                    EndInputButton.Visible = true;
                }
                HexInput.Focus();
                HexInput.Controls[1].Text = "";
            }
            else
            {
                InputPanel.Visible     = false;
                EndInputButton.Visible = true;
            }
        }
Exemplo n.º 6
0
 void Awake()
 {
     boardManager = GetComponent<HexBoardManager>();
     hexInput = GetComponent<HexInput>();
     tileList = GetComponent<TileList>();
 }