public static DialogResult Show(GlobalVariable variable, Game game) { GlobalVariableDialog dialog = new GlobalVariableDialog(variable, game); DialogResult result = dialog.ShowDialog(); dialog.Dispose(); return result; }
public GlobalVariables(XmlNode node) { foreach (XmlNode childNode in SerializeUtils.GetChildNodes(node, "Variables")) { GlobalVariable newVariable = new GlobalVariable(childNode); _variables.Add(newVariable.Name, newVariable); } }
private void AddNewVariableToList(GlobalVariable variable) { _variables.Add(variable); int addAtIndex = 0; if (lvwWords.SelectedIndices.Count > 0) { addAtIndex = lvwWords.SelectedIndices[0] + 1; } ListViewItem addedItem = lvwWords.Items.Insert(addAtIndex, CreateListItemFromVariable(variable)); addedItem.Selected = true; addedItem.EnsureVisible(); OnGlobalVariableChanged(); }
public GlobalVariableDialog(GlobalVariable variable, Game game) { InitializeComponent(); _variable = variable; _game = game; PopulateTypeList(); txtName.Text = variable.Name ?? string.Empty; txtDefaultValue.Text = variable.DefaultValue ?? string.Empty; foreach (GlobalVariableType varType in cmbType.Items) { if (varType.TypeName == variable.Type) { cmbType.SelectedItem = varType; break; } } Utilities.CheckLabelWidthsOnForm(this); }
public void VariableRenamed(GlobalVariable variable, string oldName) { _variables.Remove(oldName); _variables.Add(variable.Name, variable); }
public void Remove(GlobalVariable variable) { _variables.Remove(variable.Name); }
public void Add(GlobalVariable variable) { _variables.Add(variable.Name, variable); }
private void ContextMenuEventHandler(object sender, EventArgs e) { ToolStripMenuItem item = (ToolStripMenuItem)sender; GlobalVariable selectedVariable = null; if (lvwWords.SelectedItems.Count > 0) { selectedVariable = ((GlobalVariable)lvwWords.SelectedItems[0].Tag); } if ((item.Name == MENU_ITEM_EDIT_WORD) && (selectedVariable != null)) { EditSelectedVariable(selectedVariable); } else if (item.Name == MENU_ITEM_ADD_WORD) { GlobalVariable variable = new GlobalVariable(); if (GlobalVariableDialog.Show(variable, _game) == DialogResult.OK) { AddNewVariableToList(variable); } } else if (item.Name == MENU_ITEM_DELETE_WORD) { if (Factory.GUIController.ShowQuestion("Are you sure you want to remove the variable '" + selectedVariable.Name + "'? If you are using it in your scripts, your game will no longer compile.", MessageBoxIcon.Warning) == DialogResult.Yes) { lvwWords.Items.RemoveAt(lvwWords.SelectedIndices[0]); _variables.Remove(selectedVariable); OnGlobalVariableChanged(); } } }
private void EditSelectedVariable(GlobalVariable variable) { string nameWas = variable.Name; if (GlobalVariableDialog.Show(variable, _game) == DialogResult.OK) { if (variable.Name != nameWas) { _variables.VariableRenamed(variable, nameWas); } lvwWords.SelectedItems[0].SubItems[0].Text = variable.Name; lvwWords.SelectedItems[0].SubItems[1].Text = variable.Type; lvwWords.SelectedItems[0].SubItems[2].Text = variable.DefaultValue; OnGlobalVariableChanged(); } }
private ListViewItem CreateListItemFromVariable(GlobalVariable variable) { ListViewItem newItem = new ListViewItem(new string[] { variable.Name, variable.Type, variable.DefaultValue }); newItem.Tag = variable; return newItem; }
private void FindSelectedVariable(GlobalVariable variable) { TextProcessing.FindAllUsages findAllUsages = new TextProcessing.FindAllUsages(null, null, null, AGSEditor.Instance); findAllUsages.Find(null, variable.Name); }