private void runPrograms(dsThingPrograms.thingsRow curThing, string eventName = null) { foreach (dsThingPrograms.programsRow program in curThing.GetChildRows("FK_things_programs")) { if (program.enabled && (eventName == null || program.trigger_event == eventName)) { Process progProcess = new Process(); try { progProcess.StartInfo.UseShellExecute = false; // You can start any process, HelloWorld is a do-nothing example. progProcess.StartInfo.FileName = program.filePath; //myProcess.StartInfo.CreateNoWindow = true; progProcess.Start(); // This code assumes the process you are starting will terminate itself. // Given that is is started without a window so you cannot terminate it // on the desktop, it must terminate itself or you can do it programmatically // from this application using the Kill method. } catch (Exception e) { string errorHeader; if (program.name == null || program.name == "") { errorHeader = "Problem launching script/program at " + program.filePath; } else { errorHeader = "Problem launching " + program.name; } MessageBox.Show(errorHeader + ":\n" + e.Message, Globals.errorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private void addOnRemoveProgram() { dsThingPrograms.thingsRow curThing = (dsThingPrograms.thingsRow)((DataRowView)thingsBindingSource.Current).Row; dsThingPrograms.programs.AddprogramsRow(wtbAddOnRemoveName.Text, wtbAddOnRemovePath.Text, curThing, "onRemove", true); wtbAddOnRemoveName.Text = ""; wtbAddOnRemovePath.Text = ""; dsThingPrograms.programs.WriteXml(Globals.programsXmlPath, System.Data.XmlWriteMode.WriteSchema); }
private void addOnPlaceProgram() { dsThingPrograms.thingsRow curThing = (dsThingPrograms.thingsRow)((DataRowView)thingsBindingSource.Current).Row; String on_event = (curThing.name == "mirConnected" || curThing.name == "mirDisconnected") ? "" : "onPlace"; dsThingPrograms.programs.AddprogramsRow(wtbAddOnPlaceName.Text, wtbAddOnPlacePath.Text, curThing, on_event, true); wtbAddOnPlaceName.Text = ""; wtbAddOnPlacePath.Text = ""; dsThingPrograms.programs.WriteXml(Globals.programsXmlPath, System.Data.XmlWriteMode.WriteSchema); }
private void updateCurThing(string RFID, string eventName = null) { // update placedRFIDs if (eventName == "onRemove" && placedRFIDs.Contains(RFID)) { placedRFIDs.Remove(RFID); } else if (eventName == "onPlace") { addUnique(placedRFIDs, RFID); } else if (RFID == "mirDisconnected") { placedRFIDs.ForEach((placedRFID) => { addUnique(prevPlacedRFIDs, (string)placedRFID.Clone()); }); placedRFIDs.Clear(); } else if (RFID == "mirConnected") { prevPlacedRFIDs.ForEach((placedRFID) => { addUnique(placedRFIDs, (string)placedRFID.Clone()); }); prevPlacedRFIDs.Clear(); } updateImageDeleteObject(); updateSafeToDisableChoreo(RFID); dsThingPrograms.thingsRow curThing = this.dsThingPrograms.things.FindByRFID(RFID); if (eventName != null && curThing == null) { curThing = this.dsThingPrograms.things.NewthingsRow(); curThing.RFID = RFID; curThing.name = "Unnamed Object " + curThing.id; this.dsThingPrograms.things.Rows.Add(curThing); this.dsThingPrograms.things.WriteXml(Globals.thingsXmlPath, System.Data.XmlWriteMode.WriteSchema); } if (eventName != "onRemove") { cbThingNames.SelectedValue = curThing.RFID; } if (eventName != "mirConnected") { updatePlacedThings(); } if (!dontRunProgs) { runPrograms(curThing, eventName); } }
private void imageDeleteObject_Click(object sender, EventArgs e) { dsThingPrograms.thingsRow curThing = this.dsThingPrograms.things.FindByRFID(curRFID); foreach (dsThingPrograms.programsRow program in curThing.GetChildRows("FK_things_programs")) { this.dsThingPrograms.programs.Rows.Remove(program); } this.dsThingPrograms.things.Rows.Remove(curThing); this.dsThingPrograms.things.WriteXml(Globals.thingsXmlPath, XmlWriteMode.WriteSchema); this.dsThingPrograms.programs.WriteXml(Globals.programsXmlPath, XmlWriteMode.WriteSchema); }