Example #1
0
 /// <summary>
 /// Called when [selection changed].
 /// </summary>
 /// <param name="sender">The sender.</param>
 protected void OnSelectionChanged(AppTreeNode sender)
 {
     if (SelectionChanged != null)
     {
         SelectionChanged(sender);
     }
 }
        /// <summary>
        /// Updates the preview.
        /// </summary>
        private void UpdatePreview()
        {
            if (_previewChild != null)
            {
                _previewChild.PropertyChanged -= PreviewPropertyChanged;
            }

            if (_children.Count == 0)
            {
                Icon = null;
                OnPropertyChanged("Icon");

                return;
            }

            _previewChild = _children.First();
            _previewChild.PropertyChanged += PreviewPropertyChanged;

            if (IsSelected)
            {
                Icon = null;
                OnPropertyChanged("Icon");
            }
            else
            {
                Icon = _previewChild.Icon;
                OnPropertyChanged("Icon");
            }
        }
        /// <summary>
        /// Adds the child.
        /// </summary>
        /// <param name="item">The item.</param>
        public void AddChild(AppTreeNode item)
        {
            item.SelectionChanged += OnSelectionChanged;
            item.Parent            = this;
            _children.Add(item);

            if (_enablePreview)
            {
                UpdatePreview();
            }
        }
        /// <summary>
        /// Removes the child.
        /// </summary>
        /// <param name="item">The item.</param>
        /// <returns></returns>
        public bool RemoveChild(AppTreeNode item)
        {
            item.SelectionChanged -= OnSelectionChanged;
            item.Parent            = null;
            var result = _children.Remove(item);

            if (_enablePreview)
            {
                UpdatePreview();
            }
            return(result);
        }