コード例 #1
0
        /// <summary>
        ///		Crea un archivo
        /// </summary>
        public FileModel CreateFile(ProjectModel project, FileModel folderParent, string name, FileModel.DocumentType type)
        {
            FileModel file = new FileModel(project);

            // Asigna las propiedades
            file.Title        = name;
            file.FullFileName = GetPath(project, folderParent, name);
            file.FileType     = type;
            // Si es un archivo de tipo documento, añade al nombre de archivo, el nombre de archivo predeterminado, si no recoge el
            // título normalizado
            if (!file.IsDocumentFolder)
            {
                file.FullFileName += file.GetExtension(type);
            }
            else
            {
                file.Title = Path.GetFileName(file.FullFileName);
            }
            // Crea el directorio
            LibCommonHelper.Files.HelperFiles.MakePath(file.Path);
            // Graba el archivo
            if (file.FileType == FileModel.DocumentType.File)
            {
                LibCommonHelper.Files.HelperFiles.SaveTextFile(file.FullFileName, "");
            }
            else if (file.FileType != FileModel.DocumentType.Folder)
            {
                new Documents.DocumentBussiness().Save(file);
            }
            // Devuelve el archivo
            return(file);
        }
コード例 #2
0
        /// <summary>
        ///		Convierte un archivo
        /// </summary>
        private FileModel ConvertFile(ProjectModel project, string fileName)
        {
            FileModel file = new FileModel(project);

            // Asigna las propiedades
            file.FullFileName = fileName;
            file.FileType     = FileModel.DocumentType.File;
            // Asigna el tipo de documento
            if (Directory.Exists(fileName))
            {
                // Indica que es una carpeta
                file.FileType = FileModel.DocumentType.Folder;
                // Comprueba si es un documento o una etiqueta (en ese caso no se añadirían a la colección)
                if (File.Exists(Path.Combine(fileName, file.GetDefaultFileName(FileModel.DocumentType.Document))))
                {
                    file.FileType = FileModel.DocumentType.Document;
                }
                else if (File.Exists(Path.Combine(fileName, file.GetDefaultFileName(FileModel.DocumentType.Tag))))
                {
                    file.FileType = FileModel.DocumentType.Tag;
                }
            }
            else
            {
                string extension = Path.GetExtension(fileName);

                if (extension.EqualsIgnoreCase(file.GetExtension(FileModel.DocumentType.Document)) ||
                    extension.EqualsIgnoreCase(file.GetExtension(FileModel.DocumentType.Tag)))
                {
                    file = null;
                }
                else if (extension.EqualsIgnoreCase(file.GetExtension(FileModel.DocumentType.SiteMap)))
                {
                    file.FileType = FileModel.DocumentType.SiteMap;
                }
                else if (extension.EqualsIgnoreCase(file.GetExtension(FileModel.DocumentType.Reference)))
                {
                    file.FileType = FileModel.DocumentType.Reference;
                }
                else if (extension.EqualsIgnoreCase(file.GetExtension(FileModel.DocumentType.Section)))
                {
                    file.FileType = FileModel.DocumentType.Section;
                }
                else if (extension.EqualsIgnoreCase(file.GetExtension(FileModel.DocumentType.Template)))
                {
                    file.FileType = FileModel.DocumentType.Template;
                }
                else if (extension.EqualsIgnoreCase(".bmp") || extension.EqualsIgnoreCase(".gif") ||
                         extension.EqualsIgnoreCase(".jpg") || extension.EqualsIgnoreCase(".png") ||
                         extension.EqualsIgnoreCase(".tif") || extension.EqualsIgnoreCase(".tiff"))
                {
                    file.FileType = FileModel.DocumentType.Image;
                }
            }
            // Devuelve el objeto
            return(file);
        }
コード例 #3
0
        private ImportArgs DecideImportOptions(FileModel model)
        {
            _ = Enum.TryParse(model.GetExtension(), out ERawFileFormat rawFileFormat);

            return(rawFileFormat switch
            {
                ERawFileFormat.tga => new XbmImportArgs(),
                ERawFileFormat.dds => new XbmImportArgs(),
                ERawFileFormat.fbx => new CommonImportArgs(),
                ERawFileFormat.glb => new MeshImportArgs(),
                ERawFileFormat.gltf => new MeshImportArgs(),
                ERawFileFormat.ttf => new FntImportArgs(),
                ERawFileFormat.wav => new OpusImportArgs(),
                _ => new CommonImportArgs()
            });
コード例 #4
0
        public async Task ExecuteSelectFile(FileModel model)
        {
            SelectedIndex = 0;
            if (model == null)
            {
                return;
            }

            if (State is DockState.AutoHidden or DockState.Hidden)
            {
                return;
            }

            PE_SelectedItem = model;
            if (!_settingsManager.ShowFilePreview)
            {
                return;
            }

            PE_MeshPreviewVisible = false;
            IsAudioPreviewVisible = false;
            IsImagePreviewVisible = false;
            IsVideoPreviewVisible = false;

            // check additional changes
            if (model.IsDirectory)
            {
                return;
            }

            if (PE_SelectedItem == null)
            {
                return;
            }
            // string.Equals(model.GetExtension(), ERedExtension.bk2.ToString(), StringComparison.OrdinalIgnoreCase) ||
            if (!(
                    string.Equals(model.GetExtension(), ERedExtension.ent.ToString(), StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(model.GetExtension(), ERedExtension.physicalscene.ToString(), StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(model.GetExtension(), ERedExtension.w2mesh.ToString(), StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(model.GetExtension(), ERedExtension.mesh.ToString(), StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(model.GetExtension(), ERedExtension.wem.ToString(), StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(model.GetExtension(), ERedExtension.xbm.ToString(), StringComparison.OrdinalIgnoreCase) ||
                    string.Equals(model.GetExtension(), ERedExtension.envprobe.ToString(), StringComparison.OrdinalIgnoreCase) ||
                    Enum.TryParse <EConvertableOutput>(PE_SelectedItem.GetExtension(), out _) ||
                    Enum.TryParse <EUncookExtension>(PE_SelectedItem.GetExtension(), out _)
                    ))
            {
                return;
            }

            if (PE_SelectedItem != null)
            {
                if (PE_SelectedItem.GetExtension().Length > 0)
                {
                    //if (string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.bk2.ToString(),
                    //   System.StringComparison.OrdinalIgnoreCase))
                    //{
                    //    IsVideoPreviewVisible = true;
                    //    SetExeCommand?.Invoke("test.exe | test2.bk2 /J /I2 /P");
                    //}


                    if (Enum.IsDefined(typeof(EConvertableOutput), PE_SelectedItem.GetExtension()))
                    {
                        PE_MeshPreviewVisible = true;
                        SelectedIndex         = 1;

                        LoadModel(PE_SelectedItem.FullName);
                    }

                    if (string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.mesh.ToString(), StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.w2mesh.ToString(), StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.ent.ToString(), StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.physicalscene.ToString(), StringComparison.OrdinalIgnoreCase))
                    {
                        using (var meshStream = new FileStream(PE_SelectedItem.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        {
                            meshStream.Seek(0, SeekOrigin.Begin);
                            var outPath = Path.Combine(ISettingsManager.GetTemp_OBJPath(), Path.GetFileName(PE_SelectedItem.FullName));
                            outPath = Path.ChangeExtension(outPath, ".glb");
                            if (_meshTools.ExportMeshPreviewer(meshStream, new FileInfo(outPath)))
                            {
                                LoadModel(outPath);
                                PE_MeshPreviewVisible = true;
                                SelectedIndex         = 1;
                            }
                            meshStream.Dispose();
                            meshStream.Close();
                        }
                    }

                    if (string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.wem.ToString(),
                                      System.StringComparison.OrdinalIgnoreCase))
                    {
                        IsAudioPreviewVisible = true;
                        SelectedIndex         = 2;

                        PreviewAudioCommand.SafeExecute(PE_SelectedItem.FullName);
                    }

                    // textures
                    if (Enum.TryParse <EUncookExtension>(PE_SelectedItem.GetExtension(),
                                                         out _))
                    {
                        var q = await ImageDecoder.RenderToBitmapSource(PE_SelectedItem.FullName);

                        if (q != null)
                        {
                            var g = BitmapFrame.Create(q);
                            LoadImage(g);
                            IsImagePreviewVisible = true;
                            SelectedIndex         = 3;
                        }
                    }

                    // xbm
                    if (string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.xbm.ToString(), StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.mesh.ToString(), StringComparison.OrdinalIgnoreCase) ||
                        string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.envprobe.ToString(), StringComparison.OrdinalIgnoreCase))
                    {
                        // convert xbm to dds stream
                        await using var ddsstream  = new MemoryStream();
                        await using var filestream = new FileStream(PE_SelectedItem.FullName,
                                                                    FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, FileOptions.SequentialScan);
                        if (_modTools.ConvertXbmToDdsStream(filestream, ddsstream, out _))
                        {
                            // try loading it in pfim
                            try
                            {
                                var qa = await ImageDecoder.RenderToBitmapSourceDds(ddsstream);

                                if (qa != null)
                                {
                                    LoadImage(qa);
                                    IsImagePreviewVisible = true;
                                    SelectedIndex         = 3;
                                }
                            }
                            catch (Exception)
                            {
                                throw;
                            }
                        }
                    }
                }
            }
            DecideForMeshPreview();
        }
コード例 #5
0
        public async Task ExecuteSelectFile(FileModel model)
        {
            if (model == null)
            {
                return;
            }

            if (State is DockState.AutoHidden or DockState.Hidden)
            {
                return;
            }

            if (canShowPrev)
            {
                PE_SelectedItem = model;
            }
            else
            {
                return;
            }
            PE_MeshPreviewVisible = false;
            IsAudioPreviewVisible = false;
            IsImagePreviewVisible = false;
            IsVideoPreviewVisible = false;

            // check additional changes
            if (model.IsDirectory)
            {
                return;
            }

            if (PE_SelectedItem == null)
            {
                return;
            }
            // string.Equals(model.GetExtension(), ERedExtension.bk2.ToString(), StringComparison.OrdinalIgnoreCase) ||
            if (!(string.Equals(model.GetExtension(), ERedExtension.mesh.ToString(), StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(model.GetExtension(), ERedExtension.wem.ToString(), StringComparison.OrdinalIgnoreCase) ||
                  string.Equals(model.GetExtension(), ERedExtension.xbm.ToString(), StringComparison.OrdinalIgnoreCase) ||
                  Enum.TryParse <EConvertableOutput>(PE_SelectedItem.GetExtension(), out _) ||
                  Enum.TryParse <EUncookExtension>(PE_SelectedItem.GetExtension(), out _)
                  )
                )
            {
                return;
            }

            if (PE_SelectedItem != null)
            {
                if (PE_SelectedItem.GetExtension().Length > 0)
                {
                    //if (string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.bk2.ToString(),
                    //   System.StringComparison.OrdinalIgnoreCase))
                    //{
                    //    IsVideoPreviewVisible = true;
                    //    SetExeCommand?.Invoke("test.exe | test2.bk2 /J /I2 /P");
                    //}


                    if (Enum.IsDefined(typeof(EConvertableOutput), PE_SelectedItem.GetExtension()))
                    {
                        PE_MeshPreviewVisible = true;

                        LoadModel(PE_SelectedItem.FullName);
                    }



                    if (string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.mesh.ToString(),
                                      System.StringComparison.OrdinalIgnoreCase))
                    {
                        PE_MeshPreviewVisible = true;

                        var q = _meshTools.ExportMeshWithoutRigPreviewer(PE_SelectedItem.FullName, Path.Combine(ISettingsManager.GetManagerCacheDir(), "Temp_OBJ"));
                        if (q.Length > 0)
                        {
                            LoadModel(q);
                        }
                    }

                    if (string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.wem.ToString(),
                                      System.StringComparison.OrdinalIgnoreCase))
                    {
                        IsAudioPreviewVisible = true;

                        AddAudioItem(PE_SelectedItem.FullName);
                    }

                    // textures
                    if (Enum.TryParse <EUncookExtension>(PE_SelectedItem.GetExtension(),
                                                         out _))
                    {
                        IsImagePreviewVisible = true;

                        var q = await ImageDecoder.RenderToBitmapSource(PE_SelectedItem.FullName);

                        if (q != null)
                        {
                            var g = BitmapFrame.Create(q);
                            LoadImage(g);
                        }
                    }

                    // xbm
                    if (string.Equals(PE_SelectedItem.GetExtension(), ERedExtension.xbm.ToString(),
                                      System.StringComparison.OrdinalIgnoreCase))
                    {
                        IsImagePreviewVisible = true;
                        var man = ServiceLocator.Default.ResolveType <ModTools>();

                        // convert xbm to dds stream
                        await using var ddsstream  = new MemoryStream();
                        await using var filestream = new FileStream(PE_SelectedItem.FullName,
                                                                    FileMode.Open, FileAccess.Read, FileShare.ReadWrite, 4096, FileOptions.SequentialScan);
                        man.ConvertXbmToDdsStream(filestream, ddsstream, out _);

                        // try loading it in pfim
                        try
                        {
                            var qa = await ImageDecoder.RenderToBitmapSourceDds(ddsstream);

                            if (qa != null)
                            {
                                LoadImage(qa);
                            }
                        }
                        catch (Exception)
                        {
                        }
                    }
                }
            }
            DecideForMeshPreview();
        }