Esempio n. 1
0
        private async Task GenerateCleanedESM(CleanedESM directive)
        {
            var filename = directive.To.FileName;
            var gameFile = GameFolder !.Value.Combine((RelativePath)"Data", filename);

            Info($"Generating cleaned ESM for {filename}");
            if (!gameFile.Exists)
            {
                throw new InvalidDataException($"Missing {filename} at {gameFile}");
            }
            Status($"Hashing game version of {filename}");
            var sha = await gameFile.FileHashAsync();

            if (sha != directive.SourceESMHash)
            {
                throw new InvalidDataException(
                          $"Cannot patch {filename} from the game folder because the hashes do not match. Have you already cleaned the file?");
            }

            var patchData = await LoadBytesFromPath(directive.SourceDataID);

            var toFile = OutputFolder.Combine(directive.To);

            Status($"Patching {filename}");
            using var output = toFile.Create();
            using var input  = gameFile.OpenRead();
            Utils.ApplyPatch(input, () => new MemoryStream(patchData), output);
        }
Esempio n. 2
0
        private async Task InstallIncludedFiles()
        {
            Info("Writing inline files");
            await ModList.Directives
            .OfType <InlineFile>()
            .PMap(Queue, async directive =>
            {
                Status($"Writing included file {directive.To}");
                var outPath = OutputFolder.Combine(directive.To);
                outPath.Delete();

                switch (directive)
                {
                case RemappedInlineFile file:
                    await WriteRemappedFile(file);
                    break;

                case CleanedESM esm:
                    await GenerateCleanedESM(esm);
                    break;

                default:
                    await outPath.WriteAllBytesAsync(await LoadBytesFromPath(directive.SourceDataID));
                    break;
                }
            });
        }
Esempio n. 3
0
        private void ProcessFolder(OutputFolder folder, ref Node treenode)
        {
            if (treenode == null && Slyce.Common.Utility.StringsAreEqual(folder.Name, "root", false))
            {
                treenode      = new Node();
                treenode.Text = "ROOT";
                treenode.Cells.Add(new Cell(""));
                treenode.Cells.Add(new Cell(""));
                treenode.ImageIndex = IMG_ROOT;
                treenode.Tag        = new TagInfo(folder.Id, TagInfo.FileTypes.Folder);
                treeFiles.Nodes.Add(treenode);
            }
            else if (folder.Files.Count > 0 ||
                     folder.Folders.Count > 0 &&
                     treenode.ImageIndex != IMG_ROOT)
            {
                treenode.ImageIndex = IMG_OPEN_FOLDER;
            }
            foreach (OutputFolder subFolder in folder.Folders)
            {
                // TODO: This check for a root folder can be removed once all templates have been saved without
                // the extra root folders. Remove anytime after September 2006.
                if (Slyce.Common.Utility.StringsAreEqual(subFolder.Name, "root", false))
                {
                    continue;
                }

                Node newNode = AddFolderNode(treenode, subFolder);
                ProcessFolder(subFolder, ref newNode);
            }
            foreach (OutputFile file in folder.Files)
            {
                AddFileNode(treenode, file);
            }
        }
Esempio n. 4
0
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            var FFMPEGPath      = ffmpegPath.Get(context);
            var FFMPEGDirectory = FFMPEGPath.Substring(0, FFMPEGPath.LastIndexOf('\\'));

            FFMPEGPath = '"' + FFMPEGPath + '"';
            var inputFile       = InputFile.Get(context);
            var outputFolder    = OutputFolder.Get(context);
            var outputContainer = OutputContainer.Get(context);
            var command         = Command.Get(context);
            var lutFile         = LUTFile.Get(context);
            var debuggingMode   = DebuggingMode.Get(context);

            var startInfo = new ProcessStartInfo(FFMPEGPath);

            startInfo.WindowStyle      = ProcessWindowStyle.Normal;
            startInfo.WorkingDirectory = FFMPEGDirectory;

            string inputContainer = inputFile.Substring(inputFile.LastIndexOf('.'));

            if (outputContainer == "")
            {
                outputContainer = inputContainer;
            }

            string fileNameWithoutExtensions = inputFile.Replace(inputContainer, "");
            var    fileName = fileNameWithoutExtensions.Substring(fileNameWithoutExtensions.LastIndexOf(@"\"));

            fileName = fileName.Replace(@"\", "");

            lutFile = lutFile.Replace(@"\", @"/");
            lutFile = lutFile.Replace(@":", @"\\:");

            var uniqueId = (DateTime.Now.Ticks - new DateTime(2016, 1, 1).Ticks).ToString("x");

            startInfo.Arguments = "-i " + '"' + inputFile + '"' + " " + "-vf lut3d=" + '"' + lutFile + '"' + " " + command + " " + '"' + outputFolder + @"\" + uniqueId + "." + outputContainer + '"';


            if (debuggingMode)
            {
                var processn = new Process();
                processn.StartInfo           = startInfo;
                processn.EnableRaisingEvents = true;
                processn.StartInfo.FileName  = "CMD.EXE";
                processn.StartInfo.Arguments = "/K " + '"' + @FFMPEGPath + " " + startInfo.Arguments + '"';
                processn.Start();
                processn.WaitForExit();
            }
            else
            {
                var processn = Process.Start(startInfo);
                processn.EnableRaisingEvents = true;

                processn.WaitForExit();
            }

            // Outputs
            return((ctx) => {
            });
        }
Esempio n. 5
0
            public ExitCode?Validate()
            {
                if (!Host.HasValue())
                {
                    return(ExitCode.MissingHost);
                }

                if (!Port.HasValue())
                {
                    return(ExitCode.MissingPort);
                }

                if (!int.TryParse(Port.Value(), out var port) || port > MaxPort || port < MinPort)
                {
                    return(ExitCode.InvalidPort);
                }

                if (InputFolder.HasValue() && OutputFolder.HasValue())
                {
                    return(ExitCode.IncompatibleArguments);
                }

                if (!InputFolder.HasValue() && !OutputFolder.HasValue())
                {
                    return(ExitCode.IncompatibleArguments);
                }

                return(null);
            }
        private void ProcessChildrenOfFolder(XmlNode node, OutputFolder folder)
        {
            var folderNodes = node.SelectNodes("Folder");

            if (folderNodes != null)
            {
                foreach (XmlNode child in folderNodes)
                {
                    OutputFolder childFolder = ReadFolder(child);
                    folder.Folders.Add(childFolder);
                }
            }

            // Process child files.
            var fileNodes = node.SelectNodes("StaticFile");

            if (fileNodes != null)
            {
                foreach (XmlNode child in fileNodes)
                {
                    OutputFile childFile = ReadStaticFile(child);
                    folder.Files.Add(childFile);
                }
            }

            fileNodes = node.SelectNodes("ScriptFile");
            if (fileNodes != null)
            {
                foreach (XmlNode child in fileNodes)
                {
                    OutputFile childFile = ReadScriptFile(child);
                    folder.Files.Add(childFile);
                }
            }
        }
Esempio n. 7
0
        public void InitializeEnvironment()
        {
            if (!RootWatchFolder.Exists)
            {
                RootWatchFolder.Create();
            }

            if (!NoMatchFolder.Exists)
            {
                NoMatchFolder.Create();
            }


            foreach (var tagFolder in TagFolders)
            {
                DirectoryInfo tagFolderInfo = new DirectoryInfo(Path.Combine(RootWatchFolder.FullName, tagFolder));
                if (!tagFolderInfo.Exists)
                {
                    tagFolderInfo.Create();
                }
            }

            if (!UnhandledFilesFolder.Exists)
            {
                UnhandledFilesFolder.Create();
            }

            if (!OutputFolder.Exists)
            {
                OutputFolder.Create();
            }
        }
        public void Populate()
        {
            int topNodeIndex = tgv.TopVisibleNodeIndex;

            tgv.BeginUnboundLoad();
            tgv.Nodes.Clear();
            tgv.Columns[1].Caption = System.IO.Path.GetFileName(frmTemplateSyncWizard.TheirProject.ProjectFileName) + " (external project)";
            tgv.Columns[3].Caption = System.IO.Path.GetFileName(frmTemplateSyncWizard.MyProject.ProjectFileName) + " (current project)";

            // Create the treeview
            foreach (string outputName in Project.Instance.OutputNames)
            {
                ActiproSoftware.UIStudio.TabStrip.TabStripPage page = new ActiproSoftware.UIStudio.TabStrip.TabStripPage(outputName, outputName, (int)Images.IMG_ROOT);
                page.TabSelectedBackgroundFill = new ActiproSoftware.Drawing.TwoColorLinearGradient(Color.White, System.Drawing.Color.Khaki, 0F, ActiproSoftware.Drawing.TwoColorLinearGradientStyle.Normal, ActiproSoftware.Drawing.BackgroundFillRotationType.None);
                page.EnsureTabVisible();
            }
            if (Project.Instance.OutputNames.Count == 0)
            {
                ActiproSoftware.UIStudio.TabStrip.TabStripPage page = new ActiproSoftware.UIStudio.TabStrip.TabStripPage("Default", "Default", (int)Images.IMG_ROOT);
                page.TabSelectedBackgroundFill = new ActiproSoftware.Drawing.TwoColorLinearGradient(Color.White, System.Drawing.Color.Khaki, 0F, ActiproSoftware.Drawing.TwoColorLinearGradientStyle.Normal, ActiproSoftware.Drawing.BackgroundFillRotationType.None);
                page.EnsureTabVisible();
            }
            TreeListNode rootNode2 = null;

            rootNode2            = tgv.AppendNode(new object[] { "ROOT", "", "" }, null);
            rootNode2.ImageIndex = rootNode2.SelectImageIndex = (int)Images.IMG_ROOT;

            OutputFolder rootFolderTheirs = frmTemplateSyncWizard.TheirProject.RootOutput;
            OutputFolder rootFolderMine   = frmTemplateSyncWizard.MyProject.RootOutput;

            ProcessFolderTGV(rootFolderTheirs, rootFolderMine, rootNode2);
            tgv.ExpandAll();
            tgv.TopVisibleNodeIndex = topNodeIndex;
            tgv.EndUnboundLoad();
        }
Esempio n. 9
0
        public void ReadXml(XmlReader reader)
        {
            var isEmpty = reader.IsEmptyElement;

            reader.ReadStartElement();
            if (isEmpty)
            {
                throw new XmlException("Settings were empty");
            }

            OutputFolder = reader.ReadElementString(nameof(OutputFolder));
            if (string.IsNullOrWhiteSpace(OutputFolder))
            {
                OutputFolder = RelativeDirectory;
            }
            else if (!Directory.Exists(OutputFolder))
            {
                OutputFolder = RelativeDirectory;
                Console.WriteLine("Settings directory does not exist. Resetting to relative Path.");
            }
            else if (!OutputFolder.EndsWith("\\"))
            {
                OutputFolder += "\\";
            }
            OpenFolderAfterFinished = bool.Parse(reader.ReadElementString(nameof(OpenFolderAfterFinished)));
            OverwriteExistingFiles  = bool.Parse(reader.ReadElementString(nameof(OverwriteExistingFiles)));
            Enum.TryParse(reader.ReadElementString(nameof(DisplayMode)), out DisplayMode displayMode);
            DisplayMode = displayMode;
            reader.ReadEndElement();
        }
Esempio n. 10
0
        private void CreateOutputMods()
        {
            OutputFolder.Combine("profiles")
            .EnumerateFiles(true)
            .Where(f => f.FileName == Consts.SettingsIni)
            .Do(f =>
            {
                var ini = f.LoadIniFile();
                if (ini == null)
                {
                    Utils.Log($"settings.ini is null for {f}, skipping");
                    return;
                }

                var overwrites = ini.custom_overwrites;
                if (overwrites == null)
                {
                    Utils.Log("No custom overwrites found, skipping");
                    return;
                }

                if (overwrites is SectionData data)
                {
                    data.Coll.Do(keyData =>
                    {
                        var v   = keyData.Value;
                        var mod = OutputFolder.Combine(Consts.MO2ModFolderName, (RelativePath)v);

                        mod.CreateDirectory();
                    });
                }
            });
        }
Esempio n. 11
0
 private async Task CompactFiles()
 {
     if (this.UseCompression)
     {
         await OutputFolder.CompactFolder(Queue, FileCompaction.Algorithm.XPRESS16K);
     }
 }
Esempio n. 12
0
            public void Apply(IServiceProvider serviceProvider)
            {
                var settings = serviceProvider.GetService <IOptions <Settings> >().Value;

                if (Host.HasValue())
                {
                    settings.Admin.Host = Host.Value();
                }

                if (OutputFolder.HasValue())
                {
                    settings.OutputFolder = OutputFolder.Value();
                }

                if (Port.HasValue())
                {
                    settings.Admin.Port = int.Parse(Port.Value());
                }

                settings.DryRun = DryRun.HasValue();

                if (InputFolder.HasValue())
                {
                    settings.InputFolder = InputFolder.Value();
                }
            }
Esempio n. 13
0
        public void DeleteImage(string m_name, string m_path, string m_month, string m_Thumbnail, string m_year)
        {
            string fullPath = Path.Combine(OutputFolder.Replace("Output", ""), m_path);

            File.Delete(m_Thumbnail);
            File.Delete(fullPath);
        }
Esempio n. 14
0
        private void treeFiles_AfterNodeDrop(object sender, TreeDragDropEventArgs e)
        {
            TagInfo      ti = (TagInfo)e.Node.Tag;
            OutputFolder oldParentFolder = Project.Instance.FindFolder(((TagInfo)e.OldParentNode.Tag).Id);
            OutputFolder newParentFolder = Project.Instance.FindFolder(((TagInfo)e.NewParentNode.Tag).Id);
            Node         prevNode        = e.Node.PrevNode;

            if (prevNode != null && ((TagInfo)prevNode.Tag).FileType == TagInfo.FileTypes.Folder)
            {
                // The user dropped just below a folder, so meant to add to that folder, so we must make the dragged node a child node, not a sibling.
                e.Node.PrevNode.Nodes.Add(e.Node);
                newParentFolder = Project.Instance.FindFolder(((TagInfo)prevNode.Tag).Id);
            }
            switch (ti.FileType)
            {
            case TagInfo.FileTypes.Folder:
                OutputFolder folder = Project.Instance.FindFolder(((TagInfo)e.Node.Tag).Id);
                oldParentFolder.Folders.Remove(folder);
                newParentFolder.Folders.Add(folder);
                break;

            case TagInfo.FileTypes.NormalFile:
            case TagInfo.FileTypes.ScriptFile:
                OutputFile normalFile = Project.Instance.FindFile(((TagInfo)e.Node.Tag).Id);
                oldParentFolder.RemoveFile(normalFile);
                newParentFolder.Files.Add(normalFile);
                break;

            default:
                throw new NotImplementedException("Not coded yet: " + ti.FileType);
            }
            Project.Instance.IsDirty = true;
        }
Esempio n. 15
0
 public void BuildFolderStructure()
 {
     Info("Building Folder Structure");
     ModList.Directives
     .Select(d => OutputFolder.Combine(d.To.Parent))
     .Distinct()
     .Do(f => f.CreateDirectory());
 }
Esempio n. 16
0
        public void AddNewStaticFiles()
        {
            if (treeFiles.SelectedNodes.Count == 0)
            {
                MessageBox.Show(this, "Select a folder to add this file to first.", "No Folder Selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            if (treeFiles.SelectedNodes.Count > 1)
            {
                throw new Exception("Only one node can be selected.");
            }

            Node    selectedNode = treeFiles.SelectedNodes[0];
            TagInfo ti           = (TagInfo)selectedNode.Tag;

            if (ti.FileType != TagInfo.FileTypes.Folder)
            {
                MessageBox.Show(this, "A file cannot be added as a child of a file. Select a parent folder", "No Folder Selected", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
            Cursor = Cursors.WaitCursor;

            try
            {
                Refresh();

                OpenFileDialog form = new OpenFileDialog();
                form.CheckFileExists = true;
                form.CheckPathExists = true;
                form.Multiselect     = true;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    string       id     = ((TagInfo)selectedNode.Tag).Id;
                    OutputFolder folder = Project.Instance.FindFolder(id);

                    if (folder != null)
                    {
                        foreach (var filename in form.FileNames)
                        {
                            CreateNewStaticFileAndAddItToTheTree(selectedNode, folder, filename);
                        }
                        selectedNode.Expanded = true;
                    }
                    else
                    {
                        MessageBox.Show(this, "No matching folder found.", "No matching folder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        return;
                    }
                    Project.Instance.IsDirty = true;
                }
            }
            finally
            {
                Controller.Instance.MainForm.Activate();
                Cursor = Cursors.Default;
            }
        }
        protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken)
        {
            var FFMPEGPath      = ffmpegPath.Get(context);
            var FFMPEGDirectory = FFMPEGPath.Substring(0, FFMPEGPath.LastIndexOf('\\'));

            FFMPEGPath = '"' + FFMPEGPath + '"';
            var videoFile       = VideoFile.Get(context);
            var outputFolder    = OutputFolder.Get(context);
            var outputContainer = OutputContainer.Get(context);
            var command         = Command.Get(context);
            var audioFile       = AudioFile.Get(context);
            var debuggingMode   = DebuggingMode.Get(context);

            var startInfo = new ProcessStartInfo(FFMPEGPath);

            startInfo.WindowStyle      = ProcessWindowStyle.Normal;
            startInfo.WorkingDirectory = FFMPEGDirectory;

            /*
             * string inputContainer = videoFile.Substring(videoFile.LastIndexOf('.'));
             * if (outputContainer == "")
             * {
             *  outputContainer = inputContainer;
             * }*/

            /*
             * string fileNameWithoutExtensions = videoFile.Replace(inputContainer, "");
             * var fileName = fileNameWithoutExtensions.Substring(fileNameWithoutExtensions.LastIndexOf(@"\"));
             * fileName = fileName.Replace(@"\", "");*/


            var uniqueId = (DateTime.Now.Ticks - new DateTime(2016, 1, 1).Ticks).ToString("x");

            startInfo.Arguments = "-i " + '"' + videoFile + '"' + " " + "-i " + '"' + audioFile + '"' + " -c copy -map 0:v -map 1:a -shortest " + '"' + outputFolder + @"\" + uniqueId + "." + outputContainer + '"'; // DateTime.Now.ToString("yyyy-dd-M--HH-mm-ss");

            if (debuggingMode)
            {
                var processn = new Process();
                processn.StartInfo           = startInfo;
                processn.EnableRaisingEvents = true;
                processn.StartInfo.FileName  = "CMD.EXE";
                processn.StartInfo.Arguments = "/K " + '"' + @FFMPEGPath + " " + startInfo.Arguments + '"';
                processn.Start();
                processn.WaitForExit();
            }
            else
            {
                var processn = Process.Start(startInfo);
                processn.EnableRaisingEvents = true;

                processn.WaitForExit();
            }

            // Outputs
            return((ctx) => {
            });
        }
        public void The_Load_Method_Creates_The_Correct_Outputs_JustRoot_With_Iterator()
        {
            ProjectDeserialiserV1 deserialiser = new ProjectDeserialiserV1(fileController);
            OutputFolder          rootFolder   = deserialiser.ReadOutputs(JustRootFolderWithIterator.GetXmlDocRoot());

            Assert.That(rootFolder.Name, Is.EqualTo("ROOT"));
            Assert.That(rootFolder.Id, Is.EqualTo("1"));
            Assert.That(rootFolder.IteratorType, Is.EqualTo(typeof(string)));
        }
Esempio n. 19
0
        private void CreateNewStaticFileAndAddItToTheTree(Node selectedNode, OutputFolder folder, string filename)
        {
            Project.Instance.AddIncludedFile(new IncludedFile(filename));
            OutputFile file = new OutputFile(Path.GetFileName(filename), OutputFileTypes.File, Path.GetFileName(filename), Guid.NewGuid().ToString());

            folder.AddFile(file);

            AddFileNode(selectedNode, file);
        }
Esempio n. 20
0
        private async Task InstallManualGameFiles()
        {
            if (!ModList.Directives.Any(d => d.To.StartsWith(Consts.ManualGameFilesDir)))
            {
                return;
            }

            var result = await Utils.Log(new YesNoIntervention("Some mods from this ModList must be installed directly into " +
                                                               "the game folder. Do you want to do this manually or do you want Wabbajack " +
                                                               "to do this for you?", "Move mods into game folder?")).Task;

            if (result != ConfirmationIntervention.Choice.Continue)
            {
                return;
            }

            var manualFilesDir = OutputFolder.Combine(Consts.ManualGameFilesDir);

            var gameFolder = GameInfo.TryGetGameLocation();

            Info($"Copying files from {manualFilesDir} " +
                 $"to the game folder at {gameFolder}");

            if (!manualFilesDir.Exists)
            {
                Info($"{manualFilesDir} does not exist!");
                return;
            }

            /* TODO FIX THIS
             * await manualFilesDir.EnumerateFiles().PMap(Queue, dir =>
             * {
             *  dirInfo.GetDirectories("*", SearchOption.AllDirectories).Do(d =>
             *  {
             *      var destPath = d.FullName.Replace(manualFilesDir, gameFolder);
             *      Status($"Creating directory {destPath}");
             *      Directory.CreateDirectory(destPath);
             *  });
             *
             *  dirInfo.GetFiles("*", SearchOption.AllDirectories).Do(f =>
             *  {
             *      var destPath = f.FullName.Replace(manualFilesDir, gameFolder);
             *      Status($"Copying file {f.FullName} to {destPath}");
             *      try
             *      {
             *          File.Copy(f.FullName, destPath);
             *      }
             *      catch (Exception)
             *      {
             *          Info($"Could not copy file {f.FullName} to {destPath}. The file may already exist, skipping...");
             *      }
             *  });
             * });
             *
             */
        }
        private void btAdd_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog dlg = new FolderBrowserDialog();

            if (dlg.ShowDialog(this) == DialogResult.OK)
            {
                OutputFolder f = new OutputFolder(false, dlg.SelectedPath);
                checkedListBox1.Items.Add(f, true);
            }
        }
Esempio n. 22
0
        private void DeleteFocusedNodes()
        {
            Controller.ShadeMainForm();
            treeFiles.BeginUpdate();
            try
            {
                if (MessageBox.Show(this, "Delete selected files?", "Delete", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes)
                {
                    List <int> selectedIndexes = new List <int>();
                    Node       parentNode      = null;

                    foreach (Node node in treeFiles.SelectedNodes)
                    {
                        selectedIndexes.Add(node.Index);

                        if (parentNode == null)
                        {
                            parentNode = node.Parent;
                        }
                    }
                    for (int i = selectedIndexes.Count - 1; i >= 0; i--)
                    {
                        TagInfo ti = (TagInfo)parentNode.Nodes[selectedIndexes[i]].Tag;

                        if (ti.FileType == TagInfo.FileTypes.Folder)
                        {
                            OutputFolder folder = Project.Instance.FindFolder(ti.Id);

                            if (folder != null)
                            {
                                Project.Instance.RemoveFolder(folder);
                                parentNode.Nodes.RemoveAt(selectedIndexes[i]);
                            }
                        }
                        else                         // Is a file
                        {
                            OutputFile   file   = Project.Instance.FindFile(ti.Id);
                            OutputFolder folder = Project.Instance.FindFolder(((TagInfo)parentNode.Tag).Id);

                            if (folder != null && file != null)
                            {
                                folder.RemoveFile(file);
                                parentNode.Nodes.RemoveAt(selectedIndexes[i]);
                            }
                        }
                    }
                }
            }
            finally
            {
                treeFiles.EndUpdate();
                Controller.UnshadeMainForm();
            }
        }
        public void The_Load_Method_Creates_The_Correct_Outputs_SubFolder()
        {
            ProjectDeserialiserV1 deserialiser = new ProjectDeserialiserV1(fileController);
            OutputFolder          rootFolder   = deserialiser.ReadOutputs(RootFolderWithSubFolder.GetXmlDocRoot());

            Assert.That(rootFolder.Folders, Has.Count(1));
            var subfolder = rootFolder.Folders[0];

            Assert.That(subfolder.Name, Is.EqualTo("Sub"));
            Assert.That(subfolder.Id, Is.EqualTo("2"));
            Assert.That(subfolder.IteratorType, Is.Null);
        }
Esempio n. 24
0
        protected override void Execute(CodeActivityContext context)
        {
            try
            {
                string outFolder   = OutputFolder.Get(context);
                string _imagePath  = ImagePath.Get(context);
                string _targetType = Convert_To_Type.Get(context).ToLower();
                string _destPath   = _imagePath; // default value

                if (System.IO.File.Exists(ImagePath.Get(context)))
                {
                    var sourceImg = System.Drawing.Image.FromFile(_imagePath);
                    if (Directory.Exists(outFolder) == false)
                    {
                        outFolder = Path.GetDirectoryName(_imagePath);
                    }

                    _destPath = outFolder + "\\" + Path.GetFileNameWithoutExtension(_imagePath) + "." + _targetType;



                    switch (_targetType)
                    {
                    case "jpg":
                        sourceImg.Save(_destPath, ImageFormat.Jpeg);
                        break;

                    case "png":
                        sourceImg.Save(_destPath, ImageFormat.Png);
                        break;

                    case "bmp":
                        sourceImg.Save(_destPath, ImageFormat.Bmp);
                        break;

                    case "gif":
                        sourceImg.Save(_destPath, ImageFormat.Gif);
                        break;

                    default:
                        Console.WriteLine("Conversion Type Not Supported. Supported types are  jpg, png, gif, bmp");
                        break;
                    }
                    ConvertedFilePath.Set(context, _destPath);
                    Console.WriteLine("File saved as " + _destPath);
                }
            }

            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + "Source" + ex.Source);
            }
        }
Esempio n. 25
0
        private void SetScreenSizeInPrefs()
        {
            if (SystemParameters == null)
            {
                throw new ArgumentNullException("System Parameters was null.  Cannot set screen size prefs");
            }
            var config = new IniParserConfiguration {
                AllowDuplicateKeys = true, AllowDuplicateSections = true
            };

            foreach (var file in OutputFolder.Combine("profiles").EnumerateFiles()
                     .Where(f => ((string)f.FileName).EndsWith("refs.ini")))
            {
                try
                {
                    var  parser   = new FileIniDataParser(new IniDataParser(config));
                    var  data     = parser.ReadFile((string)file);
                    bool modified = false;
                    if (data.Sections["Display"] != null)
                    {
                        if (data.Sections["Display"]["iSize W"] != null && data.Sections["Display"]["iSize H"] != null)
                        {
                            data.Sections["Display"]["iSize W"] =
                                SystemParameters.ScreenWidth.ToString(CultureInfo.CurrentCulture);
                            data.Sections["Display"]["iSize H"] =
                                SystemParameters.ScreenHeight.ToString(CultureInfo.CurrentCulture);
                            modified = true;
                        }
                    }
                    if (data.Sections["MEMORY"] != null)
                    {
                        if (data.Sections["MEMORY"]["VideoMemorySizeMb"] != null)
                        {
                            data.Sections["MEMORY"]["VideoMemorySizeMb"] =
                                SystemParameters.EnbLEVRAMSize.ToString(CultureInfo.CurrentCulture);
                            modified = true;
                        }
                    }

                    if (modified)
                    {
                        parser.WriteFile((string)file, data);
                    }
                }
                catch (Exception)
                {
                    Utils.Log($"Skipping screen size remap for {file} due to parse error.");
                }
            }
        }
Esempio n. 26
0
        private Node AddFolderNode(Node parentNode, OutputFolder subFolder)
        {
            string iteratorName = subFolder.IteratorType == null ? "" : subFolder.IteratorType.FullName;
            Node   newNode      = new Node();

            newNode.Text            = subFolder.Name;
            newNode.DragDropEnabled = true;
            newNode.Cells.Add(new Cell(""));
            newNode.Cells.Add(new Cell(iteratorName));
            newNode.ImageIndex = IMG_CLOSED_FOLDER;
            newNode.Tag        = new TagInfo(subFolder.Id, TagInfo.FileTypes.Folder);
            parentNode.Nodes.Add(newNode);
            return(newNode);
        }
        public void The_Load_Method_Creates_The_Correct_Outputs_SubFolder_With_File()
        {
            ProjectDeserialiserV1 deserialiser = new ProjectDeserialiserV1(fileController);
            OutputFolder          rootFolder   = deserialiser.ReadOutputs(SubFolderWithFile.GetXmlDocRoot());

            Assert.That(rootFolder.Folders, Has.Count(1));
            var subfolder = rootFolder.Folders[0];

            Assert.That(subfolder.Files, Has.Count(1));
            var file = subfolder.Files[0];

            Assert.That(file.Name, Is.EqualTo("A1"));
            Assert.That(file.Id, Is.EqualTo("3"));
            Assert.That(file.ScriptName, Is.EqualTo("script-1"));
        }
Esempio n. 28
0
 private void OnDeserialized(StreamingContext c)
 {
     //try to map old ones to the new format. Best effort here.
     if (IsFalconFormat && string.IsNullOrEmpty(FalconOutputFolder))
     {
         if (OutputFolder.EndsWith("sequences") || OutputFolder.EndsWith("sequences/"))
         {
             var path = Directory.GetParent(OutputFolder).FullName;
             //if(Directory.Exists(path))
             //{
             FalconOutputFolder = path;
             //}
         }
     }
 }
        private bool FoldersAreDifferent(OutputFolder folder1, OutputFolder folder2)
        {
            bool differenceExists = false;

            if (folder1 != null && folder2 != null)
            {
                //if (folder1.IteratorType != folder2.IteratorType) { differenceExists = true; }
                if (folder1.Name != folder2.Name)
                {
                    differenceExists = true;
                }
                //if (folder1.OutputNames != folder2.OutputNames) { differenceExists = true; }
            }
            return(differenceExists);
        }
Esempio n. 30
0
        private async Task InstallIncludedFiles()
        {
            Info("Writing inline files");
            await ModList.Directives.OfType <InlineFile>()
            .PMap(Queue, async directive =>
            {
                if (directive.To.Extension == Consts.MetaFileExtension)
                {
                    return;
                }

                Info($"Writing included file {directive.To}");
                var outPath = OutputFolder.Combine(directive.To);
                outPath.Delete();
                await outPath.WriteAllBytesAsync(await LoadBytesFromPath(directive.SourceDataID));
            });
        }