private void FormGraph_tabGUI(object sender, EventArgs e) { var size = tabGUI.Size; var bounds = new Rectangle(10, 43, size.Width - 9, size.Height - 8); int halfWidth = size.Width / 2 - 13; int quarterWidth = halfWidth / 2 - 4; int oneSixthWidth = halfWidth / 3 - 4; int editPanel = (editKeys) ? 45 : 0; gbGraphics.Width = halfWidth; gbPanel.Width = halfWidth; gbPanel.Location = new Point(bounds.Width - gbPanel.Width, bounds.Y); gbGraphics.Location = new Point(bounds.X, bounds.Y); bRestart.Width = quarterWidth; bEdit.Width = quarterWidth; bRestart.Location = new Point(bounds.X, bRestart.Location.Y); bEdit.Location = new Point(bounds.X + gbGraphics.Width - bEdit.Width, bEdit.Location.Y); bAdd.Width = oneSixthWidth; cbAdd.Width = oneSixthWidth - 2; bSave.Width = oneSixthWidth; bLoad.Width = oneSixthWidth; bAdd.Location = new Point(bounds.X, bAdd.Location.Y); cbAdd.Location = new Point(bounds.X + 1, cbAdd.Location.Y); bLoad.Location = new Point(bounds.X + gbGraphics.Width - bLoad.Width, bLoad.Location.Y); bSave.Location = new Point((bAdd.Location.X + bLoad.Location.X) / 2, bSave.Location.Y); PanelGUI.Update(); if (editKeys) { FormGraph_ShowPanelBackground(); } }
//Inicjalizacja GUI public void InitializeGUI() { //Timer klawiatury kbTimer = new System.Windows.Forms.Timer(); kbTimer.Interval = 100; kbTimer.Tick += new EventHandler(SerialPortCheck); kbTimer.Start(); //Utworzenie klawiatury PanelGUI.Panel = gbPanel; PanelGUI.Elements = new ArrayList(); new ButtonGUI(Keys.Divide, "↶", this, gbPanel, new System.Drawing.Point(0, 0), "SetParam 21=40; SetParam SERVO_UPDATE=6; CalcParams SERVO_ANGLE=SERVO_ANGLE - 21; UpdateServo;", ""); new ButtonGUI(Keys.Add, "⇈", this, gbPanel, new System.Drawing.Point(1, 0), "SetParam MOT_SPEED=240; SetSpeed;", "SetParam MOT_SPEED=200; SetSpeed;"); new ButtonGUI(Keys.Multiply, "↷", this, gbPanel, new System.Drawing.Point(2, 0), "SetParam 21=40; SetParam SERVO_UPDATE=6; CalcParams SERVO_ANGLE=SERVO_ANGLE + 21; UpdateServo;", ""); new ButtonGUI(Keys.NumPad7, "↰", this, gbPanel, new System.Drawing.Point(0, 1), "SetParam MOT_DIRECTION=20; SetDirection;", "SetParam MOT_DIRECTION=0; SetDirection;"); new ButtonGUI(Keys.NumPad8, "↑", this, gbPanel, new System.Drawing.Point(1, 1), "SetParam MOT_DIRECTION=0; SetDirection;", "MotorBrake"); new ButtonGUI(Keys.NumPad9, "↱", this, gbPanel, new System.Drawing.Point(2, 1), "SetParam MOT_DIRECTION=340; SetDirection;", "SetParam MOT_DIRECTION=0; SetDirection;"); new ButtonGUI(Keys.NumPad4, "←", this, gbPanel, new System.Drawing.Point(0, 2), "SetParam MOT_DIRECTION=45; SetDirection;", "SetParam MOT_DIRECTION=0; SetDirection;"); new ButtonGUI(Keys.NumPad5, "X", this, gbPanel, new System.Drawing.Point(1, 2), "MotorBrake", ""); new ButtonGUI(Keys.NumPad6, "→", this, gbPanel, new System.Drawing.Point(2, 2), "SetParam MOT_DIRECTION=315; SetDirection;", "SetParam MOT_DIRECTION=0; SetDirection;"); new ButtonGUI(Keys.NumPad1, "↲", this, gbPanel, new System.Drawing.Point(0, 3), "SetParam MOT_DIRECTION=135; SetDirection;", "SetParam MOT_DIRECTION=180; SetDirection;"); new ButtonGUI(Keys.NumPad2, "↓", this, gbPanel, new System.Drawing.Point(1, 3), "SetParam MOT_DIRECTION=180; SetDirection;", "MotorBrake; SetParam MOT_DIRECTION=0; SetDirection;"); new ButtonGUI(Keys.NumPad3, "↳", this, gbPanel, new System.Drawing.Point(2, 3), "SetParam MOT_DIRECTION=225; SetDirection;", "SetParam MOT_DIRECTION=180; SetDirection;"); PanelGUI.Update(); editKeys = false; addingItemsGUI = false; }
private void gbPanel_Click(object sender, EventArgs e) { if (addingItemsGUI) { Point cell = PanelGUI.GetCell(Cursor.Position); labelTest.Text = "zle"; //switch (cbAdd.SelectedItem.ToString()) //{ // case "-": // break; // case "Przycisk": // new ButtonGUI(Keys.F1, String.Empty, this, gbPanel, cell, string.Empty, string.Empty); // break; // case "Suwak": // break; // case "Wartość": // break; // default: // bAdd.Text = "err"; // break; //} //PanelGUI.Update(); } }