private void PlayButtonClicked(object sender, EventArgs e) { // Run script and handle exceptions. ScriptExecuter.Execute( Editor.Text.Split('\n').ToList(), (ScriptExecuter.ScriptErrorType type, string message) => { // On exception, show toast message and log it. switch (type) { case ScriptExecuter.ScriptErrorType.SYNTAX_ERROR: ToastProvider.ShowToast("Syntax error in script. See logfile for details."); LoggerPage.instance.LogMessage("Syntax error in script: \n" + message, LoggerPage.MessageType.ERROR); break; case ScriptExecuter.ScriptErrorType.RUNTIME_ERROR: ToastProvider.ShowToast("Error while executing script. See logfile for details."); LoggerPage.instance.LogMessage("Error while executing script: \n" + message, LoggerPage.MessageType.ERROR); break; case ScriptExecuter.ScriptErrorType.INTERNAL_ERROR: ToastProvider.ShowToast("Internal error in scripting engine. See logfile for details."); LoggerPage.instance.LogMessage("Internal error while executing script: \n" + message, LoggerPage.MessageType.ERROR); break; case ScriptExecuter.ScriptErrorType.CONNECTION_ERROR: ToastProvider.ShowToast("No connection to Arduino. See logfile for details."); LoggerPage.instance.LogMessage("Script execution was stopped because there was no Arduino connection: \n" + message, LoggerPage.MessageType.WARNING); break; } LoggerPage.instance.LogMessage("While executing script " + title + ".lua"); } ); }
public string RunAttachable(ArduinoAttachable a, string data) { if (data == null) { data = ""; } string result = ""; ManualResetEvent evnt = new ManualResetEvent(false); connection.SendMessage( a.device, a.port, data, (string answer) => { result = answer; evnt.Set(); }, () => { ToastProvider.ShowToast("A request for attachable " + a.name + " timed out."); }, TimeSpan.FromMilliseconds(2500) ); evnt.WaitOne(); return(result); }
private void dialogImportTextureMap_FileOk(object sender, CancelEventArgs e) { int undoCount = UndoBackups.Count; // Load the texture-map from the PNG file but keep everything else ExecuteCommandSafe(new ImportTextureMap( _universe.Terrain, dialogImportTextureMap.FileName, _presenter.RebuildTerrain)); if (UndoBackups.Count > undoCount) { ToastProvider.ShowToast(Resources.DataImported); } }
private void dialogExportXml_FileOk(object sender, System.ComponentModel.CancelEventArgs e) { if (TemplateList.CheckedEntries.Count != 0) { TemplateList.CheckedEntries.ToList().SaveXml(dialogExportXml.FileName); } else if (TemplateList.SelectedEntry != null) { TemplateList.SelectedEntry.SaveXml(dialogExportXml.FileName); } ToastProvider.ShowToast(Resources.SavedFile); }
private void dialogExportTextureMap_FileOk(object sender, CancelEventArgs e) { try { // Save the texture-map to a PNG file _universe.Terrain.TextureMap.Save(dialogExportTextureMap.FileName); } #region Error handling catch (IOException ex) { Msg.Inform(this, Resources.FileNotSavable + "\n" + ex.Message, MsgSeverity.Warn); return; } catch (UnauthorizedAccessException ex) { Msg.Inform(this, Resources.FileNotSavable + "\n" + ex.Message, MsgSeverity.Warn); return; } #endregion ToastProvider.ShowToast(Resources.SavedFile); }