private void KHR_1HV_ToolForm_Load(object sender, EventArgs e) { toolForm = (KHR_1HV_ToolMenu)sender; for (int i = 0; i < StaticUtilities.numberOfMotions; i++) { comboBox1.Items.Add(string.Format("{0} {1}", Roboard.DataTable.motionDataTable[i, 0], Roboard.DataTable.motionDataTable[i, 3])); } if (selectedMotionIndex >= 0) comboBox1.SelectedIndex = selectedMotionIndex; else comboBox1.SelectedIndex = -1; }
// Delete a motion // private void tsDelete_Click(object sender, EventArgs e) { if (!Roboard.DataTable.Done) return; KHR_1HV_ToolMenu myDelete = new KHR_1HV_ToolMenu(); myDelete.Text = "Delete"; myDelete.Label = "Select the motion or scenario to be deleted"; myDelete.ShowDialog(); // Need to rebuild the ListView // if (myDelete.DialogResult == DialogResult.OK) this.constructDataTable(); }
private void ToolStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { Roboard.NetworkClient.messageHandler -= new NetworkClient.NewMessageEventHandler(NetworkClient_messageHandler); ToolStripItem item = e.ClickedItem; // parse the string sender to enum eToolStripMenu tsMenuNum = (eToolStripMenu)Enum.Parse(typeof(eToolStripMenu), item.Text.ToUpper()); switch (tsMenuNum) { // // MAIN MENU // case eToolStripMenu.LOAD: this.openFD.Title = "Open a Roboard Motion File"; this.openFD.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal); this.openFD.FileName = string.Empty; this.openFD.Filter = "Roboard Motion File (RMF)|*.RMF|Kondo RCB files|*.RCB|All files|*.*"; if (this.openFD.ShowDialog() != DialogResult.Cancel) { fileName = this.openFD.SafeFileName; chosenFile = this.openFD.FileName; currentMotion = new IniFile(chosenFile); if (currentMotion.Exists()) { currentMotion.Load(); // check of de geladen rcb file wel een goede is. this.tcDataSheet.TabPages[0].Text = "EDIT " + currentMotion["GraphicalEdit"]["Name"]; this.DataSheet.Size = new Size(Convert.ToInt32(currentMotion["GraphicalEdit"]["Width"]), Convert.ToInt32(currentMotion["GraphicalEdit"]["Height"])); // Get file extension string fileExtension = Path.GetExtension(chosenFile); if (fileExtension == ".RCB") // This file needs to be converted. // convert { convertMotionFile(); } // teken de motion. } } break; case eToolStripMenu.SAVE: this.saveFD.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Personal); this.saveFD.Title = "Save the Roboard Motion File"; this.saveFD.AddExtension = true; this.saveFD.DefaultExt = ".RMF"; this.saveFD.FileName = chosenFile; this.saveFD.Filter = "Roboard Motion File (RMF) files|*.RMF|All files|*.*"; if (this.saveFD.ShowDialog() != DialogResult.Cancel) { chosenFile = saveFD.FileName; currentMotion.FileName = chosenFile; currentMotion.Save(); } break; case eToolStripMenu.PROPERTIES: KHR_1HV_Properties propForm = new KHR_1HV_Properties(); propForm.sizeWidth = this.DataSheet.Width; propForm.sizeHeight = this.DataSheet.Height; propForm.GridX = this.KHR1HV_Ini.GridWidth; propForm.GridY = this.KHR1HV_Ini.GridHeight; propForm.ToolMenu = this.tsToolMenu.Visible; propForm.PartsMenu = this.tsObjectMenu.Visible; propForm.CommSettings = this.tsCommunicationsMenu.Visible; propForm.CommandMenu = this.tsCommandMenu.Visible; propForm.ShowDialog(); if (propForm.DialogResult == DialogResult.OK) { this.DataSheet.Size = new System.Drawing.Size(propForm.sizeWidth, propForm.sizeHeight); this.currentMotion[Roboard.StaticUtilities.SectionGraphicalEdit][Roboard.StaticUtilities.GraphicalEditWidth] = propForm.sizeWidth.ToString(); this.currentMotion[Roboard.StaticUtilities.SectionGraphicalEdit][Roboard.StaticUtilities.GraphicalEditHeight] = propForm.sizeHeight.ToString(); this.tsToolMenu.Visible = propForm.ToolMenu; this.tsObjectMenu.Visible = propForm.PartsMenu; this.tsCommunicationsMenu.Visible = propForm.CommSettings; this.tsCommandMenu.Visible = propForm.CommandMenu; this.KHR1HV_Ini.GridWidth = propForm.GridX; this.KHR1HV_Ini.GridHeight = propForm.GridY; } break; case eToolStripMenu.INFORMATION: if (this.RoboardConnected) { KHR_1HV_Information InformationForm = new KHR_1HV_Information(); InformationForm.ShowDialog(); } break; case eToolStripMenu.EXIT: if (exitForm() == true) { Application.Exit(); } break; // // COMMAND MENU // case eToolStripMenu.TRIM: if (RoboardConnected) { // get trim values from the server KHR_1HV_Trim secondForm = new KHR_1HV_Trim(); secondForm.ShowDialog(); } break; case eToolStripMenu.OPTION: if (RoboardConnected) { KHR_1HV_Options optionsForm = new KHR_1HV_Options(); optionsForm.ShowDialog(); } break; case eToolStripMenu.ANALOG: if (RoboardConnected) { KHR_1HV_Sensors AnalogForm = new KHR_1HV_Sensors(); AnalogForm.ShowDialog(); } break; case eToolStripMenu.ICS: break; case eToolStripMenu.RECEIVER: if (RoboardConnected) { KHR_1HV_XBox360Controller myXBox360 = new KHR_1HV_XBox360Controller(); myXBox360.ShowDialog(); } break; case eToolStripMenu.TABLE: if (RoboardConnected) { KHR_1HV_DataTable myDataTable = new KHR_1HV_DataTable(); myDataTable.ShowDialog(); this.MotionDataTableLoaded = myDataTable.Done; } break; //============================================================================= // OBJECT MENU //============================================================================= case eToolStripMenu.SELECT: tsSelect.CheckState = CheckState.Checked; tsPos.CheckState = CheckState.Unchecked; tsSet.CheckState = CheckState.Unchecked; tsMix.CheckState = CheckState.Unchecked; tsCompare.CheckState = CheckState.Unchecked; tsFlowWiring.CheckState = CheckState.Unchecked; tsBranchWiring.CheckState = CheckState.Unchecked; break; case eToolStripMenu.GRID: break; case eToolStripMenu.STARTFLAG: break; case eToolStripMenu.POSITION: tsSelect.CheckState = CheckState.Unchecked; tsPos.CheckState = CheckState.Checked; tsSet.CheckState = CheckState.Unchecked; tsMix.CheckState = CheckState.Unchecked; tsCompare.CheckState = CheckState.Unchecked; tsFlowWiring.CheckState = CheckState.Unchecked; tsBranchWiring.CheckState = CheckState.Unchecked; break; case eToolStripMenu.SET: tsSelect.CheckState = CheckState.Unchecked; tsPos.CheckState = CheckState.Unchecked; tsSet.CheckState = CheckState.Checked; tsMix.CheckState = CheckState.Unchecked; tsCompare.CheckState = CheckState.Unchecked; tsFlowWiring.CheckState = CheckState.Unchecked; tsBranchWiring.CheckState = CheckState.Unchecked; break; case eToolStripMenu.MIX: tsSelect.CheckState = CheckState.Unchecked; tsPos.CheckState = CheckState.Unchecked; tsSet.CheckState = CheckState.Unchecked; tsMix.CheckState = CheckState.Checked; tsCompare.CheckState = CheckState.Unchecked; tsFlowWiring.CheckState = CheckState.Unchecked; tsBranchWiring.CheckState = CheckState.Unchecked; break; case eToolStripMenu.COMPARE: tsSelect.CheckState = CheckState.Unchecked; tsPos.CheckState = CheckState.Unchecked; tsSet.CheckState = CheckState.Unchecked; tsMix.CheckState = CheckState.Unchecked; tsCompare.CheckState = CheckState.Checked; tsFlowWiring.CheckState = CheckState.Unchecked; tsBranchWiring.CheckState = CheckState.Unchecked; break; case eToolStripMenu.FLOWWIRING: tsSelect.CheckState = CheckState.Unchecked; tsPos.CheckState = CheckState.Unchecked; tsSet.CheckState = CheckState.Unchecked; tsMix.CheckState = CheckState.Unchecked; tsCompare.CheckState = CheckState.Unchecked; tsFlowWiring.CheckState = CheckState.Checked; tsBranchWiring.CheckState = CheckState.Unchecked; break; case eToolStripMenu.BRANCHWIRING: tsSelect.CheckState = CheckState.Unchecked; tsPos.CheckState = CheckState.Unchecked; tsSet.CheckState = CheckState.Unchecked; tsMix.CheckState = CheckState.Unchecked; tsCompare.CheckState = CheckState.Unchecked; tsFlowWiring.CheckState = CheckState.Unchecked; tsBranchWiring.CheckState = CheckState.Checked; break; case eToolStripMenu.COMPILE: break; //============================================================================= // TOOL MENU //============================================================================= case eToolStripMenu.HOMEPOSITION: if (RoboardConnected) { } break; case eToolStripMenu.TRIMPOSITION: if (RoboardConnected) { } break; case eToolStripMenu.WRITE: if ((RoboardConnected) && (MotionDataTableLoaded)) { KHR_1HV_ToolMenu myWrite = new KHR_1HV_ToolMenu(); myWrite.Text = "Write"; myWrite.Label = "Select Roboard memory location"; myWrite.Motion = currentMotion; myWrite.ShowDialog(); } break; case eToolStripMenu.READ: if ((RoboardConnected) && (MotionDataTableLoaded)) { KHR_1HV_ToolMenu myRead = new KHR_1HV_ToolMenu(); myRead.Text = "Read"; myRead.Label = "Select Roboard memory location"; myRead.ShowDialog(); if (myRead.Motion != null) { currentMotion = myRead.Motion; this.tcDataSheet.TabPages[0].Text = "EDIT " + currentMotion["GraphicalEdit"]["Name"]; this.DataSheet.Size = new Size(Convert.ToInt32(currentMotion["GraphicalEdit"]["Width"]), Convert.ToInt32(currentMotion["GraphicalEdit"]["Height"])); // teken de motion } } break; case eToolStripMenu.DELETE: if ((RoboardConnected) && (MotionDataTableLoaded)) { KHR_1HV_ToolMenu myDelete = new KHR_1HV_ToolMenu(); myDelete.Text = "Delete"; myDelete.Label = "Select the motion or scenario to be deleted"; myDelete.ShowDialog(); } break; case eToolStripMenu.STOP: if (RoboardConnected) { ToolMenu.Stop(); } break; case eToolStripMenu.PAUSE: if (RoboardConnected) { ToolMenu.Pause(); } break; case eToolStripMenu.PLAY: if ((RoboardConnected) && (MotionDataTableLoaded)) { KHR_1HV_ToolMenu myPlay = new KHR_1HV_ToolMenu(); myPlay.Text = "Play"; myPlay.Label = "Select the motion or scenario to play"; myPlay.SelectedMotionIndex = 0; myPlay.ShowDialog(); } break; default: break; } Roboard.NetworkClient.messageHandler += new NetworkClient.NewMessageEventHandler(NetworkClient_messageHandler); }