Esempio n. 1
0
 public void AddItem(BrowsingFile ent)
 {
     subItems.Add(ent);
 }
Esempio n. 2
0
        private void Populate(string ent)
        {
            ent = ent.Replace('/', '\\');
            bvm.IsBusy = true;
            if (string.IsNullOrEmpty(ent))
            {
                bvm.Root.Clear();
                ThreadPool.QueueUserWorkItem(PopulateAsync, null);
                return;
            }
            string[] items = ent.Split('\\');
            BrowsingFile parent = bvm.Root.Where(n => n.Name == items[0]).FirstOrDefault();

            if (string.IsNullOrEmpty(ent))
            {
                //Just the root
                bvm.CurrentItem = parent;
            }
            else
            {
                for (int i = 1; i < items.Length; i++)
                {
                    BrowsingFile search = parent.Items.Where(n => n.Name == items[i]).FirstOrDefault();
                    if (null == search)
                    {
                        var fse = new BrowsingFile();
                        fse.FullPath = ent;
                        parent.Items.Add(fse);
                        parent = fse;
                    }
                    else
                    {
                        parent = search;
                    }
                }
            }

            if (!parent.IsPopulated || bvm.NoCache)
            {
                parent.ClearItems();

                ThreadPool.QueueUserWorkItem(PopulateAsync, parent);
            }
            else
            {
                bvm.CurrentItem = parent;
                bvm.IsBusy = false;
            }
        }
Esempio n. 3
0
 public void AddItem(BrowsingFile ent)
 {
     subItems.Add(ent);
 }
Esempio n. 4
0
        private void PopulateAsync(object o)
        {
            var fse = o as BrowsingFile;
            if (null != fse)
            {
                var c = new Client(model.LocalNode);
                var cmd = new BrowseVerb(shareInfo);
                cmd.Path = fse.FullPath;
                cmd.NoCache = bvm.NoCache;
                if (c.Execute(cmd, client))
                {
                    SafeObservableStatic.Dispatcher.Invoke(DispatcherPriority.Normal,
                                                           new Action(
                                                               delegate
                                                                   {
                                                                       bvm.Status = "Download complete (" +
                                                                                    cmd.Results.Count + ").";
                                                                       fse.IsPopulated = true;
                                                                       fse.ClearItems();

                                                                       foreach (BrowsingFile result in cmd.Results)
                                                                       {
                                                                           result.Path = fse.FullPath;
                                                                           fse.AddItem(result);
                                                                       }
                                                                       bvm.CurrentItem = fse;
                                                                       bvm.IsBusy = false;
                                                                   }
                                                               ));
                }
            }
            else
            {
                var c = new Client(model.LocalNode);
                var cmd = new BrowseVerb(shareInfo);
                cmd.NoCache = bvm.NoCache;

                if (c.Execute(cmd, client))
                {
                    SafeObservableStatic.Dispatcher.Invoke(DispatcherPriority.Normal,
                                                           new Action(
                                                               delegate
                                                                   {
                                                                       bvm.Status = "Download complete (" +
                                                                                    cmd.Results.Count + ").";
                                                                       var ent = new BrowsingFile();
                                                                       foreach (BrowsingFile result in cmd.Results)
                                                                       {
                                                                           bvm.Root.Add(result);
                                                                           ent.AddItem(result);
                                                                       }
                                                                       ent.IsPopulated = true;
                                                                       bvm.CurrentItem = ent;
                                                                       bvm.IsBusy = false;
                                                                   }
                                                               ));
                }
            }
        }