Exemple #1
0
    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);
        }
    }
Exemple #2
0
    /// <summary>
    /// Shows a prompt for the user to enter a new name.
    /// </summary>
    public async Task CreateNew()
    {
        var result = await DialogStringInput.ShowBlocking("Enter a name:", name => !AffixType.Exists(name) && AffixType.IsValidName(name), ShowInvalidNameMessage).result;

        if (result.IsOK)
        {
            string name = result.Value;

            AffixInfo info = new AffixInfo(name, new AffixValueInfo());
            AffixInfo.Register(info);
            AddTypeToLIst(info.Type);
            UpdateHeight();
            SelectType(info.Type);
        }
    }