Esempio n. 1
0
        internal static Tuple <ImageSource, string, string> GetIcon(string path, FileAttributes attr)
        {
            Tuple <ImageSource, string, string> result = null;

            if (path.IsNullOrEmpty())
            {
                return(result);
            }

            string fileExt = Path.GetExtension(path);

            if (!fileExt.IsNullOrEmpty() && iconCache.ContainsKey(fileExt))
            {
                result = iconCache[fileExt];
            }
            else
            {
                result = DataSourceShell.LoadFileInfoByPath(path, attr);
                if (!result.IsNull() && !fileExt.IsNullOrEmpty())
                {
                    iconCache[fileExt] = result;
                }
            }
            return(result);
        }
Esempio n. 2
0
 /// <summary>
 /// get  paths , from shell folder
 /// </summary>
 /// <param name="folder">shell folder</param>
 /// <returns></returns>
 public static List <string> GetShellSubPaths(DataSourceShell shell)
 {
     shellSubPaths.Clear();
     if (shell == null)
     {
         return(null);
     }
     getSubPathByRecursion(shell);
     return(shellSubPaths);
 }
 public LocalVirtualFolder(DataSourceShell shellItem)
     : base(string.Empty, null)
 {
     if (shellItem.IsNull())
     {
         throw new ArgumentNullException();
     }
     this.Name           = shellItem.DisplayName;
     this.Icon           = shellItem.Icon;
     this.FullPath       = shellItem.Path;
     this.IsCheckVisible = false;
     this.Parent         = this;
 }
        public LocalRootFolder()
            : base(string.Empty, null)
        {
            using (DataSourceShell shellItem = LocalExplorerFactory.GetPCRootShellItem())
            {
                this.Name = shellItem.DisplayName;
                this.Icon = shellItem.Icon;
            }

            this.IsCheckVisible = false;
            this.IsExpanded     = true;
            this.IsSelected     = true;
            this.Parent         = this;
        }
Esempio n. 5
0
        public override void GetRootFoldersAsync(Action <IEnumerable <IFolder> > callback)
        {
            ObservableCollection <IFolder> roots = new ObservableCollection <IFolder>();

            LocalRootFolder pcFolder = new LocalRootFolder();

            roots.Add(pcFolder);

            IList <string> personPaths = new List <string>()
            {
                Environment.GetFolderPath(Environment.SpecialFolder.UserProfile),
                Environment.GetFolderPath(Environment.SpecialFolder.Personal),
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
            };

            LocalVirtualFolder personFolder = null;

            foreach (var path in personPaths)
            {
                DataSourceShell item = GetShellItem(path);
                if (!item.IsNull())
                {
                    using (item)
                    {
                        personFolder = new LocalVirtualFolder(item);
                        roots.Add(personFolder);
                    }
                    break;
                }
            }

            if (!personFolder.IsNull())
            {
                pcFolder.GetItemAsync(personFolder.FullPath, (item) =>
                {
                    if (!item.IsNull() && (item is IFolder))
                    {
                        personFolder.RealFolder = item as IFolder;
                        personFolder.IsExpanded = true;
                    }
                });
            }


            if (!callback.IsNull())
            {
                callback(roots);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// get path from shell
        /// </summary>
        /// <param name="shell"></param>
        static void getSubPathByRecursion(DataSourceShell shell)
        {
            var items = shell.GetSubItems();

            foreach (var item in items)
            {
                if (item.Path.IsNullOrEmpty())
                {
                    getSubPathByRecursion(item);
                }
                else
                {
                    shellSubPaths.Add(item.Path);
                }
            }
        }
Esempio n. 7
0
        public CDRomRootFolder(string jsonPath)
            : base()
        {
            if (jsonPath.IsNullOrEmpty())
            {
                throw new ArgumentNullException();
            }
            using (DataSourceShell shellItem = LocalExplorerFactory.GetPCRootShellItem())
            {
                this.Name = shellItem.DisplayName;
                this.Icon = shellItem.Icon;
            }

            this.JsonPath   = jsonPath;
            this.IsExpanded = true;
            this.IsSelected = true;
            this.IsChecked  = true;
            this.Parent     = this;
        }
Esempio n. 8
0
        public CopyBackupRootFolder(string rootFolder, string displayName)
            : base(string.Empty, null, null)
        {
            if (rootFolder.IsNullOrEmpty())
            {
                throw new ArgumentNullException();
            }

            RootFolder = rootFolder;

            using (DataSourceShell shellItem = LocalExplorerFactory.GetPCRootShellItem())
            {
                this.Name = displayName;
                this.Icon = shellItem.Icon;
            }

            this.IsCheckVisible = false;
            this.IsExpanded     = true;
            this.IsSelected     = true;
            this.Parent         = this;
        }
Esempio n. 9
0
        public static DataSourceShell GetShellItem(string parseNames)
        {
            DataSourceShell result = null;

            using (DataSourceShell rootShell = new DataSourceShell())
            {
                List <DataSourceShell> rootChildren = rootShell.GetSubItems();
                foreach (var item in rootChildren)
                {
                    if (parseNames.Contains(item.ParsingName))
                    {
                        result = item;
                    }
                    else
                    {
                        item.Dispose();
                    }
                }
            }
            return(result);
        }
Esempio n. 10
0
        public static DataSourceShell GetPCRootShellItem()
        {
            DataSourceShell pcShell = GetShellItem(ComputerParseName);

            return(pcShell);
        }