public DeckList(string path, Dispatcher disp, DeckList parent = null, bool isRoot = false)
        {
            Parent = parent;
            Path = path;
            Name = new DirectoryInfo(path).Name;

            if (isRoot) IsRootFolder = true;

            DeckLists = new ObservableCollection<DeckList>();
            Decks = new ObservableCollection<MetaDeck>();

            foreach (var f in Directory.GetDirectories(path).Select(x => new DirectoryInfo(x)))
            {
                if (isRoot)
                {
                    if (DataNew
                        .DbContext.Get()
                        .Games
                        .Any(x => x.Name.Equals(f.Name, StringComparison.InvariantCultureIgnoreCase)))
                    {
                        var dl = new DeckList(f.FullName, disp, this);
                        dl.IsGameFolder = true;
                        disp.Invoke(new Action(() => DeckLists.Add(dl)));
                    }
                }
                else
                {
                    var dl = new DeckList(f.FullName, disp, this);
                    disp.Invoke(new Action(() => DeckLists.Add(dl)));
                }
            }

            foreach (var f in Directory.GetFiles(Path, "*.o8d"))
            {
                var deck = new MetaDeck(f);
                disp.Invoke(new Action(() => Decks.Add(deck)));
            }
            foreach (var d in DeckLists.SelectMany(x => x.Decks))
            {
                MetaDeck d1 = d;
                disp.Invoke(new Action(() => Decks.Add(d1)));
            }
        }
 private void SelectedDeckListChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
 {
     foreach (var dl in DeckLists)
     {
         foreach (var d in dl.Decks)
         {
             d.UpdateFilter(SearchString);
         }
     }
     SelectedList = e.NewValue as DeckList;
 }
        private void OnLoaded(object sender, RoutedEventArgs routedEventArgs)
        {
            this.Loaded -= OnLoaded;
            Task.Factory.StartNew(() =>
            {
                var list = new DeckList(Config.Instance.Paths.DeckPath, this.Dispatcher, null, true)
                {
                    Name = "All"
                };
                Dispatcher.Invoke(new Action(() => DeckLists.Add(list)));
                Dispatcher.Invoke(new Action(() =>
                {
                    SelectedList = null;
                    SelectedList = list;
                    foreach (DeckList item in FolderTreeView.Items)
                    {
                        if (item.Name != "All") continue;
                        TreeViewItem tvi = FolderTreeView.ItemContainerGenerator.ContainerFromItem(item) as TreeViewItem;
                        if (tvi != null)
                        {
                            Task.Factory.StartNew(() =>
                            {
                                Thread.Sleep(10);
                                Dispatcher.Invoke(new Action(
                                    () =>
                                    {
                                        try
                                        {
                                            tvi.IsSelected = true;
                                        }
                                        catch
                                        {

                                        }
                                    }));
                            });
                            break;
                        }
                    }
                }));
                IsLoading = false;
            });
        }