protected virtual void Add(string attributeName, Func <object> createAttributeValue) { if (attributeName.Length == 0) { PopupEditors.EditStringResult result = PopupEditors.EditString(L.T("EditorEnterNameAttribute"), string.Empty); if (result.Cancelled) { return; } attributeName = result.Result; } bool setSelection = true; if (!lstAttributes.Items.ContainsKey(attributeName)) { m_controller.StartTransaction(string.Format("Add '{0}' attribute", attributeName)); ValidationResult setAttrResult = m_data.SetAttribute(attributeName, createAttributeValue()); if (!setAttrResult.Valid) { PopupEditors.DisplayValidationError(setAttrResult, attributeName, "Unable to add attribute"); setSelection = false; } m_controller.EndTransaction(); } if (setSelection) { lstAttributes.Items[attributeName].Selected = true; lstAttributes.SelectedItems[0].EnsureVisible(); } }
private void toolbar_AddClicked() { if (m_data.ReadOnly) { return; } var result = PopupEditors.EditString(m_helper.ControlDefinition.GetString("editprompt"), string.Empty); if (result.Cancelled) { return; } if (!ValidateInput(result.Result)) { return; } if (m_list == null) { CurrentList = m_helper.Controller.CreateNewEditableList(m_data.Name, m_helper.ControlDefinition.Attribute, result.Result, true); } else { PrepareForEditing(); m_list.Add(result.Result); } }
private void EditCurrentSelection() { if (listBox.SelectedItem == null) { return; } if (m_data.ReadOnly) { return; } EditableListItem <string> currentSelection = (EditableListItem <string>)listBox.SelectedItem; int index = listBox.SelectedIndex; var result = PopupEditors.EditString(m_helper.ControlDefinition.GetString("editprompt"), currentSelection.Value); if (result.Cancelled) { return; } if (result.Result == currentSelection.Value) { return; } if (!ValidateInput(result.Result)) { return; } PrepareForEditing(); m_list.Update(index, result.Result); }
public void DoEditKey(string key, int index) { var newKey = PopupEditors.EditString(m_controlData.GetString("keyprompt"), key, GetAutoCompleteList()); if (newKey.Cancelled || newKey.Result == key) { return; } if (!ValidateInput(newKey.Result)) { return; } m_controller.StartTransaction(string.Format("Update key '{0}' to '{1}'", key, newKey.Result)); m_list.ChangeKey(key, newKey.Result); m_controller.EndTransaction(); }
public void DoAddKeyAction(Func <string, bool> keyAction, string suggestedNewKey) { var addKey = PopupEditors.EditString(m_controlData.GetString("keyprompt"), suggestedNewKey, GetAutoCompleteList()); if (addKey.Cancelled) { return; } if (!ValidateInput(addKey.Result)) { return; } if (keyAction(addKey.Result)) { AddNewValue(addKey); } }
protected override void EditValue(string key) { var result = PopupEditors.EditString(ControlData.GetString("valueprompt"), List[key], allowEmptyString: true); if (result.Cancelled) { return; } if (result.Result == List[key]) { return; } PrepareForEditing(); Controller.StartTransaction(string.Format("Update '{0}='{1}'", key, result.Result)); List.Update(key, result.Result); Controller.EndTransaction(); }
protected override void AddNewValue(PopupEditors.EditStringResult addKey) { var addValue = PopupEditors.EditString(ControlData.GetString("valueprompt"), string.Empty, allowEmptyString: true); if (addValue.Cancelled) { return; } PrepareForEditing(); if (List == null) { Value = Controller.CreateNewEditableStringDictionary(ElementName, AttributeName, addKey.Result, addValue.Result, true); } else { List.Add(addKey.Result, addValue.Result); } }
protected override void Add() { // TO DO: This fetches all verbs in the game, but verbs can be defined in rooms, so we should // filter out any out-of-scope verbs. IDictionary <string, string> availableVerbs = Controller.GetVerbProperties(); PopupEditors.EditStringResult result = PopupEditors.EditString( "Please enter a name for the new verb", string.Empty, availableVerbs.Values); if (result.Cancelled) { return; } string selectedPattern = result.Result.ToLower(); string selectedAttribute = Controller.GetVerbAttributeForPattern(selectedPattern); AddVerb(selectedPattern, selectedAttribute); }