예제 #1
0
        public void MergeWithOption(NoteOption other, bool overwrite, bool mergeChecked = false)
        {
            if (overwrite)
            {
                // Merge properties.
                Weight              = other.Weight;
                IsChoice            = other.IsChoice;
                IsMultiSelect       = other.IsMultiSelect;
                IsManualMultiSelect = other.IsManualMultiSelect;
                AllowsNone          = other.AllowsNone;
                NoneWeight          = other.NoneWeight;
            }
            // Do not un-check, only check to match.
            if (mergeChecked && other.IsChecked)
            {
                IsChecked = true;
            }

            // Combine matching children.
            foreach (var matchingChild in ChildOptions.Where(c => other.ChildOptions.Any(o => c.Name == o.Name)))
            {
                matchingChild.MergeWithOption(other.ChildOptions.First(o => o.Name == matchingChild.Name), overwrite, mergeChecked);
            }

            foreach (var newChild in other.ChildOptions.Where(o => !ChildOptions.Any(c => c.Name == o.Name)))
            {
                AddChild((NoteOption)newChild.Clone());
            }
        }
예제 #2
0
        public CharacterGenderOption GetArchetypeClone(string archetype)
        {
            CharacterGenderOption clone = (CharacterGenderOption)MemberwiseClone();

            clone.ChildOptions = new ObservableCollection <NoteOption>();
            foreach (CharacterGenderOption child in ChildOptions.Where(c => c is CharacterGenderOption &&
                                                                       (((CharacterGenderOption)c).Archetype == archetype || string.IsNullOrEmpty(((CharacterGenderOption)c).Archetype))))
            {
                clone.AddChild(child.GetArchetypeClone(archetype));
            }
            return(clone);
        }
예제 #3
0
        public string GetSummary(int indentLevel)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < indentLevel; i++)
            {
                sb.Append("\t");
            }
            sb.AppendLine(Name);
            foreach (var child in ChildOptions.Where(c => c.IsChecked))
            {
                sb.Append(child.GetSummary(indentLevel + 1));
            }
            return(sb.ToString());
        }
예제 #4
0
        public List <NoteOption> LowestCheckedChildren(List <NoteOption> list)
        {
            bool addedChildren = false;

            foreach (var child in ChildOptions.Where(c => c.IsChecked))
            {
                addedChildren = true;
                list          = child.LowestCheckedChildren(list);
            }

            if (!addedChildren && IsChecked)
            {
                list.Add(this);
            }
            return(list);
        }