You've already forked TranslationApp
mirror of
https://github.com/lifebottle/TranslationApp.git
synced 2026-02-13 15:25:58 -08:00
64 lines
1.8 KiB
C#
64 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace TranslationLib
|
|
{
|
|
public class TranslationProject
|
|
{
|
|
public string ProjectPath { get; }
|
|
public List<XMLFolder> XmlFolders { get; set; }
|
|
public XMLFolder CurrentFolder { get; set; }
|
|
public bool isLegacy { get; set; }
|
|
|
|
public TranslationProject(string basePath, List<string> folderIncluded, bool legacy)
|
|
{
|
|
ProjectPath = basePath;
|
|
XmlFolders = new List<XMLFolder>();
|
|
isLegacy = legacy;
|
|
|
|
foreach (var folder in folderIncluded)
|
|
{
|
|
string fullPath = Path.Combine(basePath, folder, "");
|
|
var files = Directory.GetFiles(fullPath);
|
|
if (files.Count() != 0 && files.Any(x => x.EndsWith(".xml", StringComparison.OrdinalIgnoreCase)))
|
|
{
|
|
XmlFolders.Add(new XMLFolder(folder, fullPath, legacy));
|
|
}
|
|
}
|
|
|
|
if (XmlFolders.Count == 0)
|
|
{
|
|
CurrentFolder = null;
|
|
return;
|
|
}
|
|
|
|
foreach (var xmlFolder in XmlFolders)
|
|
xmlFolder.LoadXMLs();
|
|
|
|
CurrentFolder = XmlFolders.First();
|
|
}
|
|
|
|
public XMLFolder GetFolderByName(string name)
|
|
{
|
|
return XmlFolders.First(x => x.Name == name);
|
|
}
|
|
|
|
public List<string> GetFolderNames()
|
|
{
|
|
return XmlFolders.Select(x => x.Name).ToList();
|
|
}
|
|
|
|
public void SetCurrentFolder(string name)
|
|
{
|
|
CurrentFolder = XmlFolders.First(x => x.Name == name);
|
|
}
|
|
|
|
public int GetFolderId(string name)
|
|
{
|
|
return XmlFolders.FindIndex(x => x.Name == name);
|
|
}
|
|
|
|
}
|
|
} |