コード例 #1
0
        private void ExportAll_Execute(object parameter)
        {
            try
            {
                var success      = 0;
                var fail         = 0;
                var progDialogVM = new ProgressDialogViewModel()
                {
                    PercentageMax = packages.Count
                };
                var progDialog = new View.ProgressDialog
                {
                    DataContext = progDialogVM
                };

                var task = Task.Run(() =>
                {
                    var outputFolder = mainView.FilePath.Replace(".", "_") + "_pkgfiles";
                    Directory.CreateDirectory(outputFolder);

                    for (var i = 0; i < packages.Count;)
                    {
                        var resource   = packages[i].Resource;
                        var fragment   = packages[i].Fragment;
                        var folderPath = Path.Combine(outputFolder, resource.Folder);
                        var fileName   = ErpResourceExporter.GetFragmentFileName(resource, fragment);
                        var filePath   = Path.Combine(folderPath, fileName) + ".json";
                        progDialogVM.ProgressStatus.Report("Exporting " + fileName + "... ");

                        try
                        {
                            Directory.CreateDirectory(folderPath);

                            using var fs = File.Open(filePath, FileMode.Create, FileAccess.Write, FileShare.Read);
                            using var sw = new StreamWriter(fs);
                            packages[i].ExportPkg(sw);

                            progDialogVM.ProgressStatus.Report("SUCCESS" + Environment.NewLine);
                            ++success;
                        }
                        catch when(!System.Diagnostics.Debugger.IsAttached)
                        {
                            progDialogVM.ProgressStatus.Report("FAIL" + Environment.NewLine);
                            ++fail;
                        }

                        progDialogVM.ProgressPercentage.Report(++i);
                    }

                    progDialogVM.ProgressStatus.Report(string.Format("{0} Succeeded, {1} Failed", success, fail));
                });

                progDialog.ShowDialog();
                task.Wait();
            }
            catch
            {
                MessageBox.Show("There was an error, could not export all pkg files!", Properties.Resources.AppTitleLong, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #2
0
        private void ExportAll_Execute(object parameter)
        {
            var dlg = new CommonOpenFileDialog();

            dlg.Title          = "Select a folder to export the resources:";
            dlg.IsFolderPicker = true;

            dlg.AddToMostRecentlyUsedList = false;
            dlg.AllowNonFileSystemItems   = false;
            dlg.EnsureFileExists          = true;
            dlg.EnsurePathExists          = true;
            dlg.EnsureReadOnly            = false;
            dlg.EnsureValidNames          = true;
            dlg.Multiselect    = false;
            dlg.ShowPlacesList = true;

            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
            {
                try
                {
                    ProgressDialogViewModel progDialogVM = new ProgressDialogViewModel(out mainView.ErpFile.ProgressPercentage, out mainView.ErpFile.ProgressStatus);
                    progDialogVM.PercentageMax = mainView.ErpFile.Resources.Count;
                    View.ProgressDialog progDialog = new View.ProgressDialog();
                    progDialog.DataContext = progDialogVM;
                    var task = Task.Run(() => mainView.ErpFile.Export(dlg.FileName));
                    progDialog.ShowDialog();
                    task.Wait();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed Exporting!" + Environment.NewLine + Environment.NewLine +
                                    ex.Message, Properties.Resources.AppTitleLong, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #3
0
        private void ExportTextures_Execute(object parameter)
        {
            try
            {
                var success      = 0;
                var fail         = 0;
                var progDialogVM = new ProgressDialogViewModel
                {
                    PercentageMax = Textures.Count
                };
                var progDialog = new View.ProgressDialog
                {
                    DataContext = progDialogVM
                };

                var task = Task.Run(() =>
                {
                    var outputFolderPath = mainView.FilePath.Replace(".", "_") + "_textures";
                    Directory.CreateDirectory(outputFolderPath);

                    for (var i = 0; i < textures.Count;)
                    {
                        var resource   = textures[i].Resource;
                        var folderPath = Path.Combine(outputFolderPath, resource.Folder);
                        var fileName   = resource.FileName.Replace("?", "%3F");
                        var filePath   = Path.Combine(folderPath, fileName) + ".dds";
                        progDialogVM.ProgressStatus.Report("Exporting " + fileName + "... ");

                        try
                        {
                            Directory.CreateDirectory(folderPath);
                            textures[i].ExportDDS(filePath, true, true);
                            progDialogVM.ProgressStatus.Report("SUCCESS" + Environment.NewLine);
                            ++success;
                        }
                        catch
                        {
                            progDialogVM.ProgressStatus.Report("FAIL" + Environment.NewLine);
                            ++fail;
                        }

                        progDialogVM.ProgressPercentage.Report(++i);
                    }

                    progDialogVM.ProgressStatus.Report(string.Format("{0} Succeeded, {1} Failed", success, fail));
                });

                progDialog.ShowDialog();
                task.Wait();
            }
            catch
            {
                MessageBox.Show("There was an error, could not export all textures!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #4
0
        private void ExportAll_Execute(object parameter)
        {
            try
            {
                int success = 0;
                int fail    = 0;
                ProgressDialogViewModel progDialogVM = new ProgressDialogViewModel(out mainView.ErpFile.ProgressPercentage, out mainView.ErpFile.ProgressStatus);
                progDialogVM.PercentageMax = packages.Count;
                View.ProgressDialog progDialog = new View.ProgressDialog();
                progDialog.DataContext = progDialogVM;

                var task = Task.Run(() =>
                {
                    string outputFolder = mainView.FilePath.Replace(".", "_") + "_pkgfiles";
                    Directory.CreateDirectory(outputFolder);

                    for (int i = 0; i < packages.Count;)
                    {
                        string fileName = outputFolder + "\\" + Path.Combine(packages[i].Package.Folder, packages[i].Package.FileName).Replace("?", "%3F") + ".json";
                        ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("Exporting " + Path.GetFileName(fileName) + "... ");

                        try
                        {
                            string directoryPath = Path.GetDirectoryName(fileName);
                            if (!Directory.Exists(directoryPath))
                            {
                                Directory.CreateDirectory(directoryPath);
                            }
                            packages[i].ExportPkg(new StreamWriter(File.Open(fileName, FileMode.Create, FileAccess.Write, FileShare.Read)));
                            ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("SUCCESS" + Environment.NewLine);
                            ++success;
                        }
                        catch when(!System.Diagnostics.Debugger.IsAttached)
                        {
                            ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("FAIL" + Environment.NewLine);
                            ++fail;
                        }

                        ((IProgress <int>)mainView.ErpFile.ProgressPercentage).Report(++i);
                    }

                    ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report(string.Format("{0} Succeeded, {1} Failed", success, fail));
                });

                progDialog.ShowDialog();
                task.Wait();
            }
            catch
            {
                MessageBox.Show("There was an error, could not export all pkg files!", Properties.Resources.AppTitleLong, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #5
0
        private void ExportTextures_Execute(object parameter)
        {
            try
            {
                int success = 0;
                int fail    = 0;
                ProgressDialogViewModel progDialogVM = new ProgressDialogViewModel(out mainView.ErpFile.ProgressPercentage, out mainView.ErpFile.ProgressStatus);
                progDialogVM.PercentageMax = Textures.Count;
                View.ProgressDialog progDialog = new View.ProgressDialog();
                progDialog.DataContext = progDialogVM;

                var task = Task.Run(() =>
                {
                    Directory.CreateDirectory(mainView.FilePath.Replace(".", "_") + "_textures");

                    for (int i = 0; i < textures.Count;)
                    {
                        string fileName = mainView.FilePath.Replace(".", "_") + "_textures" + "\\" + Path.Combine(textures[i].Texture.Folder, textures[i].Texture.FileName).Replace("?", "%3F") + ".dds";
                        ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("Exporting " + Path.GetFileName(fileName) + "... ");

                        try
                        {
                            string directoryPath = Path.GetDirectoryName(fileName);
                            if (!Directory.Exists(directoryPath))
                            {
                                Directory.CreateDirectory(directoryPath);
                            }
                            textures[i].ExportDDS(fileName, true, true);
                            ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("SUCCESS" + Environment.NewLine);
                            ++success;
                        }
                        catch
                        {
                            ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("FAIL" + Environment.NewLine);
                            ++fail;
                        }

                        ((IProgress <int>)mainView.ErpFile.ProgressPercentage).Report(++i);
                    }

                    ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report(string.Format("{0} Succeeded, {1} Failed", success, fail));
                });

                progDialog.ShowDialog();
                task.Wait();
            }
            catch
            {
                MessageBox.Show("There was an error, could not export all textures!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #6
0
        private void ImportAll_Execute(object parameter)
        {
            var dlg = new CommonOpenFileDialog
            {
                Title          = "Select a folder to import the resources from:",
                IsFolderPicker = true,

                AddToMostRecentlyUsedList = false,
                AllowNonFileSystemItems   = false,
                EnsureFileExists          = true,
                EnsurePathExists          = true,
                EnsureReadOnly            = false,
                EnsureValidNames          = true,
                Multiselect    = false,
                ShowPlacesList = true
            };

            if (dlg.ShowDialog() == CommonFileDialogResult.Ok)
            {
                try
                {
                    var progDialogVM = new ProgressDialogViewModel()
                    {
                        PercentageMax = mainView.ErpFile.Resources.Count
                    };
                    var progDialog = new View.ProgressDialog
                    {
                        DataContext = progDialogVM
                    };

                    var files = Directory.GetFiles(dlg.FileName, "*", SearchOption.AllDirectories);
                    var task  = Task.Run(() => resourceExporter.Import(mainView.ErpFile, files, progDialogVM.ProgressStatus, progDialogVM.ProgressPercentage));
                    progDialog.ShowDialog();
                    task.Wait();

                    foreach (var child in resources)
                    {
                        child.UpdateSize();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Failed Importing!" + Environment.NewLine + Environment.NewLine +
                                    ex.Message, Properties.Resources.AppTitleLong, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #7
0
        private void ImportAll_Execute(object parameter)
        {
            try
            {
                var directory = mainView.FilePath.Replace(".", "_") + "_pkgfiles";
                if (Directory.Exists(directory) == true)
                {
                    var success = 0;
                    var fail    = 0;
                    var skip    = 0;
                    var found   = false;

                    var progDialogVM = new ProgressDialogViewModel
                    {
                        PercentageMax = packages.Count
                    };
                    var progDialog = new View.ProgressDialog
                    {
                        DataContext = progDialogVM
                    };

                    var task = Task.Run(() =>
                    {
                        for (var i = 0; i < packages.Count;)
                        {
                            var resource    = packages[i].Resource;
                            var fragment    = packages[i].Fragment;
                            var folderPath  = Path.Combine(directory, resource.Folder);
                            var fileName    = ErpResourceExporter.GetFragmentFileName(resource, fragment);
                            var expFilePath = Path.Combine(folderPath, fileName) + ".json";
                            progDialogVM.ProgressStatus.Report("Importing " + fileName + "... ");

                            try
                            {
                                foreach (var filePath in Directory.GetFiles(directory, "*.json", SearchOption.AllDirectories))
                                {
                                    if (Path.Equals(filePath, expFilePath))
                                    {
                                        using var fs = File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read);
                                        packages[i].ImportPkg(fs);

                                        if (packages[i].IsSelected)
                                        {
                                            packages[i].IsSelected = false;
                                            packages[i].IsSelected = true;
                                        }
                                        found = true;
                                        break;
                                    }
                                }

                                if (found)
                                {
                                    progDialogVM.ProgressStatus.Report("SUCCESS" + Environment.NewLine);
                                    ++success;
                                }
                                else
                                {
                                    progDialogVM.ProgressStatus.Report("SKIP" + Environment.NewLine);
                                    ++skip;
                                }
                            }
                            catch
                            {
                                progDialogVM.ProgressStatus.Report("FAIL" + Environment.NewLine);
                                ++fail;
                            }

                            progDialogVM.ProgressPercentage.Report(++i);
                        }

                        progDialogVM.ProgressStatus.Report(string.Format("{0} Succeeded, {1} Skipped, {2} Failed", success, skip, fail));
                    });

                    progDialog.ShowDialog();
                    task.Wait();
                }
                else
                {
                    MessageBox.Show("Could not find pkgfiles folder!", Properties.Resources.AppTitleLong, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch
            {
                MessageBox.Show("There was an error, could not import all pkg files!", Properties.Resources.AppTitleLong, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #8
0
        private void ImportAll_Execute(object parameter)
        {
            try
            {
                string directory = mainView.FilePath.Replace(".", "_") + "_pkgfiles";
                if (Directory.Exists(directory) == true)
                {
                    int  success = 0;
                    int  fail    = 0;
                    int  skip    = 0;
                    bool found   = false;

                    ProgressDialogViewModel progDialogVM = new ProgressDialogViewModel(out mainView.ErpFile.ProgressPercentage, out mainView.ErpFile.ProgressStatus);
                    progDialogVM.PercentageMax = packages.Count;
                    View.ProgressDialog progDialog = new View.ProgressDialog();
                    progDialog.DataContext = progDialogVM;

                    var task = Task.Run(() =>
                    {
                        for (int i = 0; i < packages.Count;)
                        {
                            string fileName = directory + "\\" + Path.Combine(packages[i].Package.Folder, packages[i].Package.FileName).Replace("?", "%3F") + ".json";
                            ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("Exporting " + Path.GetFileName(fileName) + "... ");

                            try
                            {
                                foreach (string filePath in Directory.GetFiles(directory, "*.json", SearchOption.AllDirectories))
                                {
                                    if (Path.Equals(filePath, fileName))
                                    {
                                        packages[i].ImportPkg(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.Read));
                                        if (packages[i].IsSelected)
                                        {
                                            packages[i].IsSelected = false;
                                            packages[i].IsSelected = true;
                                        }
                                        found = true;
                                        break;
                                    }
                                }

                                if (found)
                                {
                                    ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("SUCCESS" + Environment.NewLine);
                                    ++success;
                                }
                                else
                                {
                                    ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("SKIP" + Environment.NewLine);
                                    ++skip;
                                }
                            }
                            catch
                            {
                                ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("FAIL" + Environment.NewLine);
                                ++fail;
                            }

                            ((IProgress <int>)mainView.ErpFile.ProgressPercentage).Report(++i);
                        }

                        ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report(string.Format("{0} Succeeded, {1} Skipped, {2} Failed", success, skip, fail));
                    });

                    progDialog.ShowDialog();
                    task.Wait();
                }
                else
                {
                    MessageBox.Show("Could not find pkgfiles folder!", Properties.Resources.AppTitleLong, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch
            {
                MessageBox.Show("There was an error, could not import all pkg files!", Properties.Resources.AppTitleLong, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #9
0
        private void ImportTextures_Execute(object parameter)
        {
            try
            {
                string directory       = mainView.FilePath.Replace(".", "_") + "_textures";
                string mipMapDirectory = mainView.FilePath.Replace(".", "_") + "_mipmaps";
                if (Directory.Exists(directory) == true)
                {
                    int  success = 0;
                    int  fail    = 0;
                    int  skip    = 0;
                    bool found   = false;

                    ProgressDialogViewModel progDialogVM = new ProgressDialogViewModel(out mainView.ErpFile.ProgressPercentage, out mainView.ErpFile.ProgressStatus);
                    progDialogVM.PercentageMax = Textures.Count;
                    View.ProgressDialog progDialog = new View.ProgressDialog();
                    progDialog.DataContext = progDialogVM;

                    var task = Task.Run(() =>
                    {
                        for (int i = 0; i < textures.Count;)
                        {
                            string fileName = mainView.FilePath.Replace(".", "_") + "_textures" + "\\" + Path.Combine(textures[i].Texture.Folder, textures[i].Texture.FileName).Replace("?", "%3F") + ".dds";
                            ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("Exporting " + Path.GetFileName(fileName) + "... ");

                            try
                            {
                                foreach (string filePath in Directory.GetFiles(directory, "*.dds", SearchOption.AllDirectories))
                                {
                                    if (Path.Equals(filePath, fileName))
                                    {
                                        string mipMapSaveLocation = filePath.Replace(directory, mipMapDirectory) + ".mipmaps";
                                        Directory.CreateDirectory(Path.GetDirectoryName(mipMapSaveLocation));
                                        textures[i].ImportDDS(filePath, mipMapSaveLocation, true);
                                        if (textures[i].IsSelected)
                                        {
                                            textures[i].GetPreview();
                                        }
                                        found = true;
                                        break;
                                    }
                                }

                                if (found)
                                {
                                    ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("SUCCESS" + Environment.NewLine);
                                    ++success;
                                }
                                else
                                {
                                    ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("SKIP" + Environment.NewLine);
                                    ++skip;
                                }
                            }
                            catch
                            {
                                ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report("FAIL" + Environment.NewLine);
                                ++fail;
                            }

                            ((IProgress <int>)mainView.ErpFile.ProgressPercentage).Report(++i);
                        }

                        ((IProgress <string>)mainView.ErpFile.ProgressStatus).Report(string.Format("{0} Succeeded, {1} Skipped, {2} Failed", success, skip, fail));
                    });

                    progDialog.ShowDialog();
                    task.Wait();
                }
                else
                {
                    MessageBox.Show("Could not find textures folder!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch
            {
                MessageBox.Show("There was an error, could not import all textures!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #10
0
        private void ImportTextures_Execute(object parameter)
        {
            try
            {
                var directory       = mainView.FilePath.Replace(".", "_") + "_textures";
                var mipMapDirectory = mainView.FilePath.Replace(".", "_") + "_mipmaps";
                if (Directory.Exists(directory) == true)
                {
                    var success = 0;
                    var fail    = 0;
                    var skip    = 0;
                    var found   = false;

                    var progDialogVM = new ProgressDialogViewModel
                    {
                        PercentageMax = Textures.Count
                    };
                    var progDialog = new View.ProgressDialog
                    {
                        DataContext = progDialogVM
                    };

                    var task = Task.Run(() =>
                    {
                        for (var i = 0; i < textures.Count;)
                        {
                            var resource    = textures[i].Resource;
                            var folderPath  = Path.Combine(directory, resource.Folder);
                            var fileName    = resource.FileName.Replace("?", "%3F");
                            var expFilePath = Path.Combine(folderPath, fileName) + ".dds";
                            progDialogVM.ProgressStatus.Report("Importing " + fileName + "... ");

                            try
                            {
                                foreach (var filePath in Directory.GetFiles(directory, "*.dds", SearchOption.AllDirectories))
                                {
                                    if (Path.Equals(filePath, expFilePath))
                                    {
                                        var mipMapSaveLocation = filePath.Replace(directory, mipMapDirectory) + ".mipmaps";
                                        Directory.CreateDirectory(Path.GetDirectoryName(mipMapSaveLocation));
                                        textures[i].ImportDDS(filePath, mipMapSaveLocation, true);
                                        if (textures[i].IsSelected)
                                        {
                                            textures[i].GetPreview();
                                        }
                                        found = true;
                                        break;
                                    }
                                }

                                if (found)
                                {
                                    progDialogVM.ProgressStatus.Report("SUCCESS" + Environment.NewLine);
                                    ++success;
                                }
                                else
                                {
                                    progDialogVM.ProgressStatus.Report("SKIP" + Environment.NewLine);
                                    ++skip;
                                }
                            }
                            catch
                            {
                                progDialogVM.ProgressStatus.Report("FAIL" + Environment.NewLine);
                                ++fail;
                            }

                            progDialogVM.ProgressPercentage.Report(++i);
                        }

                        progDialogVM.ProgressStatus.Report(string.Format("{0} Succeeded, {1} Skipped, {2} Failed", success, skip, fail));
                    });

                    progDialog.ShowDialog();
                    task.Wait();
                }
                else
                {
                    MessageBox.Show("Could not find textures folder!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            catch
            {
                MessageBox.Show("There was an error, could not import all textures!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }