Пример #1
0
        protected virtual void SetChecked(bool value)
        {
            // If no children are checked, make a choice.
            if (!InternalCheckUpdate && ChildOptions.Count > 0 && !ChildOptions.Any(c => c.IsChecked))
            {
                Choose();
            }

            if (Parent != null)
            {
                // Checking causes the parent to expand and check.
                bool icu = Parent.InternalCheckUpdate;
                Parent.InternalCheckUpdate = true;
                Parent.IsExpanded          = true;
                Parent.IsChecked           = true;
                Parent.InternalCheckUpdate = icu;

                // Single-select choices uncheck all siblings when checked.
                if (Parent.IsChoice && !Parent.IsMultiSelect && !Parent.IsManualMultiSelect)
                {
                    foreach (var sibling in Parent.ChildOptions.Where(s => s != this))
                    {
                        sibling.IsChecked = false;
                    }
                }
            }
        }
Пример #2
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());
            }
        }
Пример #3
0
        protected override void SetChecked(bool value)
        {
            // If no children are checked, make a choice.
            if (ChildOptions.Count > 0 && !ChildOptions.Any(c => c.IsChecked))
            {
                Choose();
            }

            if (Parent != null)
            {
                // Checking causes the parent to expand and check.
                Parent.IsExpanded = true;
                Parent.IsChecked  = true;

                // Single-select choices uncheck all siblings when checked.
                // Elements only uncheck other elements (not standard child options).
                if (Parent is PlotArchetypeNoteOption && Parent.IsChoice && !Parent.IsMultiSelect && !Parent.IsManualMultiSelect)
                {
                    foreach (var sibling in ((PlotArchetypeNoteOption)Parent).ElementOptions.Where(s => s != this))
                    {
                        sibling.IsChecked = false;
                    }
                }
            }
        }
Пример #4
0
 public bool ContainsText(string text)
 {
     if (Name.ToLowerInvariant().Contains(text))
     {
         return(true);
     }
     return(ChildOptions.Any(c => c.ContainsText(text)));
 }