Пример #1
0
        /// <summary>
        /// Update Comments and Children according to whether the item is chosen or not
        /// </summary>
        private void UpdateChosen()
        {
            if (IsChosen)
            {
                if (m_Children == null)
                {
                    Children = CodesToItems.GetChildItems(
                        Model.Children
                        .Where(ci => !ParentHasEnabledCode(ci)),
                        ParentVM, this);
                    if (m_Children.Count == 0)
                    {
                        SpecificityComplete = true;
                    }
                    else
                    {
                        if (!String.Equals(m_Children[0].Title.Title, CodesToItems.SpecificityString))
                        {
                            SpecificityComplete = true;
                        }
                    }
                    m_TrueChildren.Clear();
                    m_TrueChildren.AddRange(Children);
                }
                if ((ParentItemVM != null) && (String.Equals(Model.Code.ChildType, Data.IcdCodeStrings.ChildType_Direct)))
                {
                    Comment = ParentItemVM.Comment;
                    ParentItemVM.Comment       = ListItemVM.CommentStart;
                    ParentItemVM.HasOwnComment = false;
                }
            }
            else
            {
                SpecificityComplete = false;
                foreach (var child in m_TrueChildren)
                {
                    child.IsChosen = false;
                }
                m_TrueChildren.Clear();
                if (HasOwnComment)
                {
                    if ((ParentItemVM != null) && (String.Equals(Model.Code.ChildType, Data.IcdCodeStrings.ChildType_Direct)))
                    {
                        ParentItemVM.Comment       = Comment;
                        ParentItemVM.HasOwnComment = true;
                        Comment = CommentStart;
                    }
                }
                Children = null;
            }


            if (ParentVM != null)
            {
                if (ParentItemVM == null)
                {
                    if (IsChosen)
                    {
                        ParentVM.ClearToItem(this);
                    }
                    else
                    {
                        ParentVM.ClearToFullList();
                    }
                }
                else
                {
                    if (String.Equals(Model.Code.ChildType, IcdCodeStrings.ChildType_Direct))
                    {
                        if (IsChosen)
                        {
                            ParentItemVM.ClearChildrenToSelected();
                            ParentItemVM.ReplaceSelectedChild(this);
                        }
                        else
                        {
                            ClearForParent();
                        }
                    }
                    ParentVM.UpdateChecks();
                }
            }
        }