public static void WriteError(string error, Exception e, string scriptName) { s_console.WriteLineLow(error + ":"); if (e != null) { if (e.Source == "IronPython") { if (e is IronPython.Runtime.Exceptions.PythonSyntaxErrorException) { IronPython.Runtime.Exceptions.PythonSyntaxErrorException ee = (IronPython.Runtime.Exceptions.PythonSyntaxErrorException)e; s_console.WriteLineLow("{0}({1},{2}): {3}", ee.FileName, ee.Line, ee.Column, ee.Message); } else { if (scriptName != null && scriptName.Length > 0) { s_console.WriteLineLow("{0}: {1}", scriptName, e.Message); } else { s_console.WriteLineLow(e.Message); } } } else { s_console.WriteLineLow(e.ToString()); } } }
private void assignButton_Click(object sender, EventArgs e) { if (listView.SelectedItems.Count == 0) { return; } ListViewItem item = listView.SelectedItems[0]; ScriptedKeyBinding binding = (ScriptedKeyBinding)item.Tag; if (m_currentKey != binding.Key && m_manager.IsKeyBound(m_currentKey)) { MessageBox.Show("Key already bound"); return; } binding.Key = m_currentKey; binding.BindingType = styleRadioButton1.Checked ? KeyBindingType.Send : KeyBindingType.Script; binding.Text = actionTextBox.Text; binding.Save = true; UpdateListViewItem(item); item.Selected = false; item.Selected = item.Focused = true; // updates the controls try { binding.Compile(); } catch (Exception exc) { if (exc.Source == "IronPython") { string str; if (exc is IronPython.Runtime.Exceptions.PythonSyntaxErrorException) { IronPython.Runtime.Exceptions.PythonSyntaxErrorException ee = (IronPython.Runtime.Exceptions.PythonSyntaxErrorException)exc; str = String.Format("{0}({1},{2}): {3}", ee.FileName, ee.Line, ee.Column, ee.Message); } else { str = exc.Message; } MessageBox.Show(this, str, "Failed to compile keybinding"); } else { throw; } } }