示例#1
0
        //private BundlesManager bundlesManager;

        /// <summary>
        /// 同步加载
        /// </summary>
        internal void Load()
        {
            if (this.LoadState == AssetLoadState.Loaded && this.AssetBundle != null)
            {
                return;
            }
            if (LoadState == AssetLoadState.Unloaded)
            {
                throw new VFSException("[TinaX.VFS] Error: Attempt to load an unloaded assetbundle :" + this.AssetBundleName);
            }


            LoadState = AssetLoadState.Loading; //其实这时候改没啥用
            if (LoadedPath.StartsWith("jar:file://", StringComparison.Ordinal))
            {
                this.AssetBundle = this.ABLoader.LoadAssetBundleFromAndroidStreamingAssets(this.LoadedPath, this.AssetBundleName, this.VirtualDiskPath);
            }
            else if (LoadedPath.StartsWith("http://", StringComparison.Ordinal) ||
                     LoadedPath.StartsWith("https://", StringComparison.Ordinal) ||
                     //LoadedPath.StartsWith("file://", StringComparison.Ordinal)||
                     LoadedPath.StartsWith("ftp://", StringComparison.Ordinal))
            {
                throw new VFSException("[TinaX.VFS] Error: Connot load from network sync");
            }
            else
            {
                this.AssetBundle = ABLoader.LoadAssetBundleFromFile(this.LoadedPath, this.AssetBundleName);
            }

            LoadState = AssetLoadState.Loaded;
        }
示例#2
0
        private async UniTask DoLoadAsync()
        {
            LoadState = AssetLoadState.Loading;
            //正儿八经的开始加载了
            if (LoadedPath.StartsWith("jar:file://", StringComparison.Ordinal))
            {
                this.AssetBundle = await this.ABLoader.LoadAssetBundleFromAndroidStreamingAssetsAsync(LoadedPath, AssetBundleName, this.VirtualDiskPath);
            }
            else if (LoadedPath.StartsWith("http://", StringComparison.Ordinal) ||
                     LoadedPath.StartsWith("https://", StringComparison.Ordinal) ||
                     //LoadedPath.StartsWith("file://", StringComparison.Ordinal)||
                     LoadedPath.StartsWith("ftp://", StringComparison.Ordinal))
            {
                if (this.GroupHandleMode == GroupHandleMode.RemoteOnly)
                {
                    this.AssetBundle = await this.ABLoader.LoadAssetBundleFromWebAsync(LoadedPath, AssetBundleName, this.DownloadTimeout);
                }
                else
                {
                    await this.ABLoader.DownloadFile(LoadedPath, VirtualDiskPath, DownloadTimeout);

                    this.AssetBundle = await this.ABLoader.LoadAssetBundleFromFileAsync(this.VirtualDiskPath, this.AssetBundleName);
                }
            }
            else
            {
                this.AssetBundle = await this.ABLoader.LoadAssetBundleFromFileAsync(LoadedPath, AssetBundleName);
            }
        }
        private void ShowPathContent()
        {
            //ListView leeren
            lvfiles.Items.Clear();

            //ImageListen vorbereiten. Es werden jeweils 2 erstellt, einmal für die SmallIcons und
            //einmal für die LargeIcons
            ImageList sil = new ImageList();
            ImageList lil = new ImageList();

            sil.ColorDepth = ColorDepth.Depth32Bit;
            sil.ImageSize  = new Size(16, 16);
            lil.ColorDepth = ColorDepth.Depth32Bit;
            lil.ImageSize  = new Size(48, 48);
            sil.Images.Add(FilesystemIcons.ICON_FILE_16x);
            lil.Images.Add(FilesystemIcons.ICON_FILE_32x);
            lvfiles.SmallImageList = sil;
            lvfiles.LargeImageList = lil;

            //Wenn der Pfad leer ist, sollen die Drives angezeigt werden. Wenn aber ein Pfad enthalten ist
            //soll der Inhalt des Pfades (Ordner) angezeigt werden
            if (_selectedpath == "")
            {
                //Nun werden alle Drives geladen und angezeigt
                foreach (DriveInfo drive in DriveInfo.GetDrives())
                {
                    //Icon ermitteln
                    sil.Images.Add(FilesystemIcons.GetSmallIcon(string.Concat(drive.Name.Substring(0, 2) + @"\")));
                    lil.Images.Add(FilesystemIcons.GetLargeIcon(string.Concat(drive.Name.Substring(0, 2) + @"\")));
                    //Jetzt muss geschaut werden, ob der Drive aktiv ist oder nicht und danach entschieden werden
                    if (drive.IsReady)
                    {
                        ListViewItem lvi = new ListViewItem(string.Concat(drive.Name.Substring(0, 2), " ", DriveFunctions.GetVolumeLabel(Convert.ToChar(drive.Name.Substring(0, 1)))), sil.Images.Count - 1);
                        lvi.SubItems.Add(""); //Dummy
                        //Der Typ wird anhand des DriveType angegeben. Bei Size kommt der maximale Speicherplatz
                        if (drive.DriveType == DriveType.Fixed)
                        {
                            //Wenn es eine SSD ist, soll das auch so angegeben werden
                            if (DriveFunctions.IsSSD(Convert.ToChar(drive.Name.Substring(0, 1))))
                            {
                                lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_SSD_DESC);
                            }
                            else
                            {
                                lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_HDD_DESC);
                            }
                        }
                        else if (drive.DriveType == DriveType.CDRom)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_OPT);
                        }
                        else if (drive.DriveType == DriveType.Removable)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_EXT);
                        }
                        else if (drive.DriveType == DriveType.Network)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_NET);
                        }
                        else
                        {
                            lvi.SubItems.Add("Unbekannter Laufwerkstyp");
                        }

                        lvi.SubItems.Add(ExtraFunctions.UnitChange(drive.TotalSize));
                        lvfiles.Items.Add(lvi);
                    }
                    else
                    {
                        ListViewItem lvi = new ListViewItem(string.Concat(drive.Name.Substring(0, 2), @"\"), sil.Images.Count - 1);
                        lvi.SubItems.Add(""); //Dummy
                        //Der Typ wird anhand des DriveType angegeben. Bei Size kommt der maximale Speicherplatz
                        if (drive.DriveType == DriveType.Fixed)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_HDD);
                        }
                        else if (drive.DriveType == DriveType.CDRom)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_OPT);
                        }
                        else if (drive.DriveType == DriveType.Removable)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_EXT);
                        }
                        else if (drive.DriveType == DriveType.Network)
                        {
                            lvi.SubItems.Add(DriveFunctions.DRIVE_VOLUMELABEL_STD_NET);
                        }
                        else
                        {
                            lvi.SubItems.Add("Unbekannter Laufwerkstyp");
                        }
                        lvfiles.Items.Add(lvi);
                    }
                }
            }
            else
            {
                DirectoryInfo dirinfo = new DirectoryInfo(_selectedpath);

                //Zuerst kommen die Directories
                foreach (DirectoryInfo d in dirinfo.GetDirectories())
                {
                    try
                    {
                        sil.Images.Add(FilesystemIcons.GetSmallIcon(d.FullName));
                        lil.Images.Add(FilesystemIcons.GetLargeIcon(d.FullName));
                    }
                    catch                                                   //Wenn das Icon über GetSmallIcon nicht genommen wird
                    {
                        sil.Images.Add(FilesystemIcons.ICON_DIRECTORY_16x); //Ersatzicon
                        lil.Images.Add(FilesystemIcons.ICON_DIRECTORY_32x); //Ersatzicon
                    }
                    ListViewItem lvi = new ListViewItem(d.Name, sil.Images.Count - 1);
                    lvi.SubItems.Add(d.LastWriteTime.ToString());
                    lvi.SubItems.Add(Extra.StringResource.GetStringResourceFromFile("@shell32.dll,-10152").ToString());
                    lvfiles.Items.Add(lvi);
                }

                //Jetzt kommen die Files. Hier kann man denselben Code wie in ExplorerPlusFileView verwenden
                //Nun wird die Liste gefüllt
                foreach (FileInfo file in dirinfo.GetFiles())
                {
                    //Anhand der Erweiterung schauen, ob es eine Verknüpfung ist oder nicht
                    try
                    {
                        try
                        {
                            if (file.Extension == ".lnk")
                            {
                                sil.Images.Add(FilesystemIcons.GetSmallIcon(FileFunctions.GetShortcutPath(file.FullName)));
                                lil.Images.Add(FilesystemIcons.GetLargeIcon(FileFunctions.GetShortcutPath(file.FullName)));
                            }
                            else
                            {
                                sil.Images.Add(FilesystemIcons.GetSmallIcon(file.FullName));
                                lil.Images.Add(FilesystemIcons.GetLargeIcon(file.FullName));
                            }
                        }
                        catch
                        {
                            sil.Images.Add(FilesystemIcons.GetIconByExtension_x16(file.Extension));
                            lil.Images.Add(FilesystemIcons.GetIconByExtension_x32(file.Extension));
                        }
                        ListViewItem lvi = new ListViewItem(file.Name, sil.Images.Count - 1);
                        lvi.SubItems.Add(file.LastWriteTime.ToString());
                        lvi.SubItems.Add(FileFunctions.GetFileTypeDescription(file.Extension));

                        //Wenn die dateigröße unter 1024 Bytes ist, soll stattdessen 1 KB ausgegeben werden
                        if (file.Length < 1024)
                        {
                            lvi.SubItems.Add("1 KB");
                        }
                        else
                        {
                            lvi.SubItems.Add(ExtraFunctions.GetFileSizeKB(Convert.ToDouble(file.Length)));
                        }
                        lvfiles.Items.Add(lvi);
                    }
                    catch (UnauthorizedAccessException)
                    { //Geht nicht, da kein Zugriff
                    }
                    catch
                    {
                        ListViewItem lvi = new ListViewItem(file.Name, 0);
                        lvi.SubItems.Add(file.LastWriteTime.ToString());
                        lvi.SubItems.Add(FileFunctions.GetFileTypeDescription(file.Extension));

                        //Wenn die dateigröße unter 1024 Bytes ist, soll stattdessen 1 KB ausgegeben werden
                        if (file.Length < 1024)
                        {
                            lvi.SubItems.Add("1 KB");
                        }
                        else
                        {
                            lvi.SubItems.Add(ExtraFunctions.GetFileSizeKB(Convert.ToDouble(file.Length)));
                        }
                        lvfiles.Items.Add(lvi);
                    }
                }
            }

            LoadedPath?.Invoke(_selectedpath);
        }