protected void RemoveExplorer() { if (this.RootFactory.IsNull()) { return; } RunOnUIThread(() => { foreach (var item in this.Items) { item.Dispose(); } this.Items.Clear(); //this.ContentView = null; }); this.RootFactory = null; if (!RootFolder.IsNull()) { if (RootFolder is LocalRootFolder) { (RootFolder as LocalRootFolder).DriverChanged -= FileExplorerViewModel_DriverChanged; } this.RootFolder.Dispose(); this.RootFolder = null; } this.CurrentFolder = null; //this.SearchViewModel.UninitialSearch(); }
virtual internal void InitialExplorer(ExplorerFactoryBase factory) { if (factory.IsNull()) { throw new ArgumentNullException("factory"); } RemoveExplorer(); this.RootFactory = factory; this.RootFactory.GetRootFoldersAsync((items) => { this.RunOnUIThread(() => { try { foreach (var item in items) { if (RootFolder.IsNull()) { LogHelper.Debug("RootFolder is NULL, add root"); RootFolder = item; if (RootFolder is LocalRootFolder) { (RootFolder as LocalRootFolder).DriverChanged += FileExplorerViewModel_DriverChanged; } } else { //Not implement now //if (item is CloudRootFolder) //{ // if (0 == string.Compare(item.FolderPath, RootFolder.FolderPath)) // { // LogHelper.Debug("Duplicate root for CloudRootFolder, so ignore this callback"); // continue; // } //} } this.Items.Add(item); } } catch (Exception ex) { LogHelper.Debug(string.Format("InitialExplorer error:{0}", ex.Message)); } }); FileBase.RaiseCheckedChanged(RootFolder, false); }); }
internal void InitialExplorer(ExplorerFactoryBase factory) { if (factory.IsNull()) { throw new ArgumentNullException("factory"); } RemoveExplorer(); this.RootFactory = factory; this.RootFactory.GetRootFoldersAsync((items) => { this.RunOnUIThread(() => { foreach (var item in items) { if (RootFolder.IsNull()) { RootFolder = item; } this.Items.Add(item); } }); }); }
public void SetPathChecked(IEnumerable <string> list, bool isChecked = true) { if (list.IsNullOrEmpty() || this.RootFolder.IsNull()) //this.RootFolder.IsLoading { return; } IsChecking = true; int totalItems = list.Count(); int checkProcessing = 0; Action action = () => { int i = 0; const int timeout = 60; //Add timeout for checking mask view can't be removed // minutes while (true) { Thread.Sleep(1 * 1000); if (!IsChecking) { return; } if (i++ > timeout) { if (IsChecking) { IsChecking = false; } return; } } }; action.BeginInvoke((ar) => action.EndInvoke(ar), action); foreach (string path in list) { ///Maybe change explore factory during checking if (RootFolder.IsNull()) { IsChecking = false; break; } this.RootFolder.GetItemAsync(path, (file) => { checkProcessing++; LogHelper.DebugFormat("/**** set checked index:{0}, total:{1}", checkProcessing, totalItems); if (checkProcessing == totalItems) { IsChecking = false; } if (!file.IsNull()) { file.IsChecked = isChecked; #if DEBUG //if (file is CloudFile || file is CloudFolder) //{ // LogHelper.DebugFormat("/++++ set checked path:{0}", file.FolderPath + file.Name); //} //else //{ // LogHelper.DebugFormat("/++++ set checked path:{0}", file.FullPath); //} #endif } }); } }