Пример #1
0
        private void setButton_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            int correct = 0;

            byte[] codeDown = BlueBotCompiler.Compile(rtbCommandDown.Text, out correct);
            if (codeDown == null)
            {
                rtbCommandDown.SelectAll();
                rtbCommandDown.SelectionBackColor = Color.Transparent;
                rtbCommandDown.Select(correct, 1);
                rtbCommandDown.SelectionBackColor = Color.Red;
                this.Enabled = true;
                return;
            }
            byte[] codeUp = BlueBotCompiler.Compile(rtbCommandUp.Text, out correct);
            if (codeUp == null)
            {
                rtbCommandUp.SelectAll();
                rtbCommandUp.SelectionBackColor = Color.Transparent;
                rtbCommandUp.Select(correct, 1);
                rtbCommandUp.SelectionBackColor = Color.Red;
                this.Enabled = true;
                return;
            }
            editedKey.Button.Text = kbEdited.Text;
            editedKey.CommandDown = rtbCommandDown.Text;
            editedKey.CodeDown    = codeDown;
            editedKey.CommandUp   = rtbCommandUp.Text;
            editedKey.CodeUp      = codeUp;
            this.Close();
        }
Пример #2
0
        //Przygotowanie danych do wysłania
        private void SendCommand(string buffer)
        {
            if (serial.IsOpen || testCOM_ON)
            {
                int    correct;
                byte[] code = new byte[] { };
                if (buffer.Length > 0)
                {
                    code = BlueBotCompiler.Compile(buffer, out correct);
                }
                if (code == null)
                {
                    ConsoleMessage(rtbConsole, "Wystąpił błąd przy kompilacji!", System.Drawing.Color.Red);
                }
                else
                {
                    foreach (byte b in code)
                    {
                        serialPortBuffer.Enqueue(b);
                    }
                }

                if (serialPortBuffer.Count == 0)
                {
                    return;
                }

                if (serialPortIsBusy || serial.IsOpen && (serial.BytesToRead > 0 || serial.BytesToWrite > 0))
                {
                    return;
                }
                stateBox.BackColor = stateBox1.BackColor = System.Drawing.Color.Yellow;
                butSend.Enabled    = false;
                rtbSend.Enabled    = false;
                serialPortIsBusy   = true;

                if (cbHex.Checked)
                {
                    foreach (byte s in serialPortBuffer)
                    {
                        ConsoleMessage(rtbConsole, s.ToString() + " ", System.Drawing.Color.DarkGray, s == serialPortBuffer.Last());
                    }
                }
                else
                {
                    ConsoleMessage(rtbConsole, BlueBotCompiler.Decompile(serialPortBuffer.ToArray()), System.Drawing.Color.Black);
                }
                backgroundSender.RunWorkerAsync(); //tworzy wątek wysyłający dane
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Aby wysłać dane musisz najpierw ustanowić połączenie!");
            }
        }
Пример #3
0
        public Form2(Form1 main, ButtonGUI _editedButton)
        {
            InitializeComponent();
            this.comboBox1.Items.AddRange(BlueBotCompiler.GetFunctions());
            this.comboBox2.Items.AddRange(BlueBotCompiler.GetVariables());

            editedKey                = _editedButton;
            this.kbEdited.Text       = editedKey.Button.Text;
            this.rtbCommandDown.Text = editedKey.CommandDown;
            this.rtbCommandUp.Text   = editedKey.CommandUp;

            changeKey  = false;
            changeSign = false;
            isActiveUp = false;
        }
Пример #4
0
        //KONSTRUKTOR OKIENKA
        public Form1()
        {
            //Zainicjowanie okienka
            InitializeComponent();
            FormGraph_HideEditMenu();

            //Załadowanie biblioteki BlueBoard
            BlueBotCompiler.LoadLibrary(@"C:\Users\Admin\Documents\Arduino\AlphaBot\BlueBot\Names.h");
            this.comboBox1.Items.AddRange(BlueBotCompiler.GetVariables());
            this.comboBox2.Items.AddRange(BlueBotCompiler.GetFunctions());

            //Inicjalizacja obiektu oraz eventów do obsługi połączenia (odbierania i wysyłania danych)
            InitializeSerialPort();

            //Inicjalizacja obsługi klawiatury i GUI
            InitializeGUI();
        }
Пример #5
0
        public ButtonGUI(Keys _key,
                         string _button,
                         Form1 _form,
                         GroupBox _groupBox,
                         Point _location,
                         string _commandDown,
                         string _commandUp) : base()
        {
            Key         = _key;
            Location    = _location;
            CommandUp   = _commandUp;
            CommandDown = _commandDown;
            Element     = 'B';
            isPressed   = false;

            Button = new Button();
            _groupBox.Controls.Add(Button);
            Button.Text     = _button;
            Button.Anchor   = System.Windows.Forms.AnchorStyles.None;
            Button.Font     = new System.Drawing.Font("Microsoft Sans Serif", 18F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
            Button.Margin   = new System.Windows.Forms.Padding(0);
            Button.Size     = new Size(PanelGUI.CellSize.Width - 4, PanelGUI.CellSize.Height - 4);
            Button.TabIndex = 0;
            Button.UseVisualStyleBackColor = true;
            Button.Click += new System.EventHandler(_form.kbButton_Click);

            int correct;

            CodeUp = BlueBotCompiler.Compile(CommandUp, out correct);
            if (CodeUp == null)
            {
                CommandUp = String.Empty; CodeUp = new byte[] { 0 };
            }
            CodeDown = BlueBotCompiler.Compile(CommandDown, out correct);
            if (CodeDown == null)
            {
                CommandDown = String.Empty; CodeDown = new byte[] { 0 };
            }
        }