public async Task RenameSelectedType() { if (selectedType == AffixType.None) { return; } if (!AffixInfoDisplay.IsValid) { DialogBasic.Show("Renaming requires that all changes are saved first, but there are invalid entries. Please fix all errors before trying again."); return; } if (AffixInfoDisplay.IsChanged) { if ((await DialogCancellable.Show("Renaming requires that all changes be saved first. Save now?").result).IsCancelled) { return; } if (await SaveSelectedType() == false) { DialogBasic.Show("There was a problem saving. Please recheck the values and try again."); return; } } var result = await DialogStringInput.ShowBlocking($"Enter a new name for '{selectedType.Name}'", name => !AffixType.Exists(name) && AffixType.IsValidName(name), ShowInvalidNameMessage).result; if (result.IsOK) { string name = result.Value; var oldInfo = AffixInfo.GetAffixInfo(selectedType); AffixInfo.Deregister(selectedType); Serializer.DeleteAffixInfo(oldInfo.Type); var newType = AffixType.Replace(selectedType.ID, name); var newInfo = new AffixInfo(newType, oldInfo.ValueInfo, oldInfo.Description); AffixInfo.Register(newInfo); Serializer.SaveAffixInfoToDisk(newInfo); var display = displays[selectedType]; displays.Remove(selectedType); displays.Add(newType, display); display.SetAffixType(newType); SelectType(newType); } }
/// <summary> /// Creates a new AffixInfo object and its associated type /// </summary> public AffixInfo(int id, string name, AffixValueInfo valueInfo, string description) : this(AffixType.Replace(id, name), valueInfo, description) { }