示例#1
0
        public ShelfItem FindChild(string path)
        {
            if (string.IsNullOrEmpty(path))
            {
                return(this);
            }

            ShelfItem parent = this;

            string[] split = path.Split(new string[] { System.IO.Path.DirectorySeparatorChar + "" }, StringSplitOptions.RemoveEmptyEntries);

            int i = 0;

            for (i = 0; i < split.Length; ++i)
            {
                var s = split[i];
                if (i == 0 && s.Equals(BaseName))
                {
                    continue;
                }

                var nf = parent.children.Find(m => m.BaseName.Equals(s));

                if (nf != null)
                {
                    parent = nf;
                }
                else
                {
                    return(parent);
                }
            }

            return(parent);
        }
示例#2
0
 public void Add(ShelfItem item)
 {
     More.Visibility  = Visibility.Visible;
     item.Path        = System.IO.Path.Combine(Path, item.Path);
     item.ShelfParent = this;
     children.Add(item);
     Items.Children.Add(item);
     UpdateExpandIcon();
 }
示例#3
0
 private void ShelfItem_OnSelected(ShelfItem shelf, string path)
 {
     if (shelf == this)
     {
         Title.Background = new SolidColorBrush(Color.FromArgb(255, 10, 10, 10));
     }
     else
     {
         Title.Background = new SolidColorBrush(Colors.Transparent);
     }
 }
示例#4
0
        public void Remove(ShelfItem item)
        {
            bool contained = children.Remove(item);

            if (contained)
            {
                item.ShelfParent = null;
                Items.Children.Remove(item);
                item.Path = item.BaseName;

                if (Items.Children.Count == 0)
                {
                    More.Visibility = Visibility.Collapsed;
                    Expanded        = false;
                    UpdateExpandIcon();
                }
            }
        }