mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2025-01-31 13:01:39 +01:00
[Configuration] - Cache directory
Suffix everyting out with 'Directory'
This commit is contained in:
parent
b0d0fe0223
commit
3397886a46
@ -12,43 +12,32 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
private static readonly Lazy<Configuration> Instance = new Lazy<Configuration>(() => new Configuration());
|
||||
|
||||
private readonly string _baseDir;
|
||||
private readonly string _dataDir;
|
||||
private readonly Lazy<Settings> _settings;
|
||||
private readonly IEnumerable<Encoding> _encodings;
|
||||
|
||||
public static readonly string BaseDirectory = GetBaseDirectory();
|
||||
public static readonly string DataDirectory = GetDataDirectory();
|
||||
public static readonly string TesseractOriginalDirectory = BaseDirectory + "Tesseract" + Path.DirectorySeparatorChar;
|
||||
public static readonly string DictionariesDirectory = DataDirectory + "Dictionaries" + Path.DirectorySeparatorChar;
|
||||
public static readonly string SpectrogramsDirectory = DataDirectory + "Spectrograms" + Path.DirectorySeparatorChar;
|
||||
public static readonly string SceneChangesDirectory = DataDirectory + "SceneChanges" + Path.DirectorySeparatorChar;
|
||||
public static readonly string AutoBackupDirectory = DataDirectory + "AutoBackup" + Path.DirectorySeparatorChar;
|
||||
public static readonly string VobSubCompareDirectory = DataDirectory + "VobSub" + Path.DirectorySeparatorChar;
|
||||
public static readonly string TesseractDirectory = DataDirectory + "Tesseract" + Path.DirectorySeparatorChar;
|
||||
public static readonly string WaveformsDirectory = DataDirectory + "Waveforms" + Path.DirectorySeparatorChar;
|
||||
public static readonly string PluginsDirectory = DataDirectory + "Plugins" + Path.DirectorySeparatorChar;
|
||||
public static readonly string IconsDirectory = BaseDirectory + "Icons" + Path.DirectorySeparatorChar;
|
||||
public static readonly string OcrDirectory = DataDirectory + "Ocr" + Path.DirectorySeparatorChar;
|
||||
public static readonly string SettingFileName = DataDirectory + "Settings.xml";
|
||||
public static readonly string TesseractDataDirectory = GetTesseractDataDirectory();
|
||||
|
||||
|
||||
private Configuration()
|
||||
{
|
||||
_baseDir = GetBaseDirectory();
|
||||
_dataDir = GetDataDirectory();
|
||||
_encodings = GetAvailableEncodings();
|
||||
_settings = new Lazy<Settings>(Settings.GetSettings);
|
||||
}
|
||||
|
||||
public static string SettingsFileName
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "Settings.xml";
|
||||
}
|
||||
}
|
||||
|
||||
public static string DictionariesFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "Dictionaries" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string IconsFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return BaseDirectory + "Icons" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsRunningOnLinux()
|
||||
{
|
||||
return Environment.OSVersion.Platform == PlatformID.Unix && !IsRunningOnMac();
|
||||
@ -64,110 +53,6 @@ namespace Nikse.SubtitleEdit.Core
|
||||
Directory.Exists("/Users"));
|
||||
}
|
||||
|
||||
public static string TesseractDataFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsRunningOnLinux() || IsRunningOnMac())
|
||||
{
|
||||
if (Directory.Exists("/usr/share/tesseract-ocr/tessdata"))
|
||||
return "/usr/share/tesseract-ocr/tessdata";
|
||||
if (Directory.Exists("/usr/share/tesseract/tessdata"))
|
||||
return "/usr/share/tesseract/tessdata";
|
||||
if (Directory.Exists("/usr/share/tessdata"))
|
||||
return "/usr/share/tessdata";
|
||||
}
|
||||
return TesseractFolder + "tessdata";
|
||||
}
|
||||
}
|
||||
|
||||
public static string TesseractOriginalFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return BaseDirectory + "Tesseract" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string TesseractFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "Tesseract" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string VobSubCompareFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "VobSub" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string OcrFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "Ocr" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string WaveformsFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "Waveforms" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string SpectrogramsFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "Spectrograms" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string SceneChangesFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "SceneChanges" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string AutoBackupFolder
|
||||
{
|
||||
get
|
||||
{
|
||||
return DataDirectory + "AutoBackup" + Path.DirectorySeparatorChar;
|
||||
}
|
||||
}
|
||||
|
||||
public static string PluginsDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return Path.Combine(DataDirectory, "Plugins");
|
||||
}
|
||||
}
|
||||
|
||||
public static string DataDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return Instance.Value._dataDir;
|
||||
}
|
||||
}
|
||||
|
||||
public static string BaseDirectory
|
||||
{
|
||||
get
|
||||
{
|
||||
return Instance.Value._baseDir;
|
||||
}
|
||||
}
|
||||
|
||||
public static Settings Settings
|
||||
{
|
||||
@ -215,20 +100,20 @@ namespace Nikse.SubtitleEdit.Core
|
||||
: baseDirectory + Path.DirectorySeparatorChar;
|
||||
}
|
||||
|
||||
private string GetDataDirectory()
|
||||
private static string GetDataDirectory()
|
||||
{
|
||||
var appDataRoamingPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Subtitle Edit");
|
||||
|
||||
if (IsRunningOnLinux() || IsRunningOnMac())
|
||||
{
|
||||
if (!Directory.Exists(appDataRoamingPath) && !File.Exists(Path.Combine(_baseDir, ".PACKAGE-MANAGER")))
|
||||
if (!Directory.Exists(appDataRoamingPath) && !File.Exists(Path.Combine(BaseDirectory, ".PACKAGE-MANAGER")))
|
||||
{
|
||||
try
|
||||
{
|
||||
var path = Path.Combine(Directory.CreateDirectory(Path.Combine(_baseDir, "Dictionaries")).FullName, "not-a-word-list");
|
||||
var path = Path.Combine(Directory.CreateDirectory(Path.Combine(BaseDirectory, "Dictionaries")).FullName, "not-a-word-list");
|
||||
File.Create(path).Close();
|
||||
File.Delete(path);
|
||||
return _baseDir; // user installation
|
||||
return BaseDirectory; // user installation
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -239,13 +124,13 @@ namespace Nikse.SubtitleEdit.Core
|
||||
}
|
||||
|
||||
var installerPath = GetInstallerPath();
|
||||
var hasUninstallFiles = Directory.GetFiles(_baseDir, "unins*.*").Length > 0;
|
||||
var hasDictionaryFolder = Directory.Exists(Path.Combine(_baseDir, "Dictionaries"));
|
||||
var hasUninstallFiles = Directory.GetFiles(BaseDirectory, "unins*.*").Length > 0;
|
||||
var hasDictionaryFolder = Directory.Exists(Path.Combine(BaseDirectory, "Dictionaries"));
|
||||
|
||||
if ((installerPath == null || !installerPath.TrimEnd(Path.DirectorySeparatorChar).Equals(_baseDir.TrimEnd(Path.DirectorySeparatorChar), StringComparison.OrdinalIgnoreCase))
|
||||
if ((installerPath == null || !installerPath.TrimEnd(Path.DirectorySeparatorChar).Equals(BaseDirectory.TrimEnd(Path.DirectorySeparatorChar), StringComparison.OrdinalIgnoreCase))
|
||||
&& !hasUninstallFiles && (hasDictionaryFolder || !Directory.Exists(Path.Combine(appDataRoamingPath, "Dictionaries"))))
|
||||
{
|
||||
return _baseDir;
|
||||
return BaseDirectory;
|
||||
}
|
||||
|
||||
if (Directory.Exists(appDataRoamingPath))
|
||||
@ -265,6 +150,20 @@ namespace Nikse.SubtitleEdit.Core
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetTesseractDataDirectory()
|
||||
{
|
||||
if (IsRunningOnLinux() || IsRunningOnMac())
|
||||
{
|
||||
if (Directory.Exists("/usr/share/tesseract-ocr/tessdata"))
|
||||
return "/usr/share/tesseract-ocr/tessdata";
|
||||
if (Directory.Exists("/usr/share/tesseract/tessdata"))
|
||||
return "/usr/share/tesseract/tessdata";
|
||||
if (Directory.Exists("/usr/share/tessdata"))
|
||||
return "/usr/share/tessdata";
|
||||
}
|
||||
return TesseractDirectory + "tessdata";
|
||||
}
|
||||
|
||||
private static IEnumerable<Encoding> GetAvailableEncodings()
|
||||
{
|
||||
var encodings = new List<Encoding>();
|
||||
|
@ -78,7 +78,7 @@ namespace Nikse.SubtitleEdit.Core.Dictionaries
|
||||
|
||||
public static OcrFixReplaceList FromLanguageId(string languageId)
|
||||
{
|
||||
return new OcrFixReplaceList(Configuration.DictionariesFolder + languageId + "_OCRFixReplaceList.xml");
|
||||
return new OcrFixReplaceList(Configuration.DictionariesDirectory + languageId + "_OCRFixReplaceList.xml");
|
||||
}
|
||||
|
||||
private static Dictionary<string, string> LoadReplaceList(XmlDocument doc, string name)
|
||||
|
@ -10,7 +10,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
|
||||
private static string GetSceneChangesFileName(string videoFileName)
|
||||
{
|
||||
var dir = Configuration.SceneChangesFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
var dir = Configuration.SceneChangesDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
|
@ -1183,7 +1183,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public void Save()
|
||||
{
|
||||
//this is too slow: Serialize(Configuration.SettingsFileName, this);
|
||||
CustomSerialize(Configuration.SettingsFileName, this);
|
||||
CustomSerialize(Configuration.SettingFileName, this);
|
||||
}
|
||||
|
||||
//private static void Serialize(string fileName, Settings settings)
|
||||
@ -1197,7 +1197,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
public static Settings GetSettings()
|
||||
{
|
||||
var settings = new Settings();
|
||||
var settingsFileName = Configuration.SettingsFileName;
|
||||
var settingsFileName = Configuration.SettingFileName;
|
||||
if (File.Exists(settingsFileName))
|
||||
{
|
||||
try
|
||||
|
@ -36,7 +36,7 @@ namespace Nikse.SubtitleEdit.Core.SpellCheck
|
||||
|
||||
_languageName = languageName;
|
||||
_doSpell = doSpell;
|
||||
_namesList = new NamesList(Configuration.DictionariesFolder, languageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
_namesList = new NamesList(Configuration.DictionariesDirectory, languageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
_namesEtcList = _namesList.GetNames();
|
||||
var namesEtcMultiWordList = _namesList.GetMultiNames();
|
||||
|
||||
@ -266,7 +266,7 @@ namespace Nikse.SubtitleEdit.Core.SpellCheck
|
||||
if (!word.EndsWith('\''))
|
||||
_namesEtcListWithApostrophe.Add(word + "'");
|
||||
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, _languageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesList = new NamesList(Configuration.DictionariesDirectory, _languageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
namesList.Add(word);
|
||||
return true;
|
||||
}
|
||||
|
@ -720,7 +720,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
get
|
||||
{
|
||||
return Configuration.DictionariesFolder;
|
||||
return Configuration.DictionariesDirectory;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
public static string GetPeakWaveFileName(string videoFileName)
|
||||
{
|
||||
var dir = Configuration.WaveformsFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
var dir = Configuration.WaveformsDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
@ -804,7 +804,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
|
||||
public static string GetSpectrogramFolder(string videoFileName)
|
||||
{
|
||||
var dir = Configuration.SpectrogramsFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
var dir = Configuration.SpectrogramsDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
if (!Directory.Exists(dir))
|
||||
Directory.CreateDirectory(dir);
|
||||
|
||||
|
@ -127,7 +127,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (string.IsNullOrEmpty(languageName))
|
||||
languageName = "en_US";
|
||||
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, languageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesList = new NamesList(Configuration.DictionariesDirectory, languageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
if (namesList.Add(textBoxAddName.Text))
|
||||
DialogResult = DialogResult.OK;
|
||||
else
|
||||
|
@ -59,7 +59,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
internal void FixCasing(Subtitle subtitle, string language)
|
||||
{
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesList = new NamesList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesEtc = namesList.GetAllNames();
|
||||
|
||||
// Longer names must be first
|
||||
|
@ -114,7 +114,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (string.IsNullOrEmpty(language))
|
||||
language = "en_US";
|
||||
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesList = new NamesList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
|
||||
// Will contains both one word names and multi names
|
||||
var namesEtcList = namesList.GetAllNames();
|
||||
|
@ -29,7 +29,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
|
||||
|
||||
radioButtonRegEx.Left = radioButtonText.Left + radioButtonText.Width + 10;
|
||||
foreach (string fileName in Directory.GetFiles(Configuration.DictionariesFolder, "*_NoBreakAfterList.xml"))
|
||||
foreach (string fileName in Directory.GetFiles(Configuration.DictionariesDirectory, "*_NoBreakAfterList.xml"))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -533,7 +533,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string languageTwoLetterCode = LanguageAutoDetect.AutoDetectGoogleLanguage(Subtitle);
|
||||
|
||||
// Will contains both one word names and multi names
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, languageTwoLetterCode, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesList = new NamesList(Configuration.DictionariesDirectory, languageTwoLetterCode, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
_namesEtcList = namesList.GetAllNames();
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
string dictionaryFolder = Configuration.TesseractDataFolder;
|
||||
string dictionaryFolder = Configuration.TesseractDataDirectory;
|
||||
if (!Directory.Exists(dictionaryFolder))
|
||||
Directory.CreateDirectory(dictionaryFolder);
|
||||
|
||||
@ -185,7 +185,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
string dictionaryFolder = Configuration.TesseractDataFolder;
|
||||
string dictionaryFolder = Configuration.TesseractDataDirectory;
|
||||
if (!Directory.Exists(dictionaryFolder))
|
||||
Directory.CreateDirectory(dictionaryFolder);
|
||||
|
||||
@ -212,7 +212,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void linkLabelOpenDictionaryFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
string dictionaryFolder = Configuration.TesseractDataFolder;
|
||||
string dictionaryFolder = Configuration.TesseractDataDirectory;
|
||||
if (!Directory.Exists(dictionaryFolder))
|
||||
Directory.CreateDirectory(dictionaryFolder);
|
||||
|
||||
|
@ -3988,7 +3988,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private static void TryLoadIcon(ToolStripButton button, string iconName)
|
||||
{
|
||||
string fullPath = Configuration.IconsFolder + iconName + ".png";
|
||||
string fullPath = Configuration.IconsDirectory + iconName + ".png";
|
||||
if (File.Exists(fullPath))
|
||||
button.Image = new Bitmap(fullPath);
|
||||
}
|
||||
@ -15305,25 +15305,25 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_textAutoSave = _changeSubtitleToString;
|
||||
if (!string.IsNullOrEmpty(_textAutoSave) && currentText.Trim() != _textAutoSave.Trim() && !string.IsNullOrWhiteSpace(currentText))
|
||||
{
|
||||
if (!Directory.Exists(Configuration.AutoBackupFolder))
|
||||
if (!Directory.Exists(Configuration.AutoBackupDirectory))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Configuration.AutoBackupFolder);
|
||||
Directory.CreateDirectory(Configuration.AutoBackupDirectory);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(string.Format(_language.UnableToCreateBackupDirectory, Configuration.AutoBackupFolder, exception.Message));
|
||||
MessageBox.Show(string.Format(_language.UnableToCreateBackupDirectory, Configuration.AutoBackupDirectory, exception.Message));
|
||||
return;
|
||||
}
|
||||
}
|
||||
string title = string.Empty;
|
||||
if (!string.IsNullOrEmpty(_fileName))
|
||||
title = "_" + Path.GetFileNameWithoutExtension(_fileName);
|
||||
string fileName = string.Format("{0}{1:0000}-{2:00}-{3:00}_{4:00}-{5:00}-{6:00}{7}{8}", Configuration.AutoBackupFolder, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, title, GetCurrentSubtitleFormat().Extension);
|
||||
string fileName = string.Format("{0}{1:0000}-{2:00}-{3:00}_{4:00}-{5:00}-{6:00}{7}{8}", Configuration.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, title, GetCurrentSubtitleFormat().Extension);
|
||||
File.WriteAllText(fileName, currentText);
|
||||
|
||||
RestoreAutoBackup.CleanAutoBackupFolder(Configuration.AutoBackupFolder, Configuration.Settings.General.AutoBackupDeleteAfterMonths);
|
||||
RestoreAutoBackup.CleanAutoBackupFolder(Configuration.AutoBackupDirectory, Configuration.Settings.General.AutoBackupDeleteAfterMonths);
|
||||
}
|
||||
}
|
||||
_textAutoSave = currentText;
|
||||
@ -15337,11 +15337,11 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_textAutoSaveOriginal = _changeSubtitleToString;
|
||||
if (!string.IsNullOrEmpty(_textAutoSaveOriginal) && currentTextAlternate.Trim() != _textAutoSaveOriginal.Trim() && !string.IsNullOrWhiteSpace(currentTextAlternate))
|
||||
{
|
||||
if (!Directory.Exists(Configuration.AutoBackupFolder))
|
||||
if (!Directory.Exists(Configuration.AutoBackupDirectory))
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.CreateDirectory(Configuration.AutoBackupFolder);
|
||||
Directory.CreateDirectory(Configuration.AutoBackupDirectory);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@ -15350,7 +15350,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string title = string.Empty;
|
||||
if (!string.IsNullOrEmpty(_subtitleAlternateFileName))
|
||||
title = "_" + Path.GetFileNameWithoutExtension(_subtitleAlternateFileName);
|
||||
string fileName = string.Format("{0}{1:0000}-{2:00}-{3:00}_{4:00}-{5:00}-{6:00}{7}{8}", Configuration.AutoBackupFolder, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, "_Original" + title, GetCurrentSubtitleFormat().Extension);
|
||||
string fileName = string.Format("{0}{1:0000}-{2:00}-{3:00}_{4:00}-{5:00}-{6:00}{7}{8}", Configuration.AutoBackupDirectory, DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second, "_Original" + title, GetCurrentSubtitleFormat().Extension);
|
||||
File.WriteAllText(fileName, currentTextAlternate);
|
||||
}
|
||||
}
|
||||
@ -19036,7 +19036,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (ContinueNewOrExit())
|
||||
{
|
||||
OpenSubtitle(restoreAutoBackup.AutoBackupFileName, null);
|
||||
_fileName = _fileName.Remove(0, Configuration.AutoBackupFolder.Length).TrimStart(Path.DirectorySeparatorChar);
|
||||
_fileName = _fileName.Remove(0, Configuration.AutoBackupDirectory.Length).TrimStart(Path.DirectorySeparatorChar);
|
||||
_converted = true;
|
||||
SetTitle();
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void RestoreAutoBackup_Shown(object sender, EventArgs e)
|
||||
{
|
||||
listViewBackups.Columns[2].Width = -2;
|
||||
if (Directory.Exists(Configuration.AutoBackupFolder))
|
||||
if (Directory.Exists(Configuration.AutoBackupDirectory))
|
||||
{
|
||||
_files = Directory.GetFiles(Configuration.AutoBackupFolder, "*.*");
|
||||
_files = Directory.GetFiles(Configuration.AutoBackupDirectory, "*.*");
|
||||
foreach (string fileName in _files)
|
||||
{
|
||||
if (RegexFileNamePattern.IsMatch(Path.GetFileName(fileName)))
|
||||
@ -122,7 +122,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void linkLabelOpenContainingFolder_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||
{
|
||||
string folderName = Configuration.AutoBackupFolder;
|
||||
string folderName = Configuration.AutoBackupDirectory;
|
||||
if (Utilities.IsRunningOnMono())
|
||||
{
|
||||
System.Diagnostics.Process.Start(folderName);
|
||||
|
@ -879,8 +879,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void InitializeWaveformsAndSpectrogramsFolderEmpty(LanguageStructure.Settings language)
|
||||
{
|
||||
string waveformsFolder = Configuration.WaveformsFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
string spectrogramsFolder = Configuration.SpectrogramsFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
string waveformsFolder = Configuration.WaveformsDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
string spectrogramsFolder = Configuration.SpectrogramsDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
long bytes = 0;
|
||||
int count = 0;
|
||||
|
||||
@ -1459,7 +1459,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var task = Task.Factory.StartNew(() =>
|
||||
{
|
||||
// names etc
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesList = new NamesList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
_wordListNamesEtc = namesList.GetAllNames();
|
||||
_wordListNamesEtc.Sort();
|
||||
return _wordListNamesEtc;
|
||||
@ -1494,7 +1494,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string text = textBoxNameEtc.Text.RemoveControlCharacters().Trim();
|
||||
if (!string.IsNullOrEmpty(language) && text.Length > 1 && !_wordListNamesEtc.Contains(text))
|
||||
{
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesList = new NamesList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
namesList.Add(text);
|
||||
LoadNamesEtc(language, true);
|
||||
labelStatus.Text = string.Format(Configuration.Settings.Language.Settings.WordAddedX, text);
|
||||
@ -1543,7 +1543,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (result == DialogResult.Yes)
|
||||
{
|
||||
int removeCount = 0;
|
||||
var namesList = new NamesList(Configuration.DictionariesFolder, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
var namesList = new NamesList(Configuration.DictionariesDirectory, language, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
for (int idx = listBoxNamesEtc.SelectedIndices.Count - 1; idx >= 0; idx--)
|
||||
{
|
||||
index = listBoxNamesEtc.SelectedIndices[idx];
|
||||
@ -1940,7 +1940,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void buttonWaveformsFolderEmpty_Click(object sender, EventArgs e)
|
||||
{
|
||||
string waveformsFolder = Configuration.WaveformsFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
string waveformsFolder = Configuration.WaveformsDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
if (Directory.Exists(waveformsFolder))
|
||||
{
|
||||
var di = new DirectoryInfo(waveformsFolder);
|
||||
@ -1958,7 +1958,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
string spectrogramsFolder = Configuration.SpectrogramsFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
string spectrogramsFolder = Configuration.SpectrogramsDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
if (Directory.Exists(spectrogramsFolder))
|
||||
{
|
||||
var di = new DirectoryInfo(spectrogramsFolder);
|
||||
@ -2375,7 +2375,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void numericUpDownMaxNumberOfLines_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
checkBoxSyntaxColorTextMoreThanTwoLines.Text = string.Format(Configuration.Settings.Language.Settings.SyntaxColorTextMoreThanMaxLines, numericUpDownMaxNumberOfLines.Value);
|
||||
checkBoxSyntaxColorTextMoreThanTwoLines.Text = string.Format(Configuration.Settings.Language.Settings.SyntaxColorTextMoreThanMaxLines, numericUpDownMaxNumberOfLines.Value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
labelImageInfo.Text = string.Empty;
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.AutoSize;
|
||||
|
||||
_directoryPath = Configuration.VobSubCompareFolder + databaseFolderName + Path.DirectorySeparatorChar;
|
||||
_directoryPath = Configuration.VobSubCompareDirectory + databaseFolderName + Path.DirectorySeparatorChar;
|
||||
if (!File.Exists(_directoryPath + "Images.xml"))
|
||||
_compareDoc.LoadXml("<OcrBitmaps></OcrBitmaps>");
|
||||
else
|
||||
|
@ -833,7 +833,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_ocrMethodIndex == _ocrMethodBinaryImageCompare)
|
||||
{
|
||||
string characterDatabasePath = Configuration.OcrFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
string characterDatabasePath = Configuration.OcrDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
if (!Directory.Exists(characterDatabasePath))
|
||||
Directory.CreateDirectory(characterDatabasePath);
|
||||
|
||||
@ -869,7 +869,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else if (_ocrMethodIndex == _ocrMethodImageCompare)
|
||||
{
|
||||
comboBoxCharacterDatabase.SelectedIndexChanged -= ComboBoxCharacterDatabaseSelectedIndexChanged;
|
||||
string characterDatabasePath = Configuration.VobSubCompareFolder.TrimEnd(Path.DirectorySeparatorChar);
|
||||
string characterDatabasePath = Configuration.VobSubCompareDirectory.TrimEnd(Path.DirectorySeparatorChar);
|
||||
if (!Directory.Exists(characterDatabasePath))
|
||||
Directory.CreateDirectory(characterDatabasePath);
|
||||
|
||||
@ -911,7 +911,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else if (_ocrMethodIndex == _ocrMethodBinaryImageCompare)
|
||||
{
|
||||
string db = Configuration.OcrFolder + comboBoxCharacterDatabase.SelectedItem + ".db";
|
||||
string db = Configuration.OcrDirectory + comboBoxCharacterDatabase.SelectedItem + ".db";
|
||||
_binaryOcrDb = new BinaryOcrDb(db, true);
|
||||
}
|
||||
}
|
||||
@ -919,7 +919,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private void LoadOldCompareImages()
|
||||
{
|
||||
_compareBitmaps = new List<CompareItem>();
|
||||
string path = Configuration.VobSubCompareFolder + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
string path = Configuration.VobSubCompareDirectory + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
if (!File.Exists(path + "CompareDescription.xml"))
|
||||
_compareDoc.LoadXml("<OcrBitmaps></OcrBitmaps>");
|
||||
else
|
||||
@ -3921,15 +3921,15 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private string SaveCompareItem(NikseBitmap newTarget, string text, bool isItalic, int expandCount)
|
||||
{
|
||||
string path = Configuration.VobSubCompareFolder + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
string path = Configuration.VobSubCompareDirectory + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
string databaseName = path + "Images.db";
|
||||
FileStream f;
|
||||
long pos;
|
||||
if (!File.Exists(databaseName))
|
||||
{
|
||||
if (!Directory.Exists(Configuration.OcrFolder))
|
||||
if (!Directory.Exists(Configuration.OcrDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(Configuration.OcrFolder);
|
||||
Directory.CreateDirectory(Configuration.OcrDirectory);
|
||||
}
|
||||
|
||||
using (f = new FileStream(databaseName, FileMode.Create))
|
||||
@ -5670,7 +5670,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_binaryOcrDb == null)
|
||||
{
|
||||
_binaryOcrDbFileName = Configuration.OcrFolder + "Latin.db";
|
||||
_binaryOcrDbFileName = Configuration.OcrDirectory + "Latin.db";
|
||||
_binaryOcrDb = new BinaryOcrDb(_binaryOcrDbFileName, true);
|
||||
}
|
||||
_nOcrDb = new NOcrDb(_binaryOcrDb.FileName.Replace(".db", ".nocr"));
|
||||
@ -5903,7 +5903,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
using (var process = new Process())
|
||||
{
|
||||
process.StartInfo = new ProcessStartInfo(Configuration.TesseractFolder + "tesseract.exe");
|
||||
process.StartInfo = new ProcessStartInfo(Configuration.TesseractDirectory + "tesseract.exe");
|
||||
process.StartInfo.UseShellExecute = true;
|
||||
process.StartInfo.Arguments = "\"" + tempTiffFileName + "\" \"" + tempTextFileName + "\" -l " + language;
|
||||
|
||||
@ -5924,7 +5924,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
process.StartInfo.WorkingDirectory = (Configuration.TesseractFolder);
|
||||
process.StartInfo.WorkingDirectory = (Configuration.TesseractDirectory);
|
||||
}
|
||||
|
||||
try
|
||||
@ -5939,7 +5939,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Unable to start 'Tesseract' (" + Configuration.TesseractFolder + "tesseract.exe) - make sure tesseract-ocr 3.x is installed!");
|
||||
MessageBox.Show("Unable to start 'Tesseract' (" + Configuration.TesseractDirectory + "tesseract.exe) - make sure tesseract-ocr 3.x is installed!");
|
||||
}
|
||||
throw;
|
||||
}
|
||||
@ -6880,16 +6880,16 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
private void InitializeTesseract()
|
||||
{
|
||||
if (!Directory.Exists(Configuration.TesseractFolder))
|
||||
if (!Directory.Exists(Configuration.TesseractDirectory))
|
||||
{
|
||||
Directory.CreateDirectory(Configuration.TesseractFolder);
|
||||
Directory.CreateDirectory(Configuration.TesseractDirectory);
|
||||
if (!Configuration.IsRunningOnLinux() && !Configuration.IsRunningOnMac())
|
||||
{
|
||||
Process process = new Process();
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo();
|
||||
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
startInfo.FileName = "xcopy";
|
||||
startInfo.Arguments = "\"" + Path.Combine(Configuration.TesseractOriginalFolder, "*.*") + "\" \"" + Configuration.TesseractFolder + "\" /s";
|
||||
startInfo.Arguments = "\"" + Path.Combine(Configuration.TesseractOriginalDirectory, "*.*") + "\" \"" + Configuration.TesseractDirectory + "\" /s";
|
||||
MessageBox.Show(startInfo.Arguments);
|
||||
process.StartInfo = startInfo;
|
||||
process.Start();
|
||||
@ -6897,7 +6897,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
|
||||
string dir = Path.Combine(Configuration.TesseractFolder, "tessdata");
|
||||
string dir = Path.Combine(Configuration.TesseractDirectory, "tessdata");
|
||||
if (Directory.Exists(dir))
|
||||
{
|
||||
var list = new List<string>();
|
||||
@ -7027,7 +7027,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
string fileName = Path.Combine(Configuration.OcrFolder, newFolder.FolderName + ".db");
|
||||
string fileName = Path.Combine(Configuration.OcrDirectory, newFolder.FolderName + ".db");
|
||||
if (File.Exists(fileName))
|
||||
{
|
||||
MessageBox.Show("OCR db already exists!");
|
||||
@ -7057,7 +7057,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
if (_ocrMethodIndex == _ocrMethodBinaryImageCompare)
|
||||
{
|
||||
_binaryOcrDbFileName = Configuration.OcrFolder + comboBoxCharacterDatabase.SelectedItem + ".db";
|
||||
_binaryOcrDbFileName = Configuration.OcrDirectory + comboBoxCharacterDatabase.SelectedItem + ".db";
|
||||
}
|
||||
|
||||
LoadImageCompareBitmaps();
|
||||
@ -7090,7 +7090,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else
|
||||
{
|
||||
_compareDoc = formVobSubEditCharacters.ImageCompareDocument;
|
||||
string path = Configuration.VobSubCompareFolder + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
string path = Configuration.VobSubCompareDirectory + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
_compareDoc.Save(path + "Images.xml");
|
||||
Cursor = Cursors.WaitCursor;
|
||||
if (formVobSubEditCharacters.ChangesMade)
|
||||
@ -7253,7 +7253,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
comboBoxNOcrLanguage.Items.Clear();
|
||||
int index = 0;
|
||||
int selIndex = 0;
|
||||
foreach (string fileName in Directory.GetFiles(Configuration.OcrFolder, "*.nocr"))
|
||||
foreach (string fileName in Directory.GetFiles(Configuration.OcrDirectory, "*.nocr"))
|
||||
{
|
||||
string s = Path.GetFileNameWithoutExtension(fileName);
|
||||
if (s == Configuration.Settings.VobSubOcr.LineOcrLastLanguages)
|
||||
@ -7286,7 +7286,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (comboBoxNOcrLanguage.SelectedIndex < 0)
|
||||
return null;
|
||||
|
||||
return Configuration.OcrFolder + comboBoxNOcrLanguage.Items[comboBoxNOcrLanguage.SelectedIndex] + ".nocr";
|
||||
return Configuration.OcrDirectory + comboBoxNOcrLanguage.Items[comboBoxNOcrLanguage.SelectedIndex] + ".nocr";
|
||||
}
|
||||
|
||||
private void ShowOcrMethodGroupBox(GroupBox groupBox)
|
||||
@ -7903,7 +7903,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
_compareDoc = inspect.ImageCompareDocument;
|
||||
string path = Configuration.VobSubCompareFolder + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
string path = Configuration.VobSubCompareDirectory + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
_compareDoc.Save(path + "Images.xml");
|
||||
LoadImageCompareBitmaps();
|
||||
Cursor = Cursors.Default;
|
||||
@ -7928,7 +7928,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
else
|
||||
{
|
||||
_compareDoc = formVobSubEditCharacters.ImageCompareDocument;
|
||||
string path = Configuration.VobSubCompareFolder + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
string path = Configuration.VobSubCompareDirectory + comboBoxCharacterDatabase.SelectedItem + Path.DirectorySeparatorChar;
|
||||
_compareDoc.Save(path + "Images.xml");
|
||||
}
|
||||
}
|
||||
@ -8573,7 +8573,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
s = s.Replace("?", string.Empty).Replace("/", string.Empty).Replace("*", string.Empty).Replace("\\", string.Empty);
|
||||
if (string.IsNullOrEmpty(s))
|
||||
return;
|
||||
if (File.Exists(Configuration.DictionariesFolder + "nOCR_" + newFolder.FolderName + ".xml"))
|
||||
if (File.Exists(Configuration.DictionariesDirectory + "nOCR_" + newFolder.FolderName + ".xml"))
|
||||
{
|
||||
MessageBox.Show("Line OCR language file already exists!");
|
||||
return;
|
||||
|
@ -53,7 +53,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (_binOcrDb == null)
|
||||
{
|
||||
ImageCompareDocument = new XmlDocument();
|
||||
_directoryPath = Configuration.VobSubCompareFolder + databaseFolderName + Path.DirectorySeparatorChar;
|
||||
_directoryPath = Configuration.VobSubCompareDirectory + databaseFolderName + Path.DirectorySeparatorChar;
|
||||
if (!File.Exists(_directoryPath + "Images.xml"))
|
||||
ImageCompareDocument.LoadXml("<OcrBitmaps></OcrBitmaps>");
|
||||
else
|
||||
|
@ -56,7 +56,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
string fullName = Configuration.VobSubCompareFolder + folderName;
|
||||
string fullName = Configuration.VobSubCompareDirectory + folderName;
|
||||
Directory.CreateDirectory(fullName);
|
||||
FolderName = folderName;
|
||||
DialogResult = DialogResult.OK;
|
||||
|
@ -204,7 +204,7 @@ namespace Nikse.SubtitleEdit.Logic.Ocr
|
||||
}
|
||||
|
||||
// Load names etc list (names/noise words)
|
||||
_namesList = new NamesList(Configuration.DictionariesFolder, _fiveLetterWordListLanguageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
_namesList = new NamesList(Configuration.DictionariesDirectory, _fiveLetterWordListLanguageName, Configuration.Settings.WordLists.UseOnlineNamesEtc, Configuration.Settings.WordLists.NamesEtcUrl);
|
||||
_namesEtcList = _namesList.GetNames();
|
||||
_namesEtcMultiWordList = _namesList.GetMultiNames();
|
||||
_namesEtcListUppercase = new HashSet<string>();
|
||||
|
@ -15,7 +15,7 @@ namespace Nikse.SubtitleEdit.Logic.SpellCheck
|
||||
|
||||
// Finnish uses Voikko (not available via hunspell)
|
||||
if (dictionary.EndsWith("fi_fi", StringComparison.OrdinalIgnoreCase))
|
||||
return new VoikkoSpellCheck(Configuration.BaseDirectory, Configuration.DictionariesFolder);
|
||||
return new VoikkoSpellCheck(Configuration.BaseDirectory, Configuration.DictionariesDirectory);
|
||||
|
||||
return new WindowsHunspell(dictionary + ".aff", dictionary + ".dic");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user