void edit_button_Click(object sender, RoutedEventArgs e) { int index = this.ids.SelectedIndex; if (index >= 0) { ID idToEdit = Model.Instance.ActiveMap.Ids[index]; ScriptEditWindow editor = new ScriptEditWindow(idToEdit.Script ?? ""); editor.ShowDialog(); idToEdit.Script = string.IsNullOrEmpty(editor.FinalScript) ? null : editor.FinalScript; } }